1

I would like to add an extra IPv6 address so I can run a service on it but I want to retain the existing IPv6 address as the address to use for outgoing connections.

When I add an ipv4 address with

ip addr add <address> dev <device>

It gets added as "secondary" and is not used by default for outgoing connections but when I do the same for ipv6 the address is just added as a normal address and (all else being equal) linux uses the most recently added address for outgoing connections.

There appears to be a "deprecated" flag which can mark an IPv6 address as non-default but there doesn't seem to be any obvious way to set it.


Show us an output from ip and tell us how and where you see an address is "primary" and/or "secondary".

6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 68:b5:99:78:63:d4 brd ff:ff:ff:ff:ff:ff
    inet 5.153.225.206/26 brd 5.153.225.255 scope global bond0
    inet 5.153.225.207/26 scope global secondary bond0
    inet6 2001:41c9:1:3ce::11/64 scope global
       valid_lft forever preferred_lft forever
    inet6 2001:41c9:1:3ce::10/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::6ab5:99ff:fe78:63d4/64 scope link
       valid_lft forever preferred_lft forever

The extra IPv4 address is shown as "secondary" and is not used by default for outgoing connections but the extra IPv6 address is just listed the same as the first address and is chosen by default for outgoing connections.

1
  • Can you please clarify your problem? Show us an output from ip and tell us how and where you see an address is "primary" and/or "secondary". Which problems result from this? "deprecated" does not mark an andress as "non-default" but rather as "we'll be using another address soon".
    – Bananguin
    May 24, 2016 at 5:52

1 Answer 1

3

The deprecated flag is set when the "preffered lifetime" of the address drops to zero. You can set the preffered lifetime flag when adding an address by doing.

ip addr add <address> dev <device> preferred_lft <lifetime>

you can also set it on an existing address

ip addr change <address> dev <device> preferred_lft <lifetime>

Setting it to zero will immediately mark the address as deprecated. I'm not sure what the units are if you set it to a value other than zero.

Note the preffered_lft option and the ip addr change command do not seem to be documented in the manpage.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .