Desired behaviour of "ifconfig -alias"
olli at lurza.secnetix.de
Mon Feb 12 18:10:00 UTC 2007
JoaoBR <joao at matik.com.br> wrote:
> Oliver Fromme wrote:
> > JoaoBR <joao at matik.com.br> wrote:
> > > "ifconfig nic -alias" is obviously a wired and confusing behaviour
> > It might be confusing to you. Personally I think that the
> > current behaviour isn't that far off.
> the question is not you or me,
But you called it "confusing". That's just your personal
perception. It doesn't mean it is confusing to everybody.
In fact it might be useful to others. It _is_ useful to
me, for example, and I would object for that syntax to go
away. Also note that it doesn't hurt anybody. If you
don't like that that syntax doesn't throw an error, then
don't use that syntax.
However, I agree that the manual page should be updated a
bit to match reality. If nobody else does it, I can take
a shot at it and submit a docs PR.
> > First you need to be aware that there is no distinction
> > between a primary IP and alias IPs (such a distinction
> > existed historically, but it's gone). All of the IPs on
> > an interface are equal, just like hardlinks on a file.
> I said this in shorter words in my post but it is not the point at all.
It's not "the" point, but it's an important detail.
> > The "-alias" parameter simply removes an address from an
> man page tells us that it removes THE specified address ... not AN address
I didn't say what the manpage says, I said what the "-alias"
If the manpage says something different, I suggest that the
manpage should be fixed.
> > interface. The term "alias" should really be avoided
> > because it is misleading. You can use "delete" or "remove"
> > which do the same thing. I think "-alias" should really
> > be regarded to exist for backwards compatibility only.
> > Personally I always use "delete".
> it is not misleading and it is a perfect term. With alias you add secondary
> addresses to an interface. Like secondary is probably the better word,
No, not at all. As soon as you use the terms "primary IP
address" and "secondary IP addresses", you imply that they
are not equal. But they are equal. It's just a list of
IP addresses assigned to an interface which happens to have
a certain order.
> I know that I can add the first IP also with alias but that is not the usual
The usual way is to use "add" and "delete". Well, at least
(I'm not advocating to remove the historical "alias" and
"-alias" parameters, if that's what you're afraid of.
Use them if you like them. That's not the point.)
> Also do not forget that the usual way since ever is ifconfig_nic_alias0 to
> add one. So this thing is confusing.
Yes, that's why I wrote it should be changed to not contain
the word "alias" anymore, but simply an enumerated list.
> > If no IP address is specified, then it's not completely
> > nonsensical to remove the first address. In fact I've
> > used that short-cut to quickly remove the only address
> > from an interface. I've used "ifconfig xyz0 delete"
> > quite a lot.
> the man page tells us that -alias removes *the* specified address and not the
> first, also the man page does not say that there is any further action when
> *no* IP address specified
That's true. Usually if something is not documented, the
behaviour is undefined.
> delete is according to the man page another word for -alias, that means, using
> grammatical logic that -alias is the main command,
No. It means that "delete" and "remove" are aliases for
"-alias". In reality they're simply equal. ;-)
> then according to the man
> page there is no other command as "-alias *IP*" to remove an IP address
> and -alias only should not remove anything
It's not documented that way. As I wrote above.
If something is not documented, that doesn't mean that it
shouldn't do anything at all. In that case a _lot_ of
things wouldn't work. :-)
> > > then already beeing here there is more, ifconfig nic alias does not
> > > return anything at all
> > That's the same as "ifconfig nic add". If you don't tell
> > it anything to add, then it won't add anything, of course.
> > Remember that UNIX always tries to do exactly what you
> > tell it to dao. ;-)
> you see, now you apply logic because you want to and when not not ... ;)
> to let it more clear what I mean, you say: "you don't tell it anything to add"
> so why the heck "ifconfig nic -alias" should remove one if I do not tell so?
In the case of adding something, what should be added if
nothing is specified? Should the tool invent an arbitrary
IP address and add it? Now that would be nonsensical.
But when removing something without specifying which one,
it makes some sense to simply remove the first existing
address on that interface. It would even be OK with me
to remove the last one, or an arbitrary one -- I use that
shortcut mostely when I need to remove the only address
from an interface (or all existing addresses), so it
In fact, it might also make sense to enhance the syntax
to allow the specification of a number, for example
"ifconfig xyz0 delete #2" would remove the second address
from that interface. (That's just an example, the syntax
may look different.)
However, such a feature will run into problems when the
set of ip addresses is not an ordered list anymore, which
might very well happen in the future. Then there will be
no "first" and "last" anymore, but instead the interface
will just have an unordered set of IP addresses. In fact
I wish that would already be the case, so people saying
"primary" and "secondary" would shut up already. :-)
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, USt-Id: DE204219783
Any opinions expressed in this message are personal to the author and may
not necessarily reflect the opinions of secnetix GmbH & Co KG in any way.
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"A language that doesn't have everything is actually easier
to program in than some that do."
-- Dennis M. Ritchie
More information about the freebsd-stable