ifconfig adds wrong netmask when setting an IP in an interface previously...
Linux networking base tools
Brought to you by:
eckes
Hi,
when using ifconfig to set IP address on an interface that already has an IP address previously added using iproute2 CLI, the IP is set with the default netmask of the private class.
I could reproduce this situation in a recent ubuntu 13.10 (net-tools 1.60-25ubuntu1), ubuntu 7.04 (net-tools 1.60-17ubuntu1), ubuntu 8.04, in a 2004's busybox (busybox 1.00-5).
In order to reproduce this behavior you could execute the following commands:
root@gurb:~# ip link add test type dummy root@gurb:~# ip address add dev test 192.168.55.5/24 root@gurb:~# ip address add dev test 10.99.99.5/24 root@gurb:~# ip -4 address show dev test 5: test: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN inet 192.168.55.5/24 scope global test valid_lft forever preferred_lft forever inet 10.99.99.5/24 scope global test valid_lft forever preferred_lft forever root@gurb:~# ifconfig test 10.10.10.10 netmask 255.255.255.252 root@gurb:~# ip -4 address show dev test 5: test: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN inet 10.10.10.10/8 brd 10.255.255.255 scope global test valid_lft forever preferred_lft forever inet 10.99.99.5/30 scope global test valid_lft forever preferred_lft forever
As you can see, the 10.10.10.10/30 has been added as 10.10.10.10/8, the same happens with 172.... class but the default netmask there is /16, and with 192.168... with /24.
Thanks,
Xavier.
You can also see that the netmask I try to setup with ipconfig has been set to the secondary IP address (10.99.99.5/30) overwritting the original netmask