
Igor
New User
Jun 22, 2009, 7:21 AM
Post #1 of 1
(165 views)
|
|
Multiple IP addresses
|
Can't Post
|
|
Hi, I want to get an IP address having the hostname. Most of posts I found suggest something like following: my $myIpAddress = inet_ntoa((gethostbyname($hostname))[4]) Unfortunately for some reason this returns the wrong IP address. I am expecting to get IP Address but got Autoconfiguration IP Address (see below ouput of ipconfig Windows command): Windows IP Configuration Ethernet adapter Network Connect Adapter: Media State . . . . . . . . . . . : Media disconnected Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : my.mycompany.com IP Address. . . . . . . . . . . . : 10.203.2.204 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.203.2.254 Ethernet adapter {MAC address here}: Media State . . . . . . . . . . . : Media disconnected Ethernet adapter AGN Virtual Network Adapter: Connection-specific DNS Suffix . : Autoconfiguration IP Address. . . : 169.254.198.66 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : Does anybody know what peice of code should I write to get IP Address? Thank you in advance, Igor
(This post was edited by Igor on Jun 22, 2009, 7:40 AM)
|