策略路由实战

IP

wwan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.164.219.2 netmask 255.255.255.252 destination 10.164.219.2

wlx08beac133294: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.168.111.115 netmask 255.255.255.0 broadcast 172.168.111.255

默认路由

default via 192.168.1.1 dev eth1 onlink
default via 10.164.219.1 dev wwan0 proto static metric 700

删除默认路由

route del default

建立策略路由

echo -e "100\tnet_gms " >> /etc/iproute2/rt_tables
ip route add default via 10.164.219.1 dev wwan0 table 100

echo -e "101\tnet_eth " >> /etc/iproute2/rt_tables
ip route add 172.168.30.0/24 via 192.168.1.1 dev eth1 table net_eth
ip route add 172.168.1.0/24 via 192.168.1.1 dev eth1 table net_eth

echo -e "102\tnet_wifi " >> /etc/iproute2/rt_tables
ip route add 172.168.113.0/24 via 172.168.111.1 dev wlx08beac133294 table net_wifi

ip route show table net_gms
172.168.113.73

IP

inet 10.162.62.198 netmask 255.255.255.252 destination 10.162.62.198

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值