前言:
? ? ? ? ?有線網(wǎng)(公司):172.16.224.199? ? ?網(wǎng)關(guān):172.16.224.254? (手工)?
? ? ? ? ?無線網(wǎng)(手機):192.168.43.193? ? ?網(wǎng)關(guān):192.168.43.1(自動獲取)
1.查看路由
? ? ? Kernel IP routing table? ? ?
? ? ? Destination? ? Gateway? ? ? ? Genmask? ? ? ? Flags Metric Ref? ? Use Iface
? ? ? default? ? ? ? 192.168.43.1? ? 0.0.0.0? ? ? ? UG? ? 600? ? 0? ? ? ? 0 wlp2s0
? ? ? default? ? ? ? 172.16.224.254? 0.0.0.0? ? ? ? UG? ? 20100? 0? ? ? ? 0 eth0
2.修改有線網(wǎng)絡(luò)路由
? ? ? ?刪除有線網(wǎng)卡路由
? ? ? ? route del -net default netmask 0.0.0.0 dev eth0
? ? ? ? 添一條路由
? ? ? ? route add -net 172.0.0.0 netmask 255.0.0.0 gw 172.16.224.254 dev eth0
? ? ? ?只要訪問172.0.0.0? 都從172.16.224.254走.
成功俺驶!
補充:由于重啟之后路由會恢復(fù),所以我們把它放配置文件中:
vim /etc/NetworkManager/dispatcher.d/02myroutes
里面寫:
#!/bin/bash
? route del -net default netmask 0.0.0.0 dev eth0
? route add -net 172.0.0.0 netmask 255.0.0.0 gw 172.16.224.254 dev eth0
wq!保存退出!
成功8俏摹GO帧!