How to disable Ipv6 on Ubuntu, Linux Mint, Debian
Ipv6 is the next version of the addressing scheme Ipv4 that is currently being used to assign numerical address to domain names like google.com over the internet.
Ipv6 allows for more addresses than what Ipv4 supports. However it is not yet widely supported and its adoption is still in progress.
Does your system support ipv6 ?
Check out http://testmyipv6.com/ to see if you network supports Ipv6.
For Ipv6 to work you need -
1. An OS that supports IPv6. Ubuntu and most modern Linuxes do that.
2. Your network hardware (router/modem) must support Ipv6. Many of the good brands do.
3. Your ISP must also support IPv6. This is something that is not present everywhere !
Check the output of ifconfig command to see the "inet6 addr" line.
$ ifconfig eth0 Link encap:Ethernet HWaddr 00:1c:c0:f8:79:ee inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21c:c0ff:fef8:79ee/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 .....
Problems if ipv6 not supported
So if ipv6 is not supported on your network infrastructure, it might be useful to disable it all together. It can cause issues like delayed domain lookups, un-necessary attempts to connect to ipv6 addresses causing delay in network connection etc.
I did come across some problems like that. The apt-get command occasionally tries to connect to ipv6 addresses and fails and then retries an ipv4 address. Take a look at this output
$ sudo apt-get update Ign http://archive.canonical.com trusty InRelease Ign http://archive.canonical.com raring InRelease Err http://archive.canonical.com trusty Release.gpg Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::1b). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1b 80] Err http://archive.canonical.com raring Release.gpg Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::1b). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1b 80] .....
Errors like those have been more frequent in the recent Ubuntu versions, probably because they try to use Ipv6 more than before.
I noticed similar issues happen in other applications like Hexchat and also Google Chrome which would sometimes take longer than usual to lookup a domain name.
So the best solution is to disable Ipv6 entirely to get rid of those things. It takes only a small configuration and can help you solve many network issues on your system. Users have even reported an increase in internet speed.
Method 1 - Disable from sysctl
The first method to disable Ipv6 is to edit kernel level parameters via sysctl interface.
The kernel parameters that enable ipv6 are as follows
$ sysctl net.ipv6.conf.all.disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 0 $ sysctl net.ipv6.conf.default.disable_ipv6 net.ipv6.conf.default.disable_ipv6 = 0 $ sysctl net.ipv6.conf.lo.disable_ipv6 net.ipv6.conf.lo.disable_ipv6 = 0
Note that the variables control "disabling" of ipv6. So setting them to 1 would disable ipv6
Edit the file - /etc/sysctl.conf
$ sudo gedit /etc/sysctl.conf
And fill in the following lines at the end of that file
# IPv6 disabled net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Save the file and close it. Restart sysctl with
$ sudo sysctl -p
Check the output of ifconfig again and there should be no ipv6 address
$ ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:5f:28:8b inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1346 errors:0 dropped:0 overruns:0 frame:0 TX packets:965 errors:0 dropped:0 overruns:0 carrier:0 .....
If it does not work, then try rebooting the system and check ifconfig again.
Method 2 : Disable ipv6 from GRUB
Ipv6 can also be disabled by editing the grub configuration file
$ sudo gedit /etc/default/grub
Look for the line containing "GRUB_CMDLINE_LINUX" and edit it as follows
The same can also be added to the value of the variable named "GRUB_CMDLINE_LINUX_DEFAULT" and either would work. Save the file, close it and regenerate the grub configuration
$ sudo update-grub2
Reboot. Now ipv6 should be disabled.