On Fri, 27 Jan 2006, Alexander Hall wrote:

> Hi!
> 
> I just noticed (the hard way) a strange behaviour of ifconfig. In short, if I
> supply a netmask when removing an alias with ``-alias <address>'', it is not,
> as one would expect, ignored, but rather used as the netmask for the primary
> address of the interface.
> 
> While it would not be necessary to supply the netmask when removing an alias,
> I cannot see that this behaviour would be expected. I would rather expect an
> error or that the netmask was ignored.
> 
> Or am I totally wrong?

alias/-alias is a _parameter_ and should come after the address. 
It would be better if ifconfig would be more strict, but its argument
parsing code is a nightmare....

        -Otto

> 
> Example follows:
> 
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
> $ sudo ifconfig xl0 inet alias 192.168.2.140 netmask 255.255.255.255
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffff00 broadcast 192.168.2.255
>         inet 192.168.2.140 netmask 0xffffffff broadcast 192.168.2.140
> $ sudo ifconfig xl0 inet -alias 192.168.2.140 netmask 255.255.255.255
> ifconfig: SIOCAIFADDR: File exists
> $ ifconfig xl0
> xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:06:5b:36:f8:e1
>         groups: egress
>         media: Ethernet autoselect (100baseTX full-duplex)
>         status: active
>         inet6 fe80::206:5bff:fe36:f8e1%xl0 prefixlen 64 scopeid 0x1
>         inet 192.168.2.130 netmask 0xffffffff broadcast 192.168.2.130
>                                    ^^^^^^^^^^
>                                      madness
> 
> /Alexander

Reply via email to