Disable IPv6 in Ubuntu 18.04

Sometimes you will want to disable IPv6, in this article we will describe how to easily disable it.

Start by logging into your server as root user.

1. Edit /etc/sysctl.d/99-sysctl.conf (vim /etc/sysctl.d/99-sysctl.conf or nano /etc/sysctl.d/99-sysctl.conf)

    2. Add the following 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

    3. Save and exit the file

    4. Reload the values

    $ sysctl -p

    5. Validate that IPv6 is disabled by running this command:

    $ ip a

    You should not see any 'inet6' lines anymore.

    To verify this has worked reboot your server and run the last command again to see if it completely came through.

    17 July 2019