摘要:记录一下ubuntu 24.04禁用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

然后运行sysctl -p,重新加载一下内核参数就可以生效了。生效过后可以使用curl ifconfig.me,根据API返回的ip地址,来判断是否生效。