root@vultr:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0100.64.0.10.0.0.0 UG 000 ens3 10.25.96.00.0.0.0255.255.240.0 U 000 ens7 100.64.0.00.0.0.0255.192.0.0 U 000 ens3 169.254.0.00.0.0.0255.255.0.0 U 000 ens3 207.148.112.00.0.0.0255.255.254.0 U 000 ens3 root@vultr:~# ip route show default via 100.64.0.1 dev ens3 onlink 10.25.96.0/20 dev ens7 proto kernel scope link src 10.25.96.3 100.64.0.0/10 dev ens3 proto kernel scope link src 100.68.5.186 169.254.0.0/16 dev ens3 scope link 207.148.112.0/23 dev ens3 proto kernel scope link src 207.148.113.46 root@vultr:~#
看到走的还是运营商NAT,删掉他,并添加默认路由,要使用是刚才添加的公网IPV4和实际的网卡编号.
route r del default gw 100.64.0.1
ip route add default via 207.148.113.46 dev ens3
具体如下:
root@vultr:~# route del default gw 100.64.0.1 root@vultr:~# ip route list 10.25.96.0/20 dev ens7 proto kernel scope link src 10.25.96.3 100.64.0.0/10 dev ens3 proto kernel scope link src 100.68.5.186 169.254.0.0/16 dev ens3 scope link 207.148.112.0/23 dev ens3 proto kernel scope link src 207.148.113.46 root@vultr:~# ip route add default via 207.148.113.46 dev ens3 root@vultr:~# ip route list default via 207.148.113.46 dev ens3 10.25.96.0/20 dev ens7 proto kernel scope link src 10.25.96.3 100.64.0.0/10 dev ens3 proto kernel scope link src 100.68.5.186 169.254.0.0/16 dev ens3 scope link 207.148.112.0/23 dev ens3 proto kernel scope link src 207.148.113.46