linux设置ipv4优先或者ipv6优先

取消掉这个注释

sed -i "s/#\?precedence ::ffff:0:0\/96 100/precedence ::ffff:0:0\/96 100/" /etc/gai.conf

改回去(恢复系统默认)

sed -i "s/^precedence ::ffff:0:0\/96  100/\#precedence ::ffff:0:0\/96  100/" /etc/gai.conf

推荐下面这种(最推荐的是手动改)

直接加一行到最后

echo "precedence ::ffff:0:0/96  100" >> /etc/gai.conf

删掉(恢复系统默认)

sed -i "/^precedence ::ffff:0:0\/96  100/d" /etc/gai.conf

改变是即时生效的

判断,看看是ipv4还是ipv6就知道了(任意一个双栈的都可以)
curl ip.sb

tag(s): none
show comments · back · home
Edit with markdown