Get IP via hostname or hostname via IP in PL/SQL

Sometimes you need to find out in PL/SQL the IP address of a hostname or more frequently the hostname from the IP address (as nslookup does), for instance to check where a web request is from.

Oracle has the package utl_inaddr that allows us to solve that problem.

Let's see some use examples:

select utl_inaddr.get_host_address('www.google.com') as ipaddress from dual;


select utl_inaddr.get_host_name('') as hostname from dual;


Of course the function utl_inaddr.get_host_address will give one of the answering IP address and that IP address can have a specific hostname.

Versão Portuguesa deste post disponível

No comments:

Post a Comment

Os comentários são moderados.
The comments are moderated.