Linux IPv6 Static Routes – Ubuntu/Debian & Fedora/RedHat

Looking at my blog statistics I realized that my most popular posts are those related to practical configuration and How To. This post will be one of them.

During the various tests I’ve performed on Linux platforms, one issue that was common –  that if you configure a default gateway like that:

Ubuntu/Debian

iface eth0 inet6 static
address xxxx:xxxx::xxxx/64
gateway xxxx:xxxx::yyyy

Fedora/RedHat

vi /etc/sysconfig/network
NETWORKING_IPV6=yes

and

vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPV6INIT=yes
IPV6ADDR=xxxx:xxxx::xxxx/64
IPV6_DEFAULTGW=xxxx:xxxx::yyyy

The above works fine when you do network restarts however will fail after a system reboot. The failure is rather interesting. After the reboot it looks like everything is fine till the moment you do some traffic. For instance doing a ping6 will allow one single packet, after which the default is present in the routing table but no packets flow. The situation can be ameliorated by putting in your

/etc/rc.local

an:

ip -6 route add ::/0 via xxxx:xxxx::yyyy dev eth0

The drawback is that even if it works after reboots, you will have to manually add it back after a network restart.
This was not good enough for production.

After searching for some time I finally found how to configure static routes in the right manner so they would work after both reboots and network restart.
An article describing that can be found here or here.

The typical configuration for Ubuntu will be:

vi /etc/network/interfaces

iface eth0 inet6 static
address xxxx:xxxx::xxxx
netmask 64
up ip -6 route add ::/0 via xxxx:xxxx::yyyy dev eth0
down ip -6 route del ::/0 via xxxx:xxxx::yyyy dev eth0

so the routes would add/delete themselves on interface ups or downs.

In case of Fedora/RedHat there is a substitute for the well know

/etc/sysconfig/network-scripts/route-eth0

the equivalent for IPv6 would be:

vi /etc/sysconfig/network-scripts/route6-eth0
::/0 via xxxx:xxxx::yyyy dev eth0

Hope this helps.

Advertisements

4 thoughts on “Linux IPv6 Static Routes – Ubuntu/Debian & Fedora/RedHat

  1. You actually make it appear really easy along with your presentation however I in finding this topic to be actually one thing that I feel I would by no means understand. It kind of feels too complex and very broad for me. I am looking forward to your next submit, I’ll attempt to get the hold of it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s