在Linux系统中启用IPv6有多种方法。以下是三种常见的启用IPv6的方法。
方法一:在NetworkManager中启用IPv6
使用NetworkManager重新启用IPv6,可以通过修改连接的ipv6.method值来实现。以下是一些可用的设置选项:
[root@shizhanxia.com ~]# nmcli connection modify ipv6.method "auto" [root@shizhanxia.com ~]# nmcli connection modify ipv6.method "dhcp" [root@shizhanxia.com ~]# nmcli connection modify ipv6.method "link-local" [root@shizhanxia.com ~]# nmcli connection modify ipv6.method "manual"
方法二:通过sysctl设置启用IPv6
1.删除/etc/sysctl.d/ipv6.conf文件。
2.从创建的备份恢复原始初始 RAM 磁盘映像。例子:
[root@shizhanxia.com ~]# mv /boot/initramfs-4.18.0-240.el8.x86_64_2022-12-16_230548.img /boot/initramfs-4.18.0-240.el8.x86_64.img
3.如果AddressFamily inet被添加到/etc/ssh/sshd_config文件以保留 SSH X11Forwarding,然后删除它并重新启动 SSH 服务。
4.恢复旧的/etc/hosts文件。
[root@shizhanxia.com ~]# mv /etc/hosts.disableipv6 /etc/hosts
方法三:启用IPv6内置内核模块
1.编辑/etc/default/grub文件
编辑/etc/default/grub并删除条目ipv6.disable=1来自GRUB_CMDLINE_LINUX,如以下示例:
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root"
2.生成grub.cfg文件
通过grub2-mkconfig命令重新生成grub.cfg文件:
[root@shizhanxia.com ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
或者,在 UEFI 系统上,运行以下命令:
[root@shizhanxia.com ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
以上就是在Linux系统中启用IPv6的三种常见方法。根据您的具体需求和系统环境,选择最适合您的方法进行操作。
原创文章,作者:运维侠,如若转载,请注明出处:https://www.yunweixia.com/solutions/detailed-explanation-of-three-methods-to-enable-ipv6-on-linux-system.html