I have several IPv6 addresses on a CentOS 7 server and need to make a specific v6 address the default address used in routing. I have been able to do this by modifying the route table.
ip -6 route del default
ip -6 route add default via 2001:470:xxxx:xx::1 src 2001:470:xxxx:xx::6
Problem is each time the network interface is restarted or the server itself is rebooted, the change to the default IPv6 route is lost. How can I make this change persistent so its permanently kept?
When Red Hat's networking scripts set multiple IPv6 addresses configured in
/etc/sysconfig/network-scripts/ifcfg-*
, for whatever reason, they are applied in reverse order, so that the last address listed inIPV6ADDR_SECONDARIES
becomes the address used by default for outgoing connections. Reversing the order in which IPv6 addresses are listed is generally sufficient to fix the problem.To answer the only vaguely related bounty question: IPv6 static routes can be set by adding them to a corresponding
/etc/sysconfig/network-scripts/route6-*
. The format of this file is the same as theip route add
command with that bit omitted, e.g.:One place you can put it is in the
/sbin/ifup-local
file which is run when an interface comes up.It doesn't exist by default so you will need to create it and set permissions to make it executable.