Disable IPv6

Updated: 2022-04-02

One of the reason someone would disable IPv6 on his own machine would be the lack of support for it on the remote server. While their DNS advertise AAAA records, their server have IPv6 disabled, making the connections timeout.

I know about the IPv4 address exhaustion, but as long as the system administrators tend to overlook the setup of IPv6 addresses, I will have it disabled on my system.

The OS I chose to do this on is Ubuntu 21, but it will work under a Debian derived distribution and possibly, even on other Linux distributions.

  1. edit the sysctl config file
sudo nano /etc/sysctl.conf
  1. append at the end of the file
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
  1. load the changes to sysctl (without a system reboot)
sudo sysctl -p

Note: the changes will remain after a reboot.

Resources: