CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Multiple IP addresses

 



Igor
New User

Jun 22, 2009, 7:21 AM

Post #1 of 1 (194 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:


Code
  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):


Code
 
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)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives