ip route replace default via 网关IP dev eth0 src 出口IP
若为同 C 段 IP,可以将其设置为函数:
# cat ~/.bashrc
function setip() {
echo "ip route replace default via 192.168.1.1 dev eth0 src 192.168.1.$1"
ip route replace default via 192.168.1.1 dev eth0 src 192.168.1.$1
sleep 1
curl ip.sb
}
# source ~/.bashrc
# setip 2