[380] in linux-net channel archive

home help back first fref pref prev next nref lref last post

Feature/hack for multi-homed hosts (esp. ifconfig alias)

daemon@ATHENA.MIT.EDU (Ian Jackson)
Sat May 27 14:49:54 1995

Date: Sat, 27 May 95 12:41 BST
From: iwj10@cus.cam.ac.uk (Ian Jackson)
To: linux-net@vger.rutgers.edu

There is currently a small problem when trying to use ifconfig alias
or dummy devices or just plain multiple interfaces to give their
machine several IP#'s which respond differently to incoming
connections.

Most TCP/IP-based programs aren't aware that there is a decision to be
made about which local address to bind to, and just pass `bind'
all-zeroes in the IP# field.  This causes the resulting socket to
listen on all the machine's interfaces.

Ultimately, of course, each program should be modified to have a
configuration option for the local interface to use.  However doing
this to many programs would be tedious at the very least, and in some
cases impossible (a nice example of this is net-Doom).

How about having an environment variable (IP_BIND_DEFAULT_ADDR or some
such) which contains the IP address to use ?  The C library's `bind'
call would, if the address type was AF_INET and the IP# was
all-zeroes, copy the struct and fill in the IP# from
IP_BIND_DEFAULT_ADDR.

This is the kind of solution that strikes some people as `elegant' and
others as a `horrible hack'.  Perhaps it's both.  There is some
precedent for having environment variables modify the behaviour of
standard library calls, especially in the TCP/IP context - for
example, the variable HOSTALIASES used by gethostbyname() and RESOLV_*
used by the resolver.

(I thought about posting this to the linux-gcc list too, but decided
to field it here first.)

Ian.

home help back first fref pref prev next nref lref last post