4

How can I get the IP v4 Of the server by using PL/SQL ? UTL_INADDR.GET_HOST_ADDRESS gives me IPv6, while I need IPv4

what I did I disabled the IPv6 on the sever, still it's bringing me the the IPv6 of the "Tunnel adapter Teredo Tunneling Pseudo-Interface" !!

I'm using Oracle 11g database on Windows 2008 R2 Server

Data-Base
  • 8,418
  • 36
  • 74
  • 98

1 Answers1

3

UTL_INADDR.GET_HOST_ADDRESS returns just an ip which is nonsense since a server may have dozens of them. Probably your best bet it's to create a pl/sql wrapper of a Java method which returns every possible ip address using NetworkInterface.getNetworkInterfaces();

Samuel
  • 2,430
  • 2
  • 19
  • 21
  • the server we are setting up has one IP, so it's ok if it returns this one IP! – Data-Base Jun 08 '11 at 09:22
  • It seems that's not true when you have ipv6 interfaces. You could open an ipv4 connection with utl_tcp (http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_tcp2.htm#1002748)and look at the local_host property, but I don't think its a great idea... – Samuel Jun 08 '11 at 14:16
  • This may also work: select UTL_INADDR.GET_HOST_ADDRESS(SYS_CONTEXT('USERENV', 'SERVER _HOST')) ipaddr from dual; – Samuel Jun 08 '11 at 14:39