How to add an IPv6 network route in Linux?

Here we show how to add an IPv6 network route under Linux. An example explains all the required inputs.

To add an IPv6 network route, you can use the ip -6 route add command along with the appropriate parameters.

Here is an example of the command:

ip -6 route add <destination network>/<prefix length> via <gateway> dev <interface>

Destination network: The destination IPv6 network address you want to add a route to.

Prefix length: The prefix length of the destination network.

Gateway: The IPv6 address of the gateway through which you want to route traffic to the destination network.

Interface: The network interface through which the traffic should be routed.

Note that you must have sufficient privileges (e.g., as root or with sudo) to change network configurations.

Here is a fictitious example to illustrate the use of the command:

ip -6 route add 2001:db8:abcd:1234::/64 via 2001:db8:abcd:5678::1 dev eth0

This command adds a route for the IPv6 network "2001:db8:abcd:1234::/64". Traffic is routed through the gateway "2001:db8:abcd:5678::1" and the network interface "eth0".