SPUG: Get the local IP address?

Atom Powers atom.powers at gmail.com
Wed Jul 20 14:44:39 PDT 2005

I'm trying to write a script what will give me the host name ( from
DNS ) for whatever machine it is run on. The stumbling block is
getting the local IP address.

Can anybody give me clues to how I can grab the local IP address of
the computer, given an arbritrary number of interfaces (but only one
of them has an IP address)?

And once I have the address, I can do this, right?

$hostname    = gethostbyaddr(inet_aton($address), AF_INET)

Perfection is just a word I use occasionally with mustard.
--Atom Powers--

More information about the spug-list mailing list