设置路由表连接服务器

添加路由规则让服务器走特定网关

sudo ip route add 172.19.128.224/28 via 172.24.64.1
sudo ip route add 211.81.55.170 via 172.24.64.1
sudo ip route add 211.81.55.176 via 172.24.64.1
sudo ip route add 211.81.55.158 via 172.24.64.1

查看所有路由表名字:

ubuntu@ubuntu-PC:~$ ip rule show
0:	from all lookup local
32766:	from all lookup main
32767:	from all lookup default

查看某个路由表的规则:

ubuntu@ubuntu-PC:~$ ip route show table main
default via 172.18.128.1 dev wlo1 proto dhcp metric 600 
default via 172.24.64.1 dev enp2s0 proto dhcp metric 20100 
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown 
172.18.128.0/17 dev wlo1 proto kernel scope link src 172.18.140.204 metric 600 
172.19.128.224/28 via 172.24.64.1 dev enp2s0 
172.24.64.0/21 dev enp2s0 proto kernel scope link src 172.24.67.195 metric 100 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown 
211.81.55.158 via 172.24.64.1 dev enp2s0 
211.81.55.170 via 172.24.64.1 dev enp2s0 
211.81.55.176 via 172.24.64.1 dev enp2s0
posted @ 2023-08-09 14:55  王冰冰  阅读(44)  评论(0编辑  收藏  举报