How To Disable IPV6 on Linux/Ubuntu?

IPV6 is the most recent version of internet protocol (IP) designed to eliminate the long-anticipated address exhaustion problem of IPV4. IPv6 offers a much larger addressing scheme than IPv4, which is one of the many reasons why it was developed. However, I have seen rare instances in which IPv6 has caused network problems.Since some hardware doesn’t take advantage of IPv6 (and most admins are still working with IPv4), a temporary and easy solution is to disable IPv6; the protocol can be re-enabled when the time comes when the issue has been permanently resolved. Sometimes in Linux (Ubuntu) update issues occurs. Like :0% [Connecting to archive.ubuntu.com (2001:67c:1360:8001::17)] After disabling IPv6 this issue can be fixed. I’ll show you how to disable IPv6 on a Linux machine. ( Note: I recommend disabling IPv6 only when you’ve exhausted all other options. Also, you should consider this a temporary fix.)
Command line
I’ll show you how to disable IPv6 on Red Hat- and Debian-based distributions.Here’s how to disable the protocol on a Red Hat-based system: In order to disable IPV6 on Linux/Ubuntu, please follow the steps below:

Open Terminal (Ctrl+Alt+T) and copy and paste the following commands :

 sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

To re-enable IPv6, issue the following commands:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0

Here’s how to disable the protocol on a Debian-based machine.

  1. Open Terminal (Ctrl+Alt+T)
  2. Issue the command
    sudo nano /etc/sysctl.conf
  3. Add the following at the bottom of the file:
  4. net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1 
    net.ipv6.conf.lo.disable_ipv6 = 1
  5. Save and close the file.
  6. Reboot the machine.

To re-enable IPv6, remove the above lines from /etc/sysctl.conf and reboot the machine.