Linux IPv6 Route
IPv6 is the future. Knowing how to add a Linux IPv6 route is an important skill. Not everybody is using IPv6 on their network. Often times people may not even be familiar with basic operations even though they are completely OK with IPv4.
We are going to use eth0 as the device name in most of our examples. The interface may be named differently. It could look something like this: enp0s25.
Showing Linux IPv6 Routes
There are a few different ways to view existing IPv6 routes on a Linux system.
You can show all IPv6 routes on your Linux system like this:
ip -6 route show
If you want to show your IPv6 routes them for a specific interface, for example eth0, you can specify it like this:
ip -6 route show dev eth0
You can also do this using the route command.
route -A inet6
If you want to filter based on a specific interface, you can grep for that interface name.
route -A inet6 |grep -w "eth0"
Add and Removing a Linux IPv6 Route
NOTE - Unless you are running as root, you will probably want to run these commands with sudo.
Add through gateway:
sudo ip -6 route add 2000::/3 via 2001:0db8:0:f101::1
sudo route -A inet6 add 2000::/3 gw 2001:0db8:0:f101::1
Add through interface:
sudo ip -6 route add 2001:db8:0:1::0/64 dev eth0
sudo ip -6 route add 2000::/3 dev eth0 metric 1
sudo route -A inet6 add 2000::/3 dev eth0
Remove through gateway:
sudo ip -6 route del 2000::/3 via 2001:0db8:0:f101::1
sudo route -A inet6 del 2000::/3 gw 2001:0db8:0:f101::1
Remove through interface:
sudo ip -6 route del 2001:db8:0:1::0/64 dev eth0
sudo ip -6 route del 2000::/3 dev eth0
sudo route -A inet6 del 2000::/3 dev eth0
References