Configuring IP address aliasing

Alex Zbyslaw xfb52 at dial.pipex.com
Mon Jan 26 08:50:35 PST 2004


Mike wrote:
> # ifconfig -a
> ed0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         inet 192.168.1.40 netmask 0xffffff00 broadcast 192.168.1.255

> # ifconfig ed0 alias 192.168.1.41 netmask 255.255.255.0 broadcast 
> 192.168.1.255
> ifconfig: ioctl (SIOCAIFADDR): File exists
> [using same netmask as real interface]

> However, THIS WORKED:
> # ifconfig ed0 alias 192.168.1.41 netmask 255.255.255.255 broadcast 
> 192.168.1.255
> [using a netmask of 255.255.255.255]
> 
> QUESTION: Why do I use a different netmask (255.255.255.255) for a IP 
> alias on FreeBSD?  Why isn't 255.255.255.0 used?

 From the ifconfig man page on 4.9

alias   Establish an additional network address for this interface.  This
         is sometimes useful when changing network numbers, and one wishes
         to accept packets addressed to the old interface.  If the address
         is on the same subnet as the first network address for this
         interface, a non-conflicting netmask must be given.  Usually
         0xffffffff is most appropriate.

Since 192.168.1.41 is on the same subnet as 92.168.1.40 you must use 
0xffffffff (aka 255.255.255.255) as the netmask.  (I don't know *why* I'm afraid).

You could always stick the alias on a different subnet at which point you can 
use the netmask you expect.

e.g. # ifconfig ed0 alias 192.168.2.40 netmask 255.255.255.0 broadcast 
192.168.2.255

--Alex




More information about the freebsd-questions mailing list