Just gimme the IP!

Clint Byrum clint at ubuntu.com
Wed Jun 15 17:02:58 UTC 2011


Excerpts from Dustin Kirkland's message of Mon Jun 13 18:58:21 -0700 2011:
> Howdy ubuntu-devel!
> 
> I'm seeing quite a bit of code duplication in scripts and packaging in
> Ubuntu around the determination of IP addresses.
> 
> Most are permutations of 'ifconfig' or 'ip addr', and four to six
> pipes through awk, grep, sed, and/or cut.  Some others dig through
> /proc.  Some are buggy (ie, more than one ip address on the system,
> foreign locale but does not set LC_ALL=C, etc).  Many of them do their
> job well enough, but I can't help but think there's some room for
> improvement.

First, Dustin, thanks for taking this on. Seeing my hacks on top of
hacks in principia seems to have pushed you to do something positive
about the propagation of this flawed technique, which if nothing else
has accomplished a spirited discussion about the issue.

However, after reading the logs of Dustin's discussion on IRC w/ Keybuk
and cjwatson, I have to think that this is actually something we should
move away from.

The usage of the ifconfig parse hack in principia is actually completely
unnecessary, and stems from a very old distrust of DNS that I have had for
a long time as a sysadmin. The truth of the matter is, DNS is the right
way to resolve this, and any latency concerns should be addressed with
local DNS caches.

You should have an FQDN, and it should always lead a remote host that
can talk to you, to the IP that it needs to use to talk to you. This
isn't always true, but in the use case we have in Ensemble and Principia,
this is precisely the case. Amazon assigns an IP and a FQDN to each host,
and that FQDN resolves inside Amazon to the internal IP that any machine
on the same security group can use to access it.

For anything else, you need more information that isn't available on
the machine anyway (such as your external NAT address or elastic IP in
the EC2 case).

So really, passing what I *think* is my IP isn't nearly as useful as
passing what I *know* is my hostname. This is especially important as
we transition to IPv6.

For the other places where IP is being used, the use should be evaluated,
as its likely hostname would work, and should be used instead.



More information about the ubuntu-devel mailing list