0

I have an Ubuntu 22.04.2 virtual machine. My intention is to only do dhcpv6 on an interface and ignore Router Advertisements so I don't get SLAAC v6 addresses and their routes. Currently, I successfully get link-local, SLAAC and dhcpv6 addresses (and v4) on my interface. If I put 'net.ipv6.conf.eth0.accept_ra=0' in /etc/sysctl.conf (and do sysctl -p) I still get all the addresses on my interface. Also doing 'all.accept_ra=0' and 'default.accept_ra=0' does not have an effect. I down/up the interface after parameter changes. Is there anything additional I have to do? sysctl -w and those parameters doesn't work for me either.

If I put 'accept-ra: false' in my netplan yaml file (with accept_ra=1 in sysctl) I don't get SLAAC or dhcpv6 addresses on my interface. So, this seems to ignore the RA like I want but dhcpv6 stops working. I only have a v6 link-local address. Looking at tcpdump I don't see any SOLICIT or any other dhcp6 or icmp6 messages being sent. I see the RA coming in so it's successfully ignored.

If someone could let me know why sysctl is ineffective and why the netplan yaml change also affects dhcpv6 I'd appreciate it.

Other notes: 2 interface system (eth0, eth1). I'm working on eth0. All forwarding is disabled (e.g. net.ipv4.conf.eth0.forwarding = 0) eth1 in yaml file has 'accept-ra: false'

0

1 Answer 1

0

The sysctl is ineffective because it's not the kernel that is processing RAs. With netplan, that's handled in userspace by systemd-networkd, just like DHCPv6.

To disable address assignment, you'll need the Netplan equivalent of the systemd.network(5) option:

[IPv6AcceptRA]
UseAutonomousPrefix=false

By design, RA is what triggers DHCPv6, and is also what provides the default route to the system (which DHCPv6 doesn't do). You can make systemd-networkd initiate DHCPv6 without RA by using the Netplan equivalent of (again in .network file):

[DHCPv6]
WithoutRA=solicit

(No, I don't know what the Netplan equivalent of those options is, or whether it even has any. Frankly, it might be easier to just directly configure systemd-networkd without Netplan – by copying the .network file that Netplan has generated and expanding it as needed.)

4
  • Thanks! I updated the .network file directly and it behaves as I expect. I still get a default route so I guess I don't completely ignore the RA.
    – Bagels1b
    Oct 25, 2023 at 20:22
  • Yeah, [Network] IPv6AcceptRA=no is how would you completely ignore the RA (it's 1:1 what Netplan's "accept-ra:" maps to). The various [IPv6AcceptRA] xx= settings just tell networkd to ignore specific parts of the RA. Oct 25, 2023 at 20:36
  • What is the purpose of the sysctl accept_ra?
    – Bagels1b
    Oct 26, 2023 at 13:41
  • @Bagels1b: It's for the in-kernel RA handler. Traditionally Linux has done IPv6 autoconfig (though not DHCPv6) without any userspace software at all, but its capabilities are limited. (Networkd actually sets it to 0 even if IPv6AcceptRA=true.) Oct 26, 2023 at 13:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .