Tuesday, March 26, 2013
remove primary ip address without removing secondary one[s]
today i have faced a problem of removing ip addresses using iproute.
i add two ip addresses from the same subnet using following commands
# ip addr add 10.35.2.129/24 dev eth0
# ip addr add 10.35.2.130/24 dev eth0
to see result
# ip addr sh
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether a4:ba:db:b7:fa:db brd ff:ff:ff:ff:ff:ff
inet 10.35.2.129/24 scope global eth0
inet 10.35.2.130/24 scope global secondary eth0
as you can see ip address 10.35.2.130 which was added after 10.35.2.129 is flagged as secondary.
iproute works fine when you try to remove secondary address.
# ip addr delete 10.35.2.130/24 dev eth0
the problem starts when i remove a primary address. iproute deletes all secondary addresses which are in the same subnet with primary address.
here i find explanation of secondary address according to the documentation:
"secondary --- this address is not used when selecting the default
source address for outgoing packets. An IP address becomes
secondary if another address within the same prefix (network)
already exists. The first address within the prefix is primary and
is the tag address for the group of all the secondary addresses.
When the primary address is deleted all of the secondaries are
purged too. See the examples for the actual functionality of these
steps."
in the docs i found nothing related to promoting secondary ip addresses in case if primary address was deleted. if you don't find it, it doesn't mean that it doesn't exist...
good news !!!
starting from 2.6.16 linux kernel supports promoting secondary ip addresses.
to enable it do following
# echo 1 > /proc/sys/net/ipv4/conf/all/promote_secondaries
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment