SPUG: Get the local IP address?

Atom Powers atom.powers at gmail.com
Wed Jul 20 15:05:27 PDT 2005


This script is going to run only in a controlled situation.
It's part of my system imaging process, which requires that the system
is registered in DNS by the IP of the network card which is in use,
and there will be only one NIC in use during the build process. Which
in turn gets it's IP from reserved DHCP.

So, even though it may have multiple interfaces it will have only one
address assigned, and that address will have only one hostname
associated with it. I need that hostname so I can set the hostname of
the system during the build.

On 7/20/05, Fred Morris <m3047 at inwa.net> wrote:
> At 2:44 PM 7/20/05, Atom Powers wrote:
> >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.
> >
> 
> Hate to throw a spanner in the works, but machines can have multiple
> network cards; it is unlikely that they will all have the same address. It
> is also possible for a single card to be multi-homed.
> 
> OS-dependent answers include looking for a file /etc/HOSTNAME. Also, what
> does hostname -i return? How does that compare to what plain old hostname
> returns (do they translate to one another)? (on Linux)
> 
> That's another common problem: systems which are misconfigured. Very
> common, biggest support PITA for systems which are sensitive to this sort
> of issue that you can possibly imagine.
> 
> Or, how about the systems which don't even know who they are until they ask
> a DNS server? Yes, they're out there (this is common on HP-UX)!
> 
> 
> Is there a Perlish solution to this rather complex problem? Inquiring minds
> want to know!
> 
> --
> 
> Fred Morris
> http://www.inwa.net/~m3047/contact.html
> 
> 
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
>     WEB PAGE: http://seattleperl.org/
> 


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


More information about the spug-list mailing list