accept_ra setting within the /etc/sysctl.conf file or dedicated configuration files in /etc/sysctl.d/. These changes ensure that your network interfaces automatically obtain IPv6 addresses and routing information from local routers without manual intervention, persisting across reboots.
Understanding Router Advertisements
Router Advertisement (RA) messages are part of the ICMPv6 protocol suite. They are broadcast by routers on a local network segment to announce their presence and provide essential configuration parameters to hosts. These parameters typically include the default gateway, DNS server addresses, and the prefix for stateless address autoconfiguration (SLAAC). By default, modern Linux distributions, including Ubuntu 22.04, may disable the acceptance of these advertisements for security reasons, particularly if the system is configured as a potential router itself.
If your machine is not acting as a router but rather as an end-host, disabling RA acceptance can lead to connectivity issues where the device fails to acquire an IPv6 address or route. The kernel parameter responsible for this behavior is accept_ra. When set to 0, the kernel ignores RA messages. Setting it to 1 allows the host to process these messages and configure its network interface accordingly.
Checking Current Configuration
Before making any changes, it is prudent to verify the current state of the accept_ra parameter for your specific network interfaces. You can check the runtime value using the sysctl command. For example, to check the setting for the primary Ethernet interface, often named eth0 or enp0s3, you would run:
sysctl net.ipv6.conf.eth0.accept_ra
This command returns either 0 or 1. If it returns 0, your system is currently ignoring Router Advertisements. Note that some systems may have different settings per interface, so you should also check the global default setting:
sysctl net.ipv6.conf.default.accept_ra
If you are experiencing issues with IPv6 connectivity, such as the repeating IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready message repeating every minute, ensuring that RAs are accepted is a critical troubleshooting step. Additionally, if you are running a virtual machine, refer to guides on Ubuntu 22.04 VM internet connection issues to rule out hypervisor-level networking misconfigurations.
Modifying Sysctl Configuration
To make the change permanent, you need to edit the sysctl configuration files. While editing the main /etc/sysctl.conf file is possible, it is often cleaner to create a dedicated file in the /etc/sysctl.d/ directory. This prevents your custom settings from being overwritten during system updates or package installations that might touch the main configuration file.
- Create a new configuration file: Use a text editor like
nanoorvimto create a file named99-ipv6-ra.confin the/etc/sysctl.d/directory. This naming convention ensures it is processed last among the drop-in files.
sudo nano /etc/sysctl.d/99-ipv6-ra.conf
- Add the necessary parameters: Inside the new file, add the following lines. The first line enables RA acceptance globally for all interfaces. The second line specifically targets your primary network interface (replace
eth0with your actual interface name if different).
# Enable IPv6 Router Advertisement acceptance
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.default.accept_ra = 1
net.ipv6.conf.eth0.accept_ra = 1
Using all and default ensures that both existing and future interfaces inherit this behavior. Specifying the interface explicitly guarantees that even if defaults change, your active connection remains configured correctly. Be cautious when setting accept_ra to 1 on systems that also function as routers, as this could expose them to routing loops or unauthorized route injections.
- Save and exit: Save the file and close the editor.
Applying the Changes
After saving the configuration file, you must apply the changes to the running kernel. You can do this by reloading the sysctl configuration using the following command:
sudo sysctl --system
This command reads all configuration files in /etc/sysctl.d/ and applies them immediately. You can verify that the changes took effect by running the sysctl commands mentioned earlier again. The output should now show = 1 for the relevant interfaces.
Once the parameters are applied, your network interface will begin processing Router Advertisement messages. You may need to renew your DHCP lease or restart the networking service to trigger the immediate acquisition of IPv6 settings. On Ubuntu 22.04, which uses Netplan for network configuration, you can restart the network manager:
sudo systemctl restart NetworkManager
Alternatively, if you are using a static IP configuration managed directly by the OS rather than NetworkManager, you might need to bring the interface down and up again. Check your IP assignment with ip -6 addr show to confirm that an IPv6 address has been assigned via SLAAC.
Troubleshooting and Verification
If you still do not receive an IPv6 address after applying these settings, there are several diagnostic steps you can take. First, ensure that your router is actually sending RA messages. You can use tcpdump to listen for ICMPv6 packets on your interface:
sudo tcpdump -i eth0 icmp6
If you see outgoing RA messages from the router, the issue might be related to firewall rules blocking ICMPv6 traffic. Unlike IPv4, IPv6 relies heavily on ICMP for core functionality, so blocking it can break networking entirely. Also, verify that your network interface is indeed configured to use DHCPv6 or SLAAC. If you are using ifconfig and IPv4 addresses for verification, remember that ifconfig is deprecated and may not display IPv6 details accurately; prefer using the ip command suite.
Finally, ensure that your network switch or upstream router is not filtering multicast traffic, as RAs are sent to the all-nodes multicast address (::1). If you are in a complex network environment, consult your network administrator to confirm that IPv6 is enabled and properly configured at the layer 2 and layer 3 boundaries.
Frequently Asked Questions
Will enabling accept_ra compromise my security?
Enabling accept_ra on a standard end-host generally does not compromise security, as it simply allows the host to learn routes from trusted local routers. However, on systems that also act as routers, accepting RAs can lead to routing loops or man-in-the-middle attacks if untrusted sources send malicious advertisements. It is recommended to keep this disabled on multi-purpose router devices.
How do I revert these changes if they cause issues?
To revert the changes, you can either delete the custom file created in /etc/sysctl.d/ or comment out the lines you added. Afterward, reload the sysctl configuration with sudo sysctl --system or reboot the system. The default behavior of Ubuntu 22.04 will then be restored.
Why is my IPv6 address showing as tentative?
An IPv6 address in the "tentative" state indicates that Duplicate Address Detection (DAD) is currently in progress. This is a normal part of the SLAAC process where the host checks if the address is already in use on the network. Once DAD completes successfully, the status will change to "preferred" or "valid".
Can I enable accept_ra for only one specific interface?
Yes, you can target specific interfaces by specifying the interface name in the sysctl configuration, such as net.ipv6.conf.eth0.accept_ra = 1. This allows you to maintain stricter controls on other interfaces while enabling auto-configuration only on the desired network adapter.
Does this setting affect IPv4 configuration?
No, the accept_ra parameter is specific to IPv6 and ICMPv6 protocols. It has no impact on IPv4 address configuration, which is handled separately through DHCPv4 or static assignments. Your IPv4 connectivity will remain unaffected by changes to this sysctl key.