Stateless Address Autoconfiguration (SLAAC) allows IPv6 devices to generate their own addresses without a DHCP server, but it relies on Router Advertisements (RAs). On Linux systems, the kernel parameter accept_ra controls whether an interface accepts these advertisements. Setting this value to 1 enables automatic configuration, while 0 disables it, forcing static or manual address assignment.
The Role of SLAAC in IPv6 Networking
In IPv4 networks, devices typically rely on Dynamic Host Configuration Protocol (DHCP) to obtain IP addresses, subnet masks, and gateway information. IPv6 simplifies this process through Stateless Address Autoconfiguration. The core idea is that routers periodically broadcast Router Advertisement messages onto the local network segment. These messages contain the network prefix and other essential routing information. When a device receives an RA, it combines the advertised prefix with its own Interface Identifier (usually derived from its MAC address using EUI-64 or randomization techniques) to form a complete global unicast address. This process is "stateless" because the router does not keep track of which devices have claimed which addresses. It simply provides the blueprint for addressing. This mechanism reduces administrative overhead significantly. Network administrators do not need to manage a pool of available IPs or configure lease times. However, it also means that if a router changes its prefix, all devices on the network must reconfigure their addresses immediately. This can lead to temporary connectivity issues during prefix transitions. For more details on how different addressing methods impact performance, you might want to read about Static IPv6 Addresses vs. Dynamic: Latency Comparison. Understanding the trade-offs between dynamic auto-configuration and static setups helps in choosing the right approach for specific network environments.Understanding the accept_ra Kernel Parameter
The behavior of SLAAC on Linux is governed by sysctl parameters located in/proc/sys/net/ipv6/conf// . The specific key you are looking for is accept_ra, not accept_ra1. This parameter determines whether the kernel will process incoming Router Advertisement packets.
The valid values for accept_ra are integers:
- 0: The interface ignores all Router Advertisements. It will not acquire an IPv6 address via SLAAC. This is often used for interfaces that should only use manually configured static addresses.
- 1: The interface accepts Router Advertisements. If the RA contains a default route, the kernel may also update the default gateway. This is the standard behavior for most consumer-grade routers and servers.
- 2: The interface accepts RAs but does not install a default route from them. This is useful when you want the address but prefer to manage routing manually.
accept_ra and other related parameters like accept_redirects or autoconf. While autoconf controls whether the address itself is generated, accept_ra controls whether the device listens to the network for instructions to do so. Disabling accept_ra effectively breaks SLAAC for that interface, even if autoconf is enabled.
Why the Confusion Exists
Some documentation or older scripts might reference incorrect variable names due to typos or confusion with other system settings. In some contexts, people might mistakenly append numbers to parameter names thinking they represent versions or instances. However, the Linux kernel networking stack strictly usesaccept_ra. Using an invalid name like accept_ra1 will result in a "No such file or directory" error when attempting to modify it via sysctl or writing to /proc.
If you encounter errors related to IPv6 connectivity after changing settings, check your current configuration using sysctl net.ipv6.conf.all.accept_ra and sysctl net.ipv6.conf.default.accept_ra. These show the global and default behaviors before applying per-interface overrides.
Configuring Interfaces for Non-Router Devices
Most end-user devices, such as laptops, smartphones, and IoT sensors, act as non-router devices. They do not forward traffic between subnets; they only send and receive data for themselves. Therefore, they generally requireaccept_ra set to 1 to function correctly on modern IPv6 networks.
However, there are scenarios where you might want to disable this. For example, if you are running a security-sensitive server that requires strict control over its network identity, you might disable SLAAC and assign a static IPv6 address. This prevents rogue routers on the local network from advertising malicious default gateways or prefixes.
To temporarily disable SLAAC on an interface named eth0, you would execute:
sysctl -w net.ipv6.conf.eth0.accept_ra=0
To make this change persistent across reboots, add the following line to /etc/sysctl.conf or a file in /etc/sysctl.d/:
net.ipv6.conf.eth0.accept_ra = 0
After making changes, apply them with sysctl -p. Note that disabling accept_ra does not remove existing addresses. You must manually flush the interface's IPv6 addresses using ip -6 addr flush dev eth0 if you want the interface to lose its auto-configured address immediately.
For users interested in bypassing VPN restrictions that might interfere with IPv6 routing, see Bypass VPN IPv6: A Comprehensive Guide for Tech Support. Properly configuring accept_ra ensures that your native IPv6 traffic flows correctly outside of tunnelled connections.
Troubleshooting Common Issues
If your device fails to obtain an IPv6 address, the first step is to verify that the router is actually sending RAs. You can use tools liketcpdump or tshark to capture ICMPv6 Type 133 packets. If no RAs are visible, the issue lies with the network infrastructure, not the host configuration.
If RAs are present but the address is not assigned, check the accept_ra setting. Ensure that neither accept_ra nor ignore_dad is inadvertently blocking the process. Additionally, verify that the interface is not in a state that prevents packet reception, such as being administratively down.
Sometimes, multiple interfaces can cause conflicts. If a device has both Wi-Fi and Ethernet connected, and both receive RAs, the kernel must decide which default route to use. This is managed by the metric values associated with each route. Lower metrics take precedence. Misconfigured metrics can lead to asymmetric routing or internet access failures despite having valid IPv6 addresses.
For further insights into unexpected address appearances, review Encountering Strange Extra IPv6 Addresses on Your Local Network. Understanding privacy extensions and temporary addresses helps explain why a single interface might appear to have multiple global IPv6 addresses simultaneously.
Frequently Asked Questions
What happens if I set accept_ra to 0?
Settingaccept_ra to 0 stops the interface from processing Router Advertisements. Consequently, the device will not automatically generate an IPv6 address via SLAAC. It will retain any statically configured addresses but will not learn new network prefixes or default routes from the router.
How do I check if my router is sending RAs?
You can use command-line tools likeping6 to link-local multicast addresses or packet sniffers like tcpdump. Running tcpdump -i any icmp6 will display ICMPv6 traffic. Look for Type 133 messages, which indicate Router Advertisements originating from your gateway.
Can I use SLAAC with DHCPv6?
Yes, but it depends on the flags in the Router Advertisement. The RA includes an "Other Configuration" flag. If this flag is set, devices know to use SLAAC for the address but should query a DHCPv6 server for additional information like DNS servers. This hybrid approach is common in enterprise environments.Why does my interface have multiple IPv6 addresses?
Modern Linux kernels use Privacy Extensions by default. This generates temporary, randomized IPv6 addresses for outbound connections to enhance privacy. Alongside the stable EUI-64 address, you will see temporary addresses that expire after a certain period. Both are valid and part of the SLAAC process.Is it safe to disable accept_ra on a home router?
Disablingaccept_ra on the WAN interface of a home router is generally safe if you are using static IPv6 configuration provided by your ISP. However, on LAN interfaces, disabling it prevents connected devices from getting addresses automatically. Ensure all downstream devices are configured statically if you disable SLAAC on the router's LAN ports.