Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mailrus!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!mcsun!ukc!kl-cs!jonathan From: jonathan@cs.keele.ac.uk (Jonathan Knight) Newsgroups: comp.unix.wizards Subject: Re: Determining one's own IP address. Message-ID: <1204@kl-cs.UUCP> Date: 13 Dec 89 11:03:39 GMT References: <5215@tekcrl.LABS.TEK.COM> Organization: University of Keele, England Lines: 38 From article <5215@tekcrl.LABS.TEK.COM>, by terryl@tekcrl.LABS.TEK.COM: > > Well, as they say (whoever THEY are!! (-:), RTFM (at least for a BSD > system): > > sethostid(2), gethostid(2), hostid(1) Ok, I did 'man hostid' and it says... This numeric value is expected to be unique across all hosts and is normally set to the host's Internet address. Note that it says 'normally' so you can't assume it will be. This is for an Ultrix 1.2 vax. A sun of course is different, the hostid is encoded in the ROM at the factory and can't be changed, so it's just a "number that's unique accross all sun hosts." (sun manual) The program 'ifconfig' will give you the IP address for your host. The output formats vary a little, but it seems consistent for getting the IP address out. (e.g. 'ifconfig qe0' or 'ifconfig le0' or 'ifconfig ie0' depending on your interface name) I have never tried to get the IP address for an interface from within a C program however here are a few manual pages that should put you on the right track. On Sun. man 4n if man 4n routing On Ultrix man 4n intro -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.