In this short article, I will explain how to disable IPv6 in the Debian 10 networking stack. Why does one want to do this? Most likely when you have connection problems and cannot reach servers on the internet from your Debian system by IPv6 while it works by IPv4. Disabling IPv6 should always be the last resort. If you can't fix it in your network e.g. because your internet access provider blocks IPv6, then the only other option is to disable it on your server, and that's what I'll describe below.
Disable IPv6 Networking on Debian 10
I'll run the commands below as root user. If you are not logged in as root, then run either "su -" first or prepend the command "sudo" to all commands. One way to disable IPv6 networking os to edit the sysctl.conf file. Open /etc/sysctl.conf file with an an editor:
And add the following line at the end of the file:
net.ipv6.conf.all.disable_ipv6 = 1
This will disable IPv6 on all network adapters. if you want to disable it just for one adapter, e.g. the external network device ens33, then use this instead:
net.ipv6.conf.ens33.disable_ipv6 = 1
Save and close the file in nano. Then apply the changes with the command:
An alternative way to edit sysctl.conf with an editor is to run these two commands:
echo 'net.ipv6.conf.all.disable_ipv6 = 1' > /etc/sysctl.d/90-disable-ipv6.conf sysctl -p -f /etc/sysctl.d/90-disable-ipv6.conf
The first one created a file /etc/sysctl.d/90-disable-ipv6.conf which contains the configuration setting to disable IPv6 and the second one applies the change.