If network troubleshooting leads you to believe there's an issue with IPv6, you may need to shut down that protocol on your Linux machines. Since some hardware doesn't take advantage of IPv6 (and most admins are still working with IPv4), a temporary and easy solution is to disable IPv6; the protocol can be re-enabled when the time comes when the issue has been permanently resolved.
To verify if IPv6 is enabled or not, execute the following command:
# ifconfig -a | grep inet6 inet6 fe80::211:aff:fe6a:9de4 prefixlen 64 scopeid 0x20 inet6 ::1 prefixlen 128 scopeid 0x10[host]
Disable IPv6 in kernel module (requires reboot)
Edit the file /etc/default/grub and add ipv6.disable=1 in line GRUB_CMDLINE_LINUX, e.g.:
# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet" GRUB_DISABLE_RECOVERY="true"
Regenerate a GRUB configuration file and overwrite existing one:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Restart system and verify no line “inet6” in “ip addr show” command output.
# shutdown -r now # ip addr show | grep net6
Using Grub2, you can permanently disable IPv6 network address allocations by modifying the GRUB boot menu using another approach. First obtain the current kernelopts argument list: For example:
# grub2-editenv - list | grep kernelopts kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet
Next, append a new argument ipv6.disable=1 to the previously received kernelopts argument list. For example:
# grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet ipv6.disable=1"
Disable IPv6 using sysctl settings (no reboot required)
Append below lines in /etc/sysctl.conf configuration file:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
NOTE: to disable IPv6 on a single interface add below lines to /etc/sysctl.conf:
net.ipv6.conf.[interface].disable_ipv6 = 1 ### put interface name here [interface] net.ipv6.conf.default.disable_ipv6 = 1
To make the settings affective, execute the following command:
# sysctl -p
NOTE: make sure the file /etc/ssh/sshd_config contains the line AddressFamily inet to avoid breaking SSH Xforwarding if you are using the sysctl method.
Add the AddressFamily line to sshd_config:
# vi /etc/ssh/sshd_config .... AddressFamily inet ....
Restart sshd daemon for changes to get get effect:
# systemctl restart sshd
Here's how to disable the protocol on a Red Hat-based system:
- Open a terminal window.
- Change to the root user.
- Issue the command sysctl -w net.ipv6.conf.all.disable_ipv6=1
- Issue the command sysctl -w net.ipv6.conf.default.disable_ipv6=1
To re-enable IPv6, issue the following commands:
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0