IPv6 is the next generation of Internet addressing, designed to replace IPv4. While it’s more modern and future-proof, many networks and applications still rely heavily on IPv4. On Ubuntu, IPv6 is enabled by default, but sometimes you may want to disable IPv6.
Why? Because in some cases, IPv6 can cause:
- Network connectivity issues
- DNS resolution delays
- Conflicts with older applications
- Security concerns if not configured properly
If you’re running a server or troubleshooting network problems, disabling IPv6 can be a practical step. In this guide, I’ll explain different methods to disable IPv6 on Ubuntu so you can pick the one that suits your needs.
Method 1: Disable IPv6 Temporarily (Until Reboot)
If you just want to test things or temporarily turn off IPv6, you can do it with these commands:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
This will immediately disable IPv6 on your system.
Check if IPv6 is disabled:
ip a
You should no longer see IPv6 addresses starting with fe80::
or similar.
⚠️ Note: This method only lasts until reboot. Once you restart your machine, IPv6 will be re-enabled.
Method 2: Disable IPv6 Permanently via sysctl.conf
To make the changes permanent, edit the sysctl.conf
file.
- Open the file in a text editor:
sudo nano /etc/sysctl.conf
- Add these lines at the bottom:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
- Save and exit (Ctrl + O, Enter, Ctrl + X in nano).
- Apply the changes:
sudo sysctl -p
Now IPv6 will remain disabled even after reboot.
Method 3: Disable IPv6 via GRUB Boot Parameters
This method ensures IPv6 is disabled right from system startup.
- Edit the GRUB config file:
sudo nano /etc/default/grub
- Look for this line:
GRUB_CMDLINE_LINUX=""
Modify it to:GRUB_CMDLINE_LINUX="ipv6.disable=1"
- Update GRUB:
sudo update-grub
- Reboot your system:
sudo reboot
IPv6 will now be completely disabled on boot.
Method 4: Disable IPv6 for Specific Network Interfaces (Netplan)
If you only want to disable IPv6 on a particular network interface, you can do it through Netplan.
- Open your Netplan config file (location may vary):
sudo nano /etc/netplan/01-netcfg.yaml
- Add these lines under your interface settings:
network: version: 2 ethernets: enp0s3: dhcp4: true ipv6: false
- Apply the changes:
sudo netplan apply
This disables IPv6 only on the chosen interface (e.g., enp0s3
).
How to Verify IPv6 is Disabled
After applying any of the above methods, run:
ip a
If IPv6 is disabled, you won’t see any IPv6 addresses.
You can also check with:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
If the output is 1
, IPv6 is disabled.
When Should You Disable IPv6?
Disabling IPv6 is useful if:
- Your ISP or network doesn’t support IPv6 properly.
- You face connectivity or DNS issues with dual-stack networks.
- You want to reduce unnecessary security risks in a server environment.
But if your network is IPv6-ready, it’s usually better to leave it enabled for future-proofing.
Conclusion
Disabling IPv6 on Ubuntu is simple and can solve a lot of network headaches, especially for servers and older applications.
- For quick fixes, use the temporary method.
- For permanent solutions, go with sysctl or GRUB.
- For fine-tuned control, disable IPv6 per interface with Netplan.
With these steps, you should have full control over IPv6 on your Ubuntu system.