21

How can I permanently disable autoconfiguration of IPv6 in Linux? When I try to manually delete an address from an interface with:

ip -6 addr del 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64 dev eth1

It will reappear a few seconds later, I want it to be gone permanently, but without disabling IPv6 all together.

20

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

  • 3
    Also, automatic address configuration and router discovery will be disabled if the host itself is a router, i.e net.ipv6.conf.all.forwarding=1 is set. – Gart Sep 18 '11 at 13:25
4

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.

3
sudo sysctl -w net.ipv6.conf.all.autoconf=0

This didn't work for me on Debian Wheezy. After examining /etc/sysctl.conf I needed to use

sudo sysctl -w net.ipv6.conf.default.autoconf=0
3

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.

  • this has just made my day been scratching my head on this for a few months :D – anthonysomerset Sep 19 '18 at 12:48
  • 2
    I usually just scratch Google till I find it. – Jeroen Vermeulen - MageHost Sep 19 '18 at 13:09
  • 1
    This worked when I tried it, but the problem is turning accept-ra off is quite dangerous, as mentioned by Mark S - it appears to work but later you may find you're missing packets because they hit a fragmentation point or a failover router is used. Also it breaks pings. The reason I was trying to do this was to reliably match my SPF record in outgoing mail but then I realised I should have been using a netmask in the record instead because in IPv6 a range of addresses effectively belongs to a machine, not a single address. – Phil McKerracher Oct 26 '18 at 4:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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