Disable IPv6 on Ubuntu Server Permanently

Disable IPv6 on Ubuntu Server Permanently

To check the settings on the server install:

sudo apt install net-tools 

And run:

netstat -tnl

In a situation where ipv6 is not turned off, you should get something similar...

Disable procedure ipv6:

First edit:

sudo nano /etc/default/grub

by changing the following lines:

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

They will change them to:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"

Next, run:

update-grub
The next step disabling IPv6 via sysctl settings
In order to make the above sysctl changes permanent.
The following file needs to be changed:
sudo nano /etc/sysctl.conf
Then add the content below in the file and save:
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6 = 1

In order for everything to be as it should be, it is necessary to restart the server.

reboot
Enter the command again:
netstat -tnl
You should get something similar: