|
5.2 ip address delete--刪除一個協(xié)議地址. 縮寫:delete、del、d
# ip addr del 192.168.4.1/24 brd + dev eth0 label eth0:Alias1
5.3 ip address show--顯示協(xié)議地址. 縮寫:show、list、lst、sh、ls、l
# ip addr ls eth0
5.4.ip address flush--清除協(xié)議地址. 縮寫:flush、f
示例1 : 刪除屬于私網10.0.0.0/8的所有地址:
# ip -s -s a f to 10/8
示例2 : 取消所有以太網卡的IP地址
# ip -4 addr flush label "eth0"
6. ip neighbour--neighbour/arp表管理命令
縮寫 neighbour、neighbor、neigh、n
命令 add、change、replace、delete、fulsh、show(或者list)
6.1 ip neighbour add -- 添加一個新的鄰接條目
ip neighbour change--修改一個現(xiàn)有的條目
ip neighbour replace--替換一個已有的條目
縮寫:add、a;change、chg;replace、repl
示例1: 在設備eth0上,為地址10.0.0.3添加一個permanent ARP條目:
# ip neigh add 10.0.0.3 lladdr 0:0:0:0:0:1 dev eth0 nud perm
示例2:把狀態(tài)改為reachable
# ip neigh chg 10.0.0.3 dev eth0 nud reachable
6.2.ip neighbour delete--刪除一個鄰接條目
示例1:刪除設備eth0上的一個ARP條目10.0.0.3
# ip neigh del 10.0.0.3 dev eth0
6.3.ip neighbour show--顯示網絡鄰居的信息. 縮寫:show、list、sh、ls
示例1: # ip -s n ls 193.233.7.254
193.233.7.254. dev eth0 lladdr 00:00:0c:76:3f:85 ref 5 used 12/13/20 nud reachable
6.4.ip neighbour flush--清除鄰接條目. 縮寫:flush、f
示例1: (-s 可以顯示詳細信息)
# ip -s -s n f 193.233.7.254
7. 路由表管理
7.1.縮寫 route、ro、r
7.5.路由表
從Linux-2.2開始,內核把路由歸納到許多路由表中,這些表都進行了編號,編號數(shù)字的范圍是1到255。另外,
為了方便,還可以在/etc/iproute2/rt_tables中為路由表命名。
默認情況下,所有的路由都會被插入到表main(編號254)中。在進行路由查詢時,內核只使用路由表main。
7.6.ip route add -- 添加新路由
ip route change -- 修改路由
ip route replace -- 替換已有的路由
縮寫:add、a;change、chg;replace、repl
示例1: 設置到網絡10.0.0/24的路由經過網關193.233.7.65
# ip route add 10.0.0/24 via 193.233.7.65
示例2: 修改到網絡10.0.0/24的直接路由,使其經過設備dummy
# ip route chg 10.0.0/24 dev dummy
示例3: 實現(xiàn)鏈路負載平衡.加入缺省多路徑路由,讓ppp0和ppp1分擔負載(注意:scope值并非必需,它只不過是告訴內核,這個路由要經過網關而不是直連的。實際上,如果你知道遠程端點的地址,使用via參數(shù)來設置就更好了)。
# ip route add default scope global nexthop dev ppp0 nexthop dev ppp1
# ip route replace default scope global nexthop dev ppp0 nexthop dev ppp1
示例4: 設置NAT路由。在轉發(fā)來自192.203.80.144的數(shù)據(jù)包之前,先進行網絡地址轉換,把這個地址轉換為193.233.7.83
# ip route add nat 192.203.80.142 via 193.233.7.83
示例5: 實現(xiàn)數(shù)據(jù)包級負載平衡,允許把數(shù)據(jù)包隨機從多個路由發(fā)出。weight 可以設置權重.
# ip route replace default equalize nexthop via 211.139.218.145 dev eth0 weight 1 nexthop via 211.139.218.145 dev eth1 weight 1
7.7.ip route delete-- 刪除路由
縮寫:delete、del、d
示例1:刪除上一節(jié)命令加入的多路徑路由
# ip route del default scope global nexthop dev ppp0 nexthop dev ppp1 |
|
【收藏】【打印】【進入論壇】 |
|
|
|
|
|
|
|