Matomo Analytics

At some point, you're going to want to disable IPv6 as it might be conflicting with the services you run on that server. Doing this is fairly easy in Ubuntu.

First of all, run this command to verify if IPv6 is currently available on your server:

ip a

CleanShot 2023-01-03 at 19.54.15.png 1007.47 KB
If you see an IPv6 address there, then IPv6 is enabled for your server. We'll continue on how to disable this.

You can either disable it for the time the server is booted or permanently. We'll start with the temporary one first.

SSH into your server and run the following 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

Next, run again:

ip a

The IP address from the previous screenshot should be gone now.

If you want to permanently disable IPv6, edit the /etc/sysctl.conf file (as root, or use sudo). Scroll all the way down, and paste these lines:

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

To make the changes come through, run the following command:

sudo sysctl -p

Now, IPv6 will always be disabled, even when you restart the server.

03 January 2023 (last updated 1 year ago)

2565 views

Written by Dennis

Dennis brings over 6 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Back to Server


Start free trial