本文共 2767 字,大约阅读时间需要 9 分钟。
88.9.10.128是一個host
指定要連結到88.9.10.128這台主機的封包,會經由wlan0的192.168.11.1這個gateway出去
Flags的H待表示一個Host
route add 88.9.10.128 gw 192.168.11.1 dev wlan0
# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 wlan00.0.0.0 192.192.192.1 0.0.0.0 UG 0 0 0 eth088.9.10.128 192.168.11.1 255.255.255.255 UGH 0 0 0 wlan0192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0192.192.192.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
設定static route
連結到172.100.100.0網段的封包,必須經過192.192.192.1這個gw(當沒有指定是經由那個界面出去時,會經由gw去判斷,應該是那個interface出去)
route add -net 172.100.100.0 netmask 255.255.255.0 gw 192.192.192.1
連結到172.101.101.0網段的封包,必須經過192.192.192.1這個gw,並且明定指出是經由eth0這個界面出去
route add -net 172.101.101.0 netmask 255.255.255.0 gw 192.192.192.1 dev eth0
# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 wlan00.0.0.0 192.192.192.1 0.0.0.0 UG 0 0 0 eth088.9.10.128 192.168.11.1 255.255.255.255 UGH 0 0 0 wlan0172.100.100.0 192.192.192.1 255.255.255.0 UG 0 0 0 eth0172.101.101.0 192.192.192.1 255.255.255.0 UG 0 0 0 eth0192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0192.192.192.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
刪除一條route 規則
route del -net 172.100.100.0 netmask 255.255.255.0 dev eth0
# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 wlan00.0.0.0 192.192.192.1 0.0.0.0 UG 0 0 0 eth088.9.10.128 192.168.11.1 255.255.255.255 UGH 0 0 0 wlan0172.101.101.0 192.192.192.1 255.255.255.0 UG 0 0 0 eth0192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0192.192.192.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
刪除UGH的route 規則
route del 88.9.10.128
# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 wlan00.0.0.0 192.192.192.1 0.0.0.0 UG 0 0 0 eth0172.101.101.0 192.192.192.1 255.255.255.0 UG 0 0 0 eth0192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0192.192.192.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
转载地址:http://zzpgi.baihongyu.com/