How to Permanently Disable IPv6 in Ubuntu Linux

While IPv6 is the future of internet networking, it can occasionally cause severe routing conflicts and DNS resolution delays on older enterprise networks or specific VPN setups. If your Ubuntu server is struggling to resolve apt repositories or failing to connect to local network shares, disabling IPv6 to force the system to rely purely on IPv4 is a common troubleshooting step.

How to Disable IPv6 via Sysctl

To disable IPv6 permanently across all network interfaces, we need to add a few rules to the kernel configuration file.

  1. Open your terminal or SSH into your server.
  2. Open the sysctl configuration file using a text editor with root privileges:
    sudo nano /etc/sysctl.conf
  3. Use the down arrow key to scroll to the very bottom of the file.
  4. Paste the following three lines of text:

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

  5. Press Ctrl + O then Enter to save the file, and Ctrl + X to exit the editor.

Apply and Verify the Changes

You do not need to reboot your server to apply these new kernel parameters.

  1. Run the following command to reload the configuration file immediately:
    sudo sysctl -p
  2. To verify that IPv6 is actually disabled, run:
    ip a

Look at the output for your primary network interface (usually named eth0 or enp3s0). You will see your standard IPv4 address (listed as inet), but the inet6 address line will be completely gone, confirming that IPv6 networking is dead.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.