Desired behaviour of "ifconfig -alias"

Jeremy Chadwick koitsu at
Tue Feb 13 18:09:11 UTC 2007

On Tue, Feb 13, 2007 at 05:19:59PM +0000, Pete French wrote:
> > For a set of IPs in the same subnet on the same interface, wouldn't the 
> > primary IP be the one with the proper netmask, and all IPs with netmasks 
> > of /32 be secondary?  In that situation, wouldn't deleting the primary IP 
> > cause connection issues for the rest of the IPs?
> Indeed. I too am not convinced by the 'there is no such thing as a
> primary IP address' thing either - because it's trivial to observe
> that if you add several addresses to an interface and make outgoing
> connections then one of those (the one with the correct netmask) is
> always the one used as the source address. Which looks suspiciously like
> a primary IP address to me - or at least one which is being treated
> slightly differently to all the others on that interface anyway.

I agree.  I consider the "primary IP" the first (non-aliased) IP bound
to the interface.  This is the same IP used by default if no particular
IP address is explicitly populated sockaddr_in.sin_addr.s_addr
during bind(2).  I think most system administrators consider a "primary
IP" the same thing I do.

The underlying API probably does not differentiate any of them
(although the routing table seems to differentiate aliases from the
"primary IP"; look at netstat -rn), but underlying socket calls
probably pick the first entry in the "address index table" per
interface when one is not defined, probably based on the routing
table too.

| Jeremy Chadwick                                 jdc at |
| Parodius Networking               |
| UNIX Systems Administrator                   Mountain View, CA, USA |
| Making life hard for others since 1977.               PGP: 4BD6C0CB |

More information about the freebsd-stable mailing list