Subject: Re: ifconfig and aliases
To: Mike Pelley <mike@pelley.com>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-net
Date: 07/20/1999 08:21:49
In some email I received from Mike Pelley, sie wrote:
> 
> > - configuring aliases for interfaces.  The method `supported' by netstart
> >   is unsatisfactory if you wish to configure more than one interface.
> >
> > - the method suggested in netstart for setting the netmask does not work.
> >   If I have an interface setup as 192.168.1.1/29 and add an alias, the
> >   netmask does not appear to be applied, instead a /24 (class C) netmask
> >   is applied to the alias.  Perhaps ifconfig should do a `head -1' of
> >   /etc/ifconfig.ifname to set initial options with a loop processing the
> >   rest of the file (if any).
> 
> The netstart on my 1.4 maching has the following comment:
> 
>     Check if each configured interface xxN has an $ifaliases_xxN
>     variable associated, then configure additional IP addresses for that
>     interface.  The variable contains a list of "address netmask" pairs,
> with
>     "netmask" set to "-" if the interface default netmask is to be used.
> 
> I'm not sure why this is not suitable for more than one interface.  If you
> prefer to use the /etc/ifaliases file it seems to operate in a similar
> manner - at least w.r.t. multiple interfaces -
[...]

Reading the script more closely makes it apparent you can do things
like:
alias_we0="10.1.0.100 - 10.1.0.101 0xffffff00"
not to mention that the ordering of fields in /etc/ifaliases leaves
a lot to be desired; the usual ordering of things is:
interface address netmask

It's neither obvious nor demonstrated where the correct place to put
alias_xyZ is.

> > - when setting an IP address alias on an interface where the IP number
> >   falls inside the network for the interface, ifconfig prints out an
> >   error ("ifconfig: SIOCAIFADDR: File exists") but sets it up anyway.
> 
> I believe this error exists because it attempts to add the network your
> ip/netmask describes.  If your IP address falls inside a network already
> assigned to the interface, setting the netmask to "-" as suggested in the
> comment mentioned above (or leaving it blank in the /etc/ifaliases file)
> seems to work well.

Setting the netmask to "-" just tells netstart not to supply the netmask
args on the command line for ifconfig.  From a command line:

# ifconfig cs0 alias 192.168.1.200
ifconfig: SIOCAIFADDR: File exists

which is what'd happen with "-".  Either this error should not be returned
or that shouldn't work.  I'd prefer the former.