11

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.)

ijw
  • 249
  • 1
  • 2
  • 10

3 Answers3

12

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 169.254.0.0/16 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
Eric Carvalho
  • 54,385
BillThor
  • 4,698
6

To check if IPv6 is enabled or disabled

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means it’s enabled and 1 is disabled.

To disable IPv6

$ su -
# nano /etc/sysctl.conf

and add these lines to sysctl.conf file

#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Save sysctl.conf file with new config, then reboot your system

# reboot

Check your system again

$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Now you should see “1″ means IPv6 has been disabled on your system.

From http://namhuy.net/1419/disable-ipv6-ubuntu-linux-mint.html

4

Similar to, but different from, one of the other answers, I tried this with a great deal of joy:

Add a sysctl file in /etc/sysctl.d to disable ipv6 - not universally, though, just as an interface default state:

net.ipv6.conf.default.disable_ipv6=1

Then, in the interfaces file and for only the interfaces you wish to have ipv6 on, add:

iface eth0 inet dhcp # .. or whatever
up sysctl -w net.ipv6.conf.$IFACE.disable_ipv6=0

... thus, interfaces don't get IPv6 addresses when they come up (as currently) but can be persuaded to have them in specific cases. You could no doubt disable RAs before enabling ipv6 if that's what you wanted, too.

NB: I suspect you'll run into issues with VLAN named interfaces (e.g. eth0.100) and will have to spell that out in the 'up' command as 'eth0/100' rather than $IFACE, which will have the wrong format - I haven't tested, but that seems to be how sysctl views the world.

ijw
  • 249
  • 1
  • 2
  • 10