Ubuntu – Disabling IPv6 on a single interface


I'm slightly weirded out by the fact that Ubuntu won't process ipv4 DHCP unless you explicitly tell it to, but will happily take ipv6 RAs unless you tell it not to. Is there any way to change the default behaviour to be 'do nothing unless I explicitly turn it on'?

(Note to answerers: I'm not looking to globally disable ipv6, or completely turn off autoconf. I'm looking to disable autoconf by default (as in, I don't want ipv6 unless I say so in /etc/network/interfaces, in the same way that I don't just get a v4 address unless I've explicitly turned on dhcp). What's happening is that, for any interface that's up – e.g. has an ipv4 config – a v6 address tends to just turn up on the interface as well, despite the fact that I've not enabled that explicitly. The solutions to date are fine as far as they go, but if I disable v6 or autoconf globally, I can't then re-enable v6 on a per-interface basis with a simple command in /etc/network/interfaces. I'm fairly sure I'm asking for the moon on a stick, mind you.)

Best Answer

Autoconf in part of the basic functionality of IPv6. RA announcements are not DHCP, and the RA server does not assign addresses. RA is much closer to the IPv4 auto-configuration done on the IP range. If privacy is enabled, your IPv6 address will change over time. Your old address will be retired and eventually removed.

You can disable ipv6 autoconf easily with the command:

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

Substitute all with the interface name to disable one interface. Replace autoconf with disable_ipv6 to disable IPv6. Create a file in /etc/sysctl.d with the variable assignments you want to have the setting applied during startup.

To find all the ipv6 related settings run the command:

sudo sysctl -a | grep ipv6 | less
Related Question