I recently ran into a bug in the jail startup scripts that caused this
command to be executed:
ifconfig bce0 -alias
It turns out that this command eliminated the primary IP for the device.
man ifconfig defines the behavior of -alias to be:
-alias Remove the network address specified. This would be used
if you
incorrectly specified an alias, or it was no longer needed. If
you have incorrectly set an NS address having the side
effect of
specifying the host portion, removing all NS addresses will
allow
you to respecify the host portion.
I can't help but wonder if it would be better behavior to throw an error
when no
argument is supplied.
The only discussion I found of this in a quick search of the archives
was a post in
2004 which noted that the fxp driver actually deletes all IP addresses,
but there was
no significant follow-up.
Should ifconfig throw an error if no address is supplied?
-Kevin Way
On Fri, Feb 09, 2007 at 04:06:56PM -0500, Kevin Way wrote:> I recently ran into a bug in the jail startup scripts that caused this > command to be executed: > > ifconfig bce0 -alias > > It turns out that this command eliminated the primary IP for the device. > > man ifconfig defines the behavior of -alias to be: > > -alias Remove the network address specified. This would be used > if you > incorrectly specified an alias, or it was no longer needed. If > you have incorrectly set an NS address having the side > effect of > specifying the host portion, removing all NS addresses will > allow > you to respecify the host portion. > > > I can't help but wonder if it would be better behavior to throw an error > when no > argument is supplied. > > The only discussion I found of this in a quick search of the archives > was a post in > 2004 which noted that the fxp driver actually deletes all IP addresses, > but there was > no significant follow-up. > > Should ifconfig throw an error if no address is supplied?My vote is for either 1) an error, or 2) delete all of the aliases associated with that interface. If I had a preference, I'd choose #1. I'd argue that -alias doing what you described (removing the non-aliased IP bound to the iface) when no inet/inet6 arguments are suppied is indeed a bug. -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |
> 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. -pcf.