TIBCO LogLogic LMI - Converting hex IP addresses to dotted decimal notation in MySQL

TIBCO LogLogic LMI - Converting hex IP addresses to dotted decimal notation in MySQL

book

Article ID: KB0077070

calendar_today

Updated On:

Products Versions
TIBCO LogLogic Log Management Intelligence all versions

Description

Occasionally inside MySQL, when troubleshooting an LMI issue or working with third party software, you may be presented with a hexadecimal-formatted IP address. The solution below shows how to convert this to conventional dotted decimal notation.

Issue/Introduction

This article shows you how to convert hex formatted IP addresses to dotted decimal notation inside MySQL.

Resolution

If the hex IP address is 4333d26e you can convert it using this query:

mysql> select inet_ntoa(conv('4333d26e', 16, 10));
+-------------------------------------+
| inet_ntoa(conv('4333d26e', 16, 10)) |
+-------------------------------------+
| 67.51.210.110                       |
+-------------------------------------+
1 row in set (0.00 sec)


The syntax of the conv() function in MySQL is to take the value to be converted as the first parameter, the 2nd parameter is the base from which the value is being converted and the 3rd parameter is the base to which the value is being converted. So the above example uses 16 (hexadecimal) and 10 for the base to convert from and to, respectively.