How can I disable IPv6 on an Ubuntu 13 VM?

October 15, 2013 9.4k views
I added `blacklist ipv6` to /etc/modprobe.d/blacklist.conf and `GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 console=ttyS0"` to /etc/default/grub and rebooted but I'm still seeing IPv6 interfaces. Docker has an issue where if it sees ipv6 interfaces it won't bind to any ipv4 ones. Is there any way I can disable ipv6 on digital ocean?
8 Answers
For the record, I also tried the following and it didn't work:

echo '1' > /proc/sys/net/ipv6/conf/lo/disable_ipv6
echo '1' > /proc/sys/net/ipv6/conf/lo/disable_ipv6
echo '1' > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo '1' > /proc/sys/net/ipv6/conf/default/disable_ipv6
/etc/init.d/networking restart

I'm using the #350076 Ubuntu 13.04 x64 image on NYC2.
This is probably easier to read than the original steps I described:

$ echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist.conf
$ echo 'GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 console=ttyS0"' >> /etc/default/grub
$ update-grub
$ reboot
Have you tried deleting the IPv6 interface from /etc/network/interfaces via sudo vi /etc/network/interfaces; followed by i making the edits; finally saving your changes by typing Esc; :; w; q; Enter?

Then, restarting networking via /etc/init.d/networking restart.

P.S. I realize you prob. know how to use vi; I added all the excruciating detail in the event a n00b stumbles across this thread in the future.
I started a new VM and I can see the IPv6 interfaces:

# ifconfig | grep inet
inet addr: Bcast: Mask:
inet6 addr: fe80::e01:9ff:feae:8301/64 Scope:Link
inet addr: Mask:
inet6 addr: ::1/128 Scope:Host

But /etc/network/interfaces isn't showing any parameters that could be removed and disable IPv6:

# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
Try running the following commands:

echo net.ipv6.conf.lo.disable_ipv6 = 1 | sudo tee -a /etc/sysctl.conf

and then rebooting your droplet.

ifconfig | grep inet
inet addr:xx.xx.xx.xx Bcast: Mask:
inet6 addr: fexx::xxx:xxxx:xxxx:xxx/64 Scope:Link
inet addr: Mask:
Sigh, why have I got that name displayed?
Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!