How to Disable IPV6 on RHEL 8 / Rocky Linux 8 / Alma Linux 8

Method 1: Using GRUB2

Edit /etc/default/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX 

GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root ipv6.disable=1"

Run the grub2-mkconfig command to regenerate the grub.cfg file:

grub2-mkconfig -o /boot/grub2/grub.cfg

Alternatively, on UEFI systems, run the following:

grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Reboot Server

reboot

 

Method 2: Using sysctl

Create File ipv6.conf

nano /etc/sysctl.d/ipv6.conf

==============================

# First, disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1


# If using the sysctl method, the protocol must be disabled all specific interfaces as well.
net.ipv6.conf..disable_ipv6 = 1

==============================

Reloaded

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

Create a backup of the initramfs before making any changes to it:

cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).bak.$(date +%m-%d-%H%M%S).img

rebuild the Initial RAM Disk Image

dracut -f -v

Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address. Make backup of the file before making any changes:

cp -p /etc/hosts /etc/hosts.disableipv6

sed -i 's/^[[:space:]]*::/#::/' /etc/hosts

VERIFICATION

1. The current state of the ipv6 module disable option can be seen via sysfs:

# cat /sys/module/ipv6/parameters/disable
1

2. The current state of the sysctl disable_ipv6 can be seen with the sysctl command:

# sysctl -a 2>/dev/null | grep disable_ipv6


net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.eth0.disable_ipv6 = 0


3. To list any IPv6 addresses assigned to the system:
 

ip -6 addr

4. To list any IPv6 TCP or UDP sockets something like the following can be used:
 

ss -6 -pan


Comments

Popular posts from this blog

How to Install Zabbix 6.0 LTS on Ubuntu 22

How to Install Nagios 4.4.9 On ubuntu 22.04

How To Install Nextcloud 25 On Red Hat 8.6 With PHP 7.4