How to disable autoconfiguration on IPv6 in Linux?
Auto configuration can be disabled temporary for eth1 with:
sudo sysctl -w net.ipv6.conf.eth1.autoconf=0
sudo sysctl -w net.ipv6.conf.eth1.accept_ra=0
or for all interfaces with:
sudo sysctl -w net.ipv6.conf.all.autoconf=0
sudo sysctl -w net.ipv6.conf.all.accept_ra=0
Reenabling works by using 1 instead of 0 in the call.
Disabling it permanently can be done with an entry to /etc/sysctl.conf
.
On Debian Etch (probably on newer too), without setting the accept_ra
, the system will autoconfigure using the Link local adress (fe80..
)
As Gart mentioned below, automatic address configuration and router discovery will be disabled if the host itself is a router and accept_ra
is not 2
, i.e
net.ipv6.conf.<iface|all|default>.forwarding=1
and
net.ipv6.conf.<iface|all|default>.accept_ra=0
or net.ipv6.conf.<iface|all|default>.accept_ra=1
.
where iface
is your interface
net.ipv6.conf.all.accept_ra=0 above should not be done, as RAs are necessary for indication of on-link and off-link for the prefix (as per RFC5942), as well as automated configuration of a number of other parameters, such as MTU, Neighbor Discovery timeouts etc.
If you want to disable autoconfiguration, either set the autoconf sysctl off as above, or switch off the A (autoconfiguration bit) in the Prefix Information Option (PIO) in the RA.
The sysctl
solution did not work for us on Ubuntu 18.04 Bionic.
We solved it by:
Editing /etc/netplan/01-netcfg.yaml
, configure:
network:
...
ethernets:
eth0:
...
dhcp6: no
accept-ra: no
You may need to use your interface name instead of eth0
.
After you save the file execute:
netplan apply
or reboot
If you already have received an IPv6 IP from autoconfiguration and you want to remove it without rebooting, you can execute:
ip -6 addr del 1111:2222:1:0:aaaa:bbbb:cccc:dddd/64 dev eth0
Of course you need to replace the IP and device in this command.