source from: https://access.redhat.com/solutions/8709
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:
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 the system to disable IPv6 support.
- Alternatively, this can be done via sysctl settings. Please be aware that this breaks SSH Xforwarding unless
sshd_configcontainsAddressFamily inet.
- Create a new file named
/etc/sysctl.d/ipv6.confand add the following options:# 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..disable_ipv6 = 1 - The new settings would then need to be reloaded with:
# sysctl -p /etc/sysctl.d/ipv6.conf
Disabling IPv6 support in Red Hat Enterprise Linux 6
- Create a file
/etc/modprobe.d/ipv6.confwith the following contents:options ipv6 disable=1 - For completeness, it is a good idea to configure the
ip6tablesservice not to start at boot by issuing the following command:# chkconfig ip6tables off - Alternatively, the IPv6 support can also be disabled in the kernel through
/etc/sysctl.confby setting following parameter:# 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::1localhost address# cp -p /etc/hosts /etc/hosts.disableipv6 # sed -i 's/^[[:space:]]*::/#::/' /etc/hosts - Optionally to prevent
rpc.nfsdsetting up IPv6 sockets while NFS server is running, edit/etc/netconfigfor 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 only: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:options ipv6 disable=1 install ipv6 /bin/true blacklist ipv6 alias ipv6 off - Configure the
ip6tablesservice to start at boot by issuing the following command:# chkconfig ip6tables on - Make sure the following options to your
/etc/sysctl.confare# 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.::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 - Edit
/etc/netconfigfor 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.conffile:alias net-pf-10 ipv6 - Add the following line to the
/etc/modprobe.conffile:alias net-pf-10 off - In versions of Red Hat Enterprise Linux before 5.4, add the following line to the
/etc/modprobe.conffile:alias ipv6 off - In Red Hat Enterprise Linux 5.4 and later, add the following line to the
/etc/modprobe.conffile:options ipv6 disable=1 - To prevent errors during the network initscript start routine, change the
NETWORKING_IPV6parameter in the/etc/sysconfig/networkfile to the following:NETWORKING_IPV6=no - Comment out any IPv6 addresses found in
/etc/hosts, including::1localhost address# cp -p /etc/hosts /etc/hosts.disableipv6 # sed -i 's/^[[:space:]]*::/#::/' /etc/hosts - For completeness, it is a good idea to configure the
ip6tablesservice not to start at boot by issuing the following command:# 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.conffile:alias net-pf-10 off alias ipv6 off options ipv6 disable=1 - Add the following line to the
/etc/modprobe.conffile (if not present already):alias net-pf-10 ipv6 - Change the
NETWORKING_IPV6parameter in the/etc/sysconfig/networkfile to the following:NETWORKING_IPV6=yes - Make sure the following line exists in
/etc/hosts, and is not commented out.::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 - For completeness, it is a good idea to configure the
ip6tablesservice to start at boot by issuing the following command:# 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.conffile:alias net-pf-10 ipv6 - Add the following line to the
/etc/modprobe.conffile:alias net-pf-10 off - Comment out any IPv6 addresses found in
/etc/hosts, including::1localhost address# 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.conffile:alias net-pf-10 off - Add the following line to the
/etc/modprobe.conffile:alias net-pf-10 ipv6 - Make sure the following line exists in
/etc/hosts, and is not commented out.::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.
No comments:
Post a Comment