Disable default IPv6 protocol on Ubuntu 18.04 Linux

this is what my hosts file looks like from a default install of 18.04.1. i have a static ip set. i changed the host name using your steps but i left the hosts file alone and it persisted after a reboot. is the whole ipv6 thing going on the default in ubuntu server now?
download

Hi

My understanding is that the IPv6 protocol has been enabled by default for some time already. If you wish to disable IPv6 network addresses simply execute:

$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

For better, after the reboot persistent solution, follow our guide on How to disable IPv6 address on Ubuntu 18.04 Bionic Beaver Linux.

However, in most cases you do not have to worry about IPv6 and simply ignore it.

The link you provided instructs one to edit the /etc/sysctl.conf file. I prefer to avoid editing standard system config files when possible.

it is better (imo) to create a new config file, say /etc/sysctl.d/60-disable-ipv6.conf with the following contents.

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

then engage it with

sysctl -p /etc/sysctl.d/60-disable-ipv6.conf

This has several advantages

  1. can toggle on/off ipv6 as a batch operation
  2. leaves the main /etc/sysctl.conf intact / clean, which means more seamless updates
  3. is persistent across reboots

Note that the precise name of the file “60-disable-ipv6.conf” is arbitrary.