Created
February 27, 2012 20:03
-
-
Save jonjensen/1926660 to your computer and use it in GitHub Desktop.
RHEL 6 IPv6 default source address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux's default source address selection for multiple IPv6 addresses on the | |
# same interface leaves a lot to be desired. See: | |
# http://www.akkadia.org/drepper/linux-rfc3484.html | |
# | |
# The RFC 3484 method described there and used in gai.conf feels like the | |
# wrong way to me, so I used the approach documented here: | |
# http://www.davidc.net/networking/ipv6-source-address-selection-linux | |
# and mark all but the main IPv6 source address as "deprecated" so they | |
# won't be used as default source addresses (but otherwise function fine). | |
# | |
# We should be able to specify options like preferred_lft at address setup | |
# time for IPV6ADDR_SECONDARIES, but in file | |
# /etc/sysconfig/network-scripts/network-functions-ipv6 | |
# function ipv6_add_addr_on_device does: /sbin/ip -6 addr add $address dev $device | |
# and doesn't allow for any options. | |
# | |
# Thus the following is custom hacking which runs multiple times during network | |
# setup, since there is also no post-config-only hook we can use. Yes, in | |
# /etc/sysconfig/network. | |
# | |
IPV6ADDR=2a01:4f8:151:5384::2 | |
the_device=eth0 | |
ip -6 addr show dev $the_device \ | |
| grep 'inet6 ' | grep 'scope global' | grep -v "$IPV6ADDR" | grep -v deprecated \ | |
| sed 's/^\s*inet6 //; s/ .*//;' \ | |
| while read addr | |
do | |
ip addr change $addr dev $the_device preferred_lft 0 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment