Friday, 31 January 2020

How to disable IPv6 on Ubuntu

Some web servers don't support IPv6 connections and might refuse such connections with 403 HTTP error (Forbidden).

In that case we need to disable IPv6 on machine's network interfaces. This is how to do it.

To check first that IPv6 traffic from your machine is enabled, go to some IP checker website (e.g. or and check what it detects (if it shows or not your IPv6 address).

You can also run

$ ifconfig | grep inet6

...and check if (local) IPv6 addresses are assigned to active interfaces.

To disable IPv6 do the following:

1) Open /etc/sysctl.conf

$ sudo nano /etc/sysctl.conf

2) Append the following lines to the existing configuration and save the file:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.tun0.disable_ipv6 = 1

3) Instruct OS to re-read this config file:

$ sudo sysctl -p

To validate changes, repeat IPv6 validation steps described above.

No comments: