How can I disable IPv6 on an Ubuntu 13 VM?

October 15, 2013 7.9k 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:192.241.137.243 Bcast:192.241.137.255 Mask:255.255.255.0
inet6 addr: fe80::e01:9ff:feae:8301/64 Scope:Link
inet addr:127.0.0.1 Mask:255.0.0.0
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
address 192.241.137.243
netmask 255.255.255.0
gateway 192.241.137.1
dns-nameservers 8.8.4.4
Try running the following commands:

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


and then rebooting your droplet.
Nope:

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