Linux, Windows, Virtualization, OpenSource & Blogging

How to Disable IPv6 on Debian 9 / Ubuntu 16.04 / LinuxMint 18

1

This post takes you to steps involved in disabling ipv6 on Debian 9 and Ubuntu 16.04. It 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 8 and 7, also, Ubuntu versions such as Ubuntu 14.04 LTS, Ubuntu 17.04, and 16.10.

Disable IPv6 on Debian 9 & Ubuntu 16.04

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

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fd50:1d9:9fe3:1400:a00:27ff:fe36:34ae  prefixlen 64  scopeid 0x0
        inet6 fe80::a00:27ff:fe36:34ae  prefixlen 64  scopeid 0x20
        ether 08:00:27:36:34:ae  txqueuelen 1000  (Ethernet)
        RX packets 893  bytes 116790 (114.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1054  bytes 77781 (75.9 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 1  (Local Loopback)
        RX packets 772  bytes 73806 (72.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 772  bytes 73806 (72.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Disable IPv6 on Debian 9 - Output of ifconfig command Before Disabling IPv6
Disable IPv6 on Debian 9 – Output of ifconfig command Before Disabling IPv6

The above output confirms that IPv6 is enabled for both network cards. So, we will now disable IPv6 using below methods.

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.ens4.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.ens4.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 using ifconfig command. You can see that there is no IPv6 address in the output.

Disable IPv6 on Debian 9 - Output of ifconfig command After Disabling IPv6
Disable IPv6 on Debian 9 – Output of ifconfig command After Disabling IPv6

That’s All.

POSTS YOU MAY LIKE -:)

You might also like
  • steveg

    Thank you Raj for this. Mint cinnamon 18.2 – Method one didn’t work but method two did! Unfortunately it can enable at times. Maybe there is a way to disallow that? I’m happy to have this fix though, I tried many things, (ignore etc) that had no effect on ipv6. Thanks.

How to Disable IPv6 on Debian 9 / Ubuntu 16.04 / LinuxMint 18

1
Never Miss Any Linux Tutorials, Guides, Tips and Free eBooks