30 May 2013

Disabling IPv6 on Ubuntu Server 12.04

A few months ago, I was sad to learn that Fail2Ban does not protect against IPv6 traffic. If your web traffic only operates on IPv4, then you have nothing to worry about. That is, unless you have the IPv6 stack enabled and don't need it.

Luckily, I came across a great little post from webupd8.org that I've summarized below (should the post ever be removed). In either case, this post is for anyone wishing to disable IPv6 on their Ubuntu server.

1. Check if the IPv6 stack is enabled. The stack is enabled if the return is 0.

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

2. Elevate to root and open your /etc/sysctl.conf file in nano.

$ sudo nano /etc/sysctl.conf

3. Paste the following at the end of the sysctl.conf:

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

4. Reboot and perform step 1. If you find the return to still be 0, head over to the webupd8 link above to see the other methods they have listed.