I am going to set a static IPv6 address and a corresponding IPv6 default route with dhcpcd. I have looked through man dhcpcd.conf, but to find nowhere mentioning how to set an IPv6 default route.

My current dhcpcd.conf:

option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier

interface eth0
static ip6_address=2001:xxx::xxx/128

What I want dhcpcd to do is:

ip addr add 2001:xxx::xxx/112 dev eth0
ip -6 route add 2001:xxx::xxxx dev eth0
ip -6 route add default via 2001:xxx::xxxx

However, with my current configuration, dhcpcd does only the first two lines for me but not the third line.

man dhcpcd.conf only tells that an IPv4 default router can be set via something like static routers=

I know it can be done by ip -6 route add manually, using hooks of dhcpcd, or simply put aside dhcpcd. But I rely on dhcpcd to handle DHCPv4. And I think it would less messy if dhcpcd can handle both IPv4 and IPv6 configurations.

My question:

Is there a more direct way where dhcpcd sets the IPv6 default route automatically by specifying some options / commands in dhcpcd.conf?


You cannot use DHCPv4 to give out default IPv6 routes. You cannot even use DHCPv6 to give out default IPv6 routes.

The reason is that IPv6 is different from IPv4 in many respects, and one of them is how routers behave: Every IPv6 router announces itself as gateway to the segment which can use it as gateway. And you can have multiple routers for segment, it's not restricted to a single gateway as in IPv4.

Therefore, this doesn't happen by exchanging DHCP broadcasts and replies, but instead it happens by exchanging router solicitation (RS) and router advertisement (RA) messages between hosts and routers, as defined in the IPv6 Neighbour Discovery Protocol.

So the only way to make your IPv6 hosts configure themselves with the right route is to run radvp (properly configured) in addition to dhcpd on your router/gateway. While you are at it, you can enable RS messages again (delete noipv6rs), because if Linux considers itself a router (forwarding is enabled) it won't (or at least shouldn't) send out RS messages.

And using radvp is actually the "less messy" way - it allows you to add routers to or remove routers from your segment without having to update a central configuration file.

In addition, stateless autoconfiguration (SLAAC) will allow your hosts to generate IPv6 addresses from the routeable prefixes themselves.

  • Wondering how this works when the system is a router with one interface facing the ISP? I get an IPv6 from my ISP but default routes aren't appearing in ip -6 route and I don't know what's responsible for doing that. Not sure if I should be pointing radvd toward the ISP.
    – LawrenceC
    Apr 2 at 12:58
  • @LawrenceC: The router gets a prefix from the ISP, and then passes on this prefix on the internal interfaces. Google "IPv6 prefix delegation". Assuming a home router etc., you usually configure dnsmasq for that.
    – dirkt
    Apr 2 at 13:10

Googling for "dhcp ipv6 defaultroute" led me to this AU Q&A titled: how to set default gateway in dhcpd6.conf. According to this Q&A IPv6:

DHCPv6 does not support options to set routers/gateways.


I'd like to answer my own question:

The answers by dirkt is the direct answer to this question. The answers by slm gives some helpful solutions and further suggestions.

But, neither of them do solve the problem I encounter.

The case I was confronted with is that the network environment is totally out of my control. In fact, I bought a VPS from a VPS provider. What they provide is the preconfigured network. I just wanted to reinstall the VPS and change the OS from Debian to another distro and I have no choice to change any network environment other than reproducing the exact same network configuration after installation.

After searching on the Internet and asking helps other where I find the best workaround to configure a static IPv6 router and address is to use netctl. netctl can use dhcpcd as the backend for negotiating DHCPv4 while also providing simple ways to configure IPv6 statically. Here is my configuration until now:

Description='A basic dhcp ethernet connection'

  • Your actual problem sounds very different from the original question. I probably don't understand the problem description completely, but what prevented you from just using IPv6 static addresses/routes in addition to DHCP? And there's a number of ways to set static IPv6 addresses/routes, depending on the distro.
    – dirkt
    Aug 8 '18 at 7:12
  • Sorry for the lateness. I had strived to make my question clear and avoided to make it specific to my own situation. But it seems that I carelessly omitted some important information so that you got a little confused. The reason for the latter question is: I think it could be less messy to make a network manager to configure them all. Besides, for Arch Linux which I am using, I find no documents describing how to configure static addresses directly.
    – Dummmy
    Nov 29 '18 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.