1. Introduction

Routing is vital when it comes to proper network setup. Even with newer protocols like IPv6, we might need to add routing entries manually. Thus, knowing how to do this can be invaluable for any network administrator, especially when DHCPv6 is unavailable or is out of order.

In this tutorial, we explore the IPv6 routing table and how to set up a default IPv6 route. First, we briefly discuss the IPv6 routing table. After that, we understand default IPv6 routes and gateways. Finally, we show how to add a default route.

Although there are many ways to do so, we use the ubiquitous ip tool from the iproute2 package to control our network configuration. To be clear, we avoid using the route utility because the net-tools package is deprecated.

We tested the code in this tutorial on Debian 12 (Bookworm) with GNU Bash 5.2.15. It should work in most POSIX-compliant environments unless otherwise specified.

2. IPv6 Routing Table

Network routing tables are internal kernel structures used to direct packets to their next station on the way to their intended target. The table itself can contain different data fields, but there is usually a bare minimum:

  • inbound interface
  • destination
  • gateway
  • outbound interface

By default, the IPv6 behaves similarly to but not exactly like IPv4 when automating the creation of routing table entries. In particular, IPv6 creates three types of entries:

  • connected: automatically configured direct link (loopback interface, global unicast address, or link-local address)
  • static: manually configured beyond connected
  • OSPF3: discovered by the OSPFv3 protocol

Of these, we normally see the first two most, and both of them have a Metric of 1. However, the administrative distance of connected routes is a non-configurable 0, while that for static routes can be between 1255. Still, administrative distances only matter in a mixed setup with OSPF and static routes.

Let’s see an example Linux routing table:

$ ip -6 route show
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev eth6 proto kernel metric 256 pref medium

In this case, we use ip with the -6 IPv6 switch to show each route. In this fairly simple table, there are two entries:

  • ::1, interface lo: loopback address route
  • fe80::/64, interface eth6: link-local network

Since the [lo]opback interface isn’t our focus, we’ll use dev to work only with eth6.

In essence, we don’t have a default gateway for any interface since this machine doesn’t connect to external networks via IPv6. Let’s change that.

3. Default IPv6 Route and Gateway

Like with IPv4, we can configure an IPv6 address that receives all traffic that’s not directed to a connected target. Such a target is called a default gateway, and the configuration: default route.

Let’s configure a default gateway for eth6 via ip:

$ ip -6 route add default via fe80::666 dev eth6

Now, we can check our updated routing table:

$ ip -6 route show dev eth0
fe80::/64 proto kernel metric 256 pref medium
default via fe80::666 metric 1024 pref medium

Now, all unknown traffic that doesn’t match another rule on the interface (eth6) should go through this default gateway (fe80::666).

Although we can a regular route to any target, default gateway addresses need a connected route that can reach them:

$ ip -6 route add default via 666:: dev eth0
RTNETLINK answers: No route to host

As expected, since we only have the fe80 link-local address, we get the No route to host RTNETLINK error.

Naturally, we can use the general syntax to add a default IPv6 route for any network we have a direct connection to:

$ ip -6 route add default via <IPV6_ADDRESS> dev <INTERFACE>

This way, we can ensure a default gateway exists for each INTERFACE.

4. Summary

In this article, we talked about default IPv6 routes and gateways.

In conclusion, just like IPv4, IPv6 can require the manual setup of default routes, so knowing how to do that may become very important during network administration.

Comments are closed on this article!