[Users] Suggestion for a new parameter: PRIMARY_IP

Marcin Owsiany marcin at owsiany.pl
Mon Jan 5 18:10:59 EST 2009


On Mon, Jan 05, 2009 at 10:43:28AM +0100, Dietmar Maurer wrote:
> > On Sun, Jan 04, 2009 at 09:21:42AM +0100, Dietmar Maurer wrote:
> > > How does adding an additional setting like PRIMARY_IP help? Instead
> > > you can simply change the order of IP_ADDRESS. What is the
> > difference?
> > 
> > Changing the order would influence both /etc/hosts and
> > /etc/network/interfaces in the same way. I want them different.
> 
> The question is why you want that.

Long story short, I would like the fqdn to stay static even if
externally-routable IP addresses come and go. That is why I would like
/etc/hosts to have an internal IP address (that is pretty much going to
stay there) mapped to the system hostname. However I would like an
externally-routable IP address to be the first on the interface, so that
applications can make connections to the internet by default.

> > Any process running in a CT that does not explicitly bind() to a
> specific 
> > address, will have the local endpoint address set to the first one in
> > IP_ADDRESS from the CT configuration. [1]
> 
> The manual page (ip(7)) states something different. Either you pass an
> specific address to bind, or use some special address like INADDR_ANY.

I read that manpage multiple times, trying to figure out what exactly
happens when. It states that specifying INADDR_ANY is equivalent to not
calling bind() at all before connect(). However if you read closely, it
does not state the semantics of such situation for "active" sockets
(i.e. sockets you call connect() on, as opposed to sockets on which you
call listen()/accept()).

In fact I could not find any documentation on such behaviour on the
internet, so I read the Linux source code. The description in the
footnote of my initial email in this thread is my interpretation of what
happens (which matches experiments I made).

> All application I know use gethostbyname to get the address (hostname +
> /etc/hosts).

I think you're confusing (userspace) address resolution with
(kernelspace) socket address assignment.

> So if you application depends on the order of /etc/network/interfaces
> I would consider that an application error.

Blame the kernel, then :-)

> What application are we talking about? 

Oh, just about anything that does: socket(); connect(); (without a
bind() in between), for example default usage of wget, telnet, ssh.. any
TCP client really.

regards,
-- 
Marcin Owsiany <marcin at owsiany.pl>              http://marcin.owsiany.pl/
GnuPG: 1024D/60F41216  FE67 DA2D 0ACA FC5E 3F75  D6F6 3A0D 8AA0 60F4 1216
 
"Every program in development at MIT expands until it can read mail."
                                                              -- Unknown


More information about the Users mailing list