|
7.8.ip route show -- 列出路由
縮寫:show、list、sh、ls、l
示例1: 計算使用gated/bgp協(xié)議的路由個數(shù)
# ip route ls proto gated/bgp wc
1413 9891 79010
示例2: 計算路由緩存里面的條數(shù),由于被緩存路由的屬性可能大于一行,以此需要使用-o選項
# ip -o route ls cloned wc
159 2543 18707
示例3: 列出路由表TABLEID里面的路由。缺省設置是table main。TABLEID或者是一個真正的路由表ID或者是/etc/iproute2/rt_tables文件定義的字符串,
或者是以下的特殊值:
all -- 列出所有表的路由;
cache -- 列出路由緩存的內(nèi)容。
ip ro ls 193.233.7.82 tab cache
示例4: 列出某個路由表的內(nèi)容
# ip route ls table fddi153
示例5: 列出默認路由表的內(nèi)容
# ip route ls
這個命令等于傳統(tǒng)的: route
7.9.ip route flush -- 擦除路由表
示例1: 刪除路由表main中的所有網(wǎng)關路由(示例:在路由監(jiān)控程序掛掉之后):
# ip -4 ro flush scope global type unicast
示例2:清除所有被克隆出來的IPv6路由:
# ip -6 -s -s ro flush cache
示例3: 在gated程序掛掉之后,清除所有的BGP路由:
# ip -s ro f proto gated/bgp
示例4: 清除所有ipv4路由cache
# ip route flush cache
*** IPv4 routing cache is flushed.
7.10 ip route get -- 獲得單個路由 .縮寫:get、g
使用這個命令可以獲得到達目的地址的一個路由以及它的確切內(nèi)容。
ip route get命令和ip route show命令執(zhí)行的操作是不同的。ip route show命令只是顯示現(xiàn)有的路由,而ip route get命令在必要時會派生出新的路由。
示例1: 搜索到193.233.7.82的路由
# ip route get 193.233.7.82
193.233.7.82 dev eth0 src 193.233.7.65 realms inr.ac cache mtu 1500 rtt 300
示例2: 搜索目的地址是193.233.7.82,來自193.233.7.82,從eth0設備到達的路由(這條命令會產(chǎn)生一條非常有意思的路由,這是一條到193.233.7.82的回環(huán)路由)
# ip r g 193.233.7.82 from 193.233.7.82 iif eth0
193.233.7.82 from 193.233.7.82 dev eth0 src 193.233.7.65 realms inr.ac/inr.ac
cache ; mtu 1500 rtt 300 iif eth0
8. ip route -- 路由策略數(shù)據(jù)庫管理命令
命令 add、delete、show(或者list)
注意:策略路由(policy routing)不等于路由策略(rouing policy)。
在某些情況下,我們不只是需要通過數(shù)據(jù)包的目的地址決定路由,可能還需要通過其他一些域:源地址、IP協(xié)議、傳輸層端口甚至數(shù)據(jù)包的負載。
這就叫做:策略路由(policy routing)。
8.5. ip rule add -- 插入新的規(guī)則
ip rule delete -- 刪除規(guī)則
縮寫:add、a;delete、del、d
示例1: 通過路由表inr.ruhep路由來自源地址為192.203.80/24的數(shù)據(jù)包
ip ru add from 192.203.80/24 table inr.ruhep prio 220
示例2:把源地址為193.233.7.83的數(shù)據(jù)報的源地址轉換為192.203.80.144,并通過表1進行路由
ip ru add from 193.233.7.83 nat 192.203.80.144 table 1 prio 320
示例3:刪除無用的缺省規(guī)則
ip ru del prio 32767
8.7. ip rule show -- 列出路由規(guī)則
縮寫:show、list、sh、ls、l
示例1: # ip ru ls
0: from all lookup local
32762: from 192.168.4.89 lookup fddi153
32764: from 192.168.4.88 lookup fddi153
32766: from all lookup main
32767: from all lookup 253
9. ip maddress -- 多播地址管理
縮寫:show、list、sh、ls、l
9.3.ip maddress show -- 列出多播地址 |
|
【收藏】【打印】【進入論壇】 |
|
|
|
|
|
|
|