要在Ubuntu上禁用IPv6,您需要执行以下步骤:
打开终端(快捷键:Ctrl + Alt + T)
首先,确保您的系统已安装了iptables-persistent
。如果没有,请运行以下命令来安装它:
sudo apt-get update
sudo apt-get install iptables-persistent
在安装过程中,它会询问您是否要保存当前的iptables规则。选择“是”,以便在系统重启后保留这些规则。
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
这将分别禁用所有网络接口、默认网络接口和本地回环接口上的IPv6。
/etc/sysctl.conf
文件中:net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
使用文本编辑器打开文件,例如:
sudo nano /etc/sysctl.conf
将上述行添加到文件末尾,然后保存并关闭文件。
sudo reboot
现在,您的Ubuntu系统应该已经禁用了IPv6。您可以通过运行以下命令来验证:
ip addr show
在输出中,您应该看不到任何IPv6地址。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:ubuntu如何禁用ipv6