How to disable IPv6 on Ubuntu 16.04 or newer

Hello my dear Linux Yogi’s

in today’s illustration I am showing you how to disable IPv6. In some server set ups it is not required to have IPv6 enable and running as well as services listening on both IPv4 and IPv6. I always try to preserve resources where I can so I turn it off if I don’t need to use it.

This is going to be a quick and dirty how to. Lets get started. In order to disable IPv6 we have to provide some kernel parameters by editing the file /etc/sysctl.d/99-sysctl.conf. Execute the following command:

sudo nano /etc/sysctl.d/99-sysctl.conf

(If the file doesn’t exist it will be created) Add the following three lines to the end of the file:

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

That is it. Go ahead and perform a reboot in order to make those changes apply. After the reboot log in and execute the following command :

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

and it either returns a 0 or 1 . If you see a 1 then the IPv6 is disabled.

Thank you for reading this illustration. If you like me to illustrate something you like to see please don’t hesitate to send me an email with my contact form or just leave a comment on my blog.

Until next time, Namaste my friends 😉