Disable IPv6 on Ubuntu 22

Mindwatering Incorporated

Author: Tripp W Black

Created: 04/27/2023 at 11:29 AM

 

Category:
Ubuntu
Configuration Files

Task:
Disable IPv6 networking on Ubuntu server


Verify IPv6 Is In Use:
Look for an inet6 line returned information for the ethernet adapter(s).
$ ip a
...
inet6 fe80:abc1: ...

If it is not there, and you are looking at an ethernet adapter, and not the localhost lo interface, there is no IPv6 enabled for that ethernet adapter. Therefore, in this case, there should be nothing needing to be done.


Steps to Disable:

We can disable in either:
- /etc/sysctl.conf
or
- /etc/default/grub

Both should not be needed.


Option 1 - GRUB
a. Update two of the lines to include ipv6.disable=1. Both lines should be updated. If there is no value, enter just ipv6.disable=1, otherwise add a space, and then ipv6.disable=1.
$ sudo vi /etc/default/grub
...
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
...
<esc>:wq
(to save the change)

b. Update grub:
$ sudo update-grub

c. Reboot and verify again w/ ip a
$ sudo reboot
<wait>

Login and then:
$ ip a



Option 2 - Sysctl
a. Update the Sysctl configuration file, and add the following first two lines for all ethernet adapters, and the third line for the localhost, lo, adapter, as needed:
$ vi /etc/sysctl.conf
...
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
...
<esc>:wq
(to save the change)

b. Enable settings now:
$ sudo sysctl -p

c. Verify with ip a, again:
$ sudo ip a
<verify the inet line is now longer there>

d. Reboot and verify again w/ ip a
$ sudo reboot
<wait>

Login and then:
$ ip a






previous page