Disable or enable the IPv6 protocol
Disabling IPv6 support in Red Hat Enterprise Linux 7
Disable ipv6 built-in kernel module.
Edit /etc/default/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX like the following sample:
Raw
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:
Raw
# grub2-mkconfig -o /boot/grub2/grub.cfg
Alternatively, on UEFI systems, run the following:
Raw
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Reboot the system to disable IPv6 support.
Note: While following above method if you notice any Selinux denied messages in audit.log file such as avc: denied { module_request } then disable the ipv6 from /etc/sysctl.d/ipv6.conf file shown below instead.
Alternatively, this can be done via sysctl settings. Please be aware that this breaks SSH Xforwarding unless sshd_config contains AddressFamily inet.
Create a new file named /etc/sysctl.d/ipv6.conf and add the following options:
Raw
# To disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1
# the protocol can be disabled for specific interfaces as well.
net.ipv6.conf.
The new settings would then need to be reloaded with:
Raw
# sysctl -p /etc/sysctl.d/ipv6.conf
Then rebuild the Initial RAM Disk Image using:
Raw
# dracut -f
Optionally to prevent rpc* messages output after disabling ipv6, edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “v” in the third column to “-“(hyphen/dash). Please refer to rpc* messages output after disabling ipv6.
Re-enabling IPv6 support in Red Hat Enterprise Linux 7
Edit /etc/default/grub and delete the entry ipv6.disable=1 from the GRUB_CMDLINE_LINUX, like the following sample:
Raw
GRUB_CMDLINE_LINUX=”rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root”
Run the grub2-mkconfig command to regenerate the grub.cfg file:
Raw
# grub2-mkconfig -o /boot/grub2/grub.cfg
Alternatively, on UEFI systems, run the following:
Raw
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Delete the file /etc/sysctl.d/ipv6.conf which contains the entry:
Raw
# To disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1
# the protocol can be disabled for specific interfaces as well.
net.ipv6.conf.
If the Initial RAM Disk image was created earlier while disabling IPv6 , only then carry out this step.
Raw
# dracut -f
Check the content of the file /etc/ssh/sshd_config and make sure the AddressFamily line is commented:
Raw
#AddressFamily inet
Make sure the following line exists in /etc/hosts, and is not commented out:
Raw
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Reboot the system to enable IPv6 support.
Disabling IPv6 support in Red Hat Enterprise Linux 6
Create a file /etc/modprobe.d/ipv6.conf with the following contents:
Raw
options ipv6 disable=1
Disable the ip6tables service from starting at boot by issuing the following command:
Raw
# chkconfig ip6tables off
Alternatively, the IPv6 support can also be disabled in the kernel through /etc/sysctl.conf by setting following parameter:
Raw
# IPv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Please be aware that this breaks SSH Xforwarding unless AddressFamily inet is set in sshd_config.
Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw
# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts
Optionally to prevent rpc.nfsd setting up IPv6 sockets while NFS server is running, edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “v” in the third column to “-“(hyphen/dash)
Reboot the system to disable IPv6 support.
Note: The solution above only disables (unhooks all of the calls) the ipv6 module, but doesn’t prevent it from loading. Unloading the module isn’t recommended due to the dependency factors it has with other modules (for example: bonding) and services. To prevent the module from loading, modify /etc/modprobe.d/ipv6.conf with the following contents:
Raw
install ipv6 /bin/true
Disabling ipv6 in the sysctl.conf will ensure ipv6 isn’t used even if the ipv6 module is loaded and can work as a short term solution (until a full reboot)
There is a special case where this might not work, please see The “ipv6 disable=1” option does not seem to work on Red Hat Enterprise Linux 6 system.
Re-enabling IPv6 support in Red Hat Enterprise Linux 6
Review the files under /etc/modprobe.d/ and remove (or comment out) any of the following lines:
Raw
options ipv6 disable=1
install ipv6 /bin/true
blacklist ipv6
alias ipv6 off
Configure the ip6tables service to start at boot by issuing the following command:
Raw
# chkconfig ip6tables on
Make sure the following options to your /etc/sysctl.conf are set to default value ‘0’
Raw
# ipv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
Make sure the following line exists in /etc/hosts and is not commented out:
Raw
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “-“(hyphen/dash) in the third column to “v”
Reboot the system to activate IPv6 support.
Disabling IPv6 support in Red Hat Enterprise Linux 5
Remove the following line (if present) from the /etc/modprobe.conf file:
Raw
alias net-pf-10 ipv6
Add the following line to the /etc/modprobe.conf file:
Raw
alias net-pf-10 off
In versions of Red Hat Enterprise Linux before 5.4, add the following line to the /etc/modprobe.conf file:
Raw
alias ipv6 off
In Red Hat Enterprise Linux 5.4 and later, add the following line to the /etc/modprobe.conf file:
Raw
options ipv6 disable=1
To prevent errors during the network initscript start routine, change the NETWORKING_IPV6 parameter in the /etc/sysconfig/network file to the following:
Raw
NETWORKING_IPV6=no
Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw
# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts
Disable the ip6tables service from starting at boot by issuing the following command:
Raw
# chkconfig ip6tables off
Reboot the system to disable IPv6 support.
Re-enabling IPv6 support in Red Hat Enterprise Linux 5
Remove the following lines (if present) from the /etc/modprobe.conf file:
Raw
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1
Add the following line to the /etc/modprobe.conf file (if not present already):
Raw
alias net-pf-10 ipv6
Change the NETWORKING_IPV6 parameter in the /etc/sysconfig/network file to the following:
Raw
NETWORKING_IPV6=yes
Make sure the following line exists in /etc/hosts and is not commented out:
Raw
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Configure the ip6tables service to start at boot by issuing the following command:
Raw
# chkconfig ip6tables on
Reboot the system to re-enable IPv6 support.
Disabling IPv6 support in Red Hat Enterprise Linux 4
Remove the following line (if present) from the /etc/modprobe.conf file:
Raw
alias net-pf-10 ipv6
Add the following line to the /etc/modprobe.conf file:
Raw
alias net-pf-10 off
Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw
# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts
Reboot the system to disable IPv6 support.
Re-enabling IPv6 support in Red Hat Enterprise Linux 4
Remove the following line from the /etc/modprobe.conf file:
Raw
alias net-pf-10 off
Add the following line to the /etc/modprobe.conf file:
Raw
alias net-pf-10 ipv6
Make sure the following line exists in /etc/hosts, and is not commented out.
Raw
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Reboot the system to re-enable IPv6 support.
Additional notes
Disabling IPv6 by blacklisting the module invalidates bonding in the system.
Recent Comments