How To Disable IPv6 on Debian 10 / 9 & Ubuntu 18.04 / 16.04

5

This post helps you in disabling ipv6 on Debian 10 / 9 & Ubuntu 18.04 / 16.04. IPv6 can be disabled by modifying sysctl.conf or by creating a .conf file in the /etc/sysctl.d directory. You can also disable IPv6 for a particular network adapter.

The steps mentioned here should work on previous versions of Debian such as Debian 9 and 8, also, Ubuntu versions such as Ubuntu 19.10, 19.04, and 18.10.

Disable IPv6 on Debian 10 & Ubuntu 18.04

Before disabling the IPv6, let us see the available network cards on the system. Use the ifconfig command.

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 2406:7400:bf:7cdd:a00:27ff:fe68:1c64  prefixlen 64  scopeid 0x0
        inet6 fe80::a00:27ff:fe68:1c64  prefixlen 64  scopeid 0x20
        inet6 2406:7400:bf:7cdd:882d:c9c6:df13:890  prefixlen 64  scopeid 0x0
        ether 08:00:27:68:1c:64  txqueuelen 1000  (Ethernet)
        RX packets 1174  bytes 80087 (78.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 372  bytes 46400 (45.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 396 (396.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 396 (396.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Output of ifconfig command Before Disabling IPv6
Output of ifconfig command Before Disabling IPv6

The above output confirms that IPv6 is enabled for both network cards.

Method 1

Edit the /etc/sysctl.conf file.

sudo nano /etc/sysctl.conf

Place the following entry to disable IPv6 for all adapters.

net.ipv6.conf.all.disable_ipv6 = 1

For a particular adapter (If the network card name is enp0s3).

net.ipv6.conf.enp0s3.disable_ipv6 = 1

To reflect the changes execute the following command.

sudo sysctl -p

Method 2

Create a file called 70-disable-ipv6.conf in the /etc/sysctl.d directory.

sudo nano /etc/sysctl.d/70-disable-ipv6.conf

Add the following entry to disable IPv6 for all adapters.

net.ipv6.conf.all.disable_ipv6 = 1

For a particular adapter (If the network card name is enp0s3).

net.ipv6.conf.enp0s3.disable_ipv6 = 1

Run the below command to take an effect of changes.

sudo sysctl -p -f /etc/sysctl.d/70-disable-ipv6.conf

Verify IPv6

Verify that IPv6 has been disabled using the ifconfig command.

Output of ifconfig command After Disabling IPv6
Output of ifconfig command After Disabling IPv6

You can see that there is no IPv6 address in the output.

Conclusion

That’s All.

You might also like