Determining one's own IP address.

Chris Torek chris at mimsy.umd.edu
Wed Dec 13 04:59:16 AEST 1989


In article <604 at bmers58.UUCP> davem at bmers58.UUCP (Dave Mielke) writes:
>I would like to be able to determine my local IP address without
>involving a hosts file or yp lookup, i.e. from memory, from within a c
>program.

Since your machine might have anywhere from zero to several hundred
official IP addresses, this is not possible.

The closest thing there is to `myself' is 127.0.0.1, which (I think)
has now been officially reserved to mean `loopback' or `connect to
myself'.

4BSD provides a `gethostid' call, but what you get is not necessarily
a valid IP address.  Since we had never set our hostid under 4.2BSD
(setting it to zero, in effect), I am fairly sure that nothing in 4.2BSD
actually used it.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list