How to Disable IPv6 on Ubuntu
Here's how to disable IPv6 on Ubuntu to help you resolve compatibility issues, network configurations, or specific use cases that require IPv6 deactivation.
How to permanently disable IPv6 on Ubuntu
Note : By default, IPv6 is enabled and used in parallel with IPv4.
To disable IPv6 on your Ubuntu system, open a terminal by pressing Ctrl + Alt + T and use the nano editor to open the sysctl configuration file:
sudo nano /etc/sysctl.conf Now, add the following code to the configuration file to disable IPv6 services:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 In the code above:
- The first line disables IPv6 for all network interfaces on the system
- The second line specifically targets the default interface and disables it
- The third line disables IPv6 on the loopback interface, meaning the machine will not use IPV6 for internal communication.
After adding the given code, press Ctrl + O to save changes and exit the editor. Now, apply changes to the system with:
sudo sysctl -p
Restart your network services with:
sudo systemctl restart systemd-networkd Verify the status of disabled IPv6 services by running:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
If the output shows a status of "1" , it means IPv6 has been successfully disabled on Ubuntu.
How to temporarily disable IPv6 on Ubuntu
To temporarily disable IPv6 on Ubuntu, run the following systemctl command with the -w option :
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
Now, restart network services with:
sudo systemctl restart systemd-networkd Therefore, all dependencies will be configured to temporarily disable IPv6 services.
Ubuntu makes controlling IPv6 settings relatively simple, ensuring that you can configure your system's networking behavior to your specific needs. Remember to use this knowledge carefully as IPv6 will continue to play an important role in the global Internet infrastructure.