[
功能]
管理系統的arp快取。
[
描述]
用來管理系統的arp快取,常用的命令包括:
arp: 顯示所有的表項。
arp -d address: 刪除乙個arp表項。
arp -s address hw_addr: 設定乙個arp表項。
常用引數:
-a 使用bsd形式輸出。(沒有固定的列)
-n 使用數字形式顯示ip位址,而不是預設的主機名形式。
-d 不是指定硬體位址而是指定乙個網路介面的名稱,表項將使用相應介面的mac位址。一般用來設定arp**。
-h type, --hw-type type: 指定檢查特定型別的表項,預設type為ether,還有其他型別。
-i if, --device if: 指定設定哪個網路介面上面的arp表項。
-f filename: 作用同'-s',不過它通過檔案來指定ip位址和mac位址的繫結。檔案中每行分別是主機和mac,中間以空格分割。如果沒有指定檔名稱,則使用/etc/ethers檔案。
以下例子中,用主機名稱的地方也可以用點分10進製的ip位址來表示。另外輸出結果中用"c"表示arp快取內容,"m"表示永久性表項,"p"表示公共的表項。
[
舉例]
*檢視arp表:
#arp
address hwtype hwaddress flags mask iface
hostname1 ether 44:37:e6:97:92:16 c eth0
hostname2 ether 00:0f:fe:43:28:c5 c eth0
hostname3 ether 00:1d:92:e3:d5:ee c eth0
hostname4 ether 00:1d:0f:11:f2:a5 c eth0
這裡,flags中的"c"代表此表專案是快取記憶體中的內容,快取記憶體中的內容過一段時間(一般20分鐘)會清空,而"m"則表示靜態表項,靜態表項的內容不會過一段時間被清空。
*檢視arp表,並且用ip顯示而不是主機名稱:
# arp -n
address hwtype hwaddress flags mask iface
10.1.10.254 ether 00:1d:92:e3:d5:ee c eth0
10.1.10.253 ether 44:37:e6:9b:2c:53 c eth0
10.1.10.178 ether 00:1b:78:83:d9:85 c eth0
10.1.10.119 ether 00:1d:0f:11:f2:a5 c eth0
這裡,對於上面的條目,假設當我們"ping 10.1.10.1"通過之後,arp中會多一條"10.1.10.1"相關的資訊。
*檢視arp表,顯示主機名稱和ip:
#arp -a
ns.amazon.esdl.others.com (10.1.10.254) at 00:1d:92:e3:d5:ee [ether] on eth0
server.amazon.eadl.others.com (10.1.10.253) at 44:37:e6:9b:2c:53 [ether] on eth0
d2-baijh.amazon.esdl.others.com (10.1.10.178) at 00:1b:78:83:d9:85 [ether] on eth0
aplab.local (10.1.10.119) at 00:1d:0f:11:f2:a5 [ether] on eth0
*# arp -s 10.1.1.1 00:11:22:33:44:55:66
這裡,如果網路無法達到,那麼會報告錯誤,具體如下:
root@quietheart:/home/lv-k# arp -s 10.1.1.1 00:11:22:33:44:55:66
siocsarp: network is unreachable
root@quietheart:/home/lv-k# arp -n
address hwtype hwaddress flags mask iface
10.1.10.254 ether 00:1d:92:e3:d5:ee c eth0
10.1.10.253 ether 44:37:e6:9b:2c:53 c eth0
10.1.10.178 ether 00:1b:78:83:d9:85 c eth0
10.1.10.119 ether 00:1d:0f:11:f2:a5 c eth0
實際上,如果"arp -s"設定成功之後,會增加乙個flags為"cm"的表項,有些系統靜態條目不會因為arp響應而更新,而快取記憶體中的條目會因此而更新。如果想要手工設定沒有"m",那麼用"temp"選項,例如:"arp -s ip mac temp"類似的命令,實踐發現,如果已經設定過ip了,那麼再設定也不會改變其flags。
*刪除乙個arp表項:
# arp -d 10.1.10.118
root@quietheart:~# arp -n
address hwtype hwaddress flags mask iface
10.1.10.118 ether 00:25:9c:c2:79:90 cm eth0
10.1.10.254 ether 00:1d:92:e3:d5:ee c eth0
root@quietheart:~# arp -d 10.1.10.118
root@quietheart:~# arp -n
address hwtype hwaddress flags mask iface
10.1.10.118 (incomplete) eth0
10.1.10.254 ether 00:1d:92:e3:d5:ee c
*刪除eth0上面的乙個arp表項:
# arp -i eth0 -d 10.1.10.118
[
其它]
*#/usr/sbin/arp -i eth0 -ds 10.0.0.2 eth1 pub
當eth0收到ip位址為10.0.0.2的請求時,將會用eth1的mac位址回答。
例如,雙網絡卡機器執行這條命令:
/usr/sbin/arp -i eth0 -ds 10.0.0.2 eth1 pub
會多一項:
10.0.0.2 * mp eth0
Linux學習手冊之檔案處理命令及檔案命名規則
檔案命名規則 1.除了 之外,所有的字元都合法 2有些字元最後不用,如空格符 製表符 退格符 和字元 等 3.避免適用.作為普通檔名的第乙個字元 4.大小寫敏感 命令格式 命令 選項 引數 例 ls la etc 說明 1.當有多個選項時,可以寫在一起 2.兩個特殊的目錄.和 分別代表當前目錄和當前...
linux學習筆記 arp命令
arp 位址解析協議 命令用於操作主機的arp緩衝區,它可以顯示arp緩衝區中的所有條目,刪除指定的條目或者新增 靜態的ip位址與mac位址對應關係 語法 arp 選項 引數 選項 a 主機 顯示arp緩衝區的所有條目 d 主機 從arp緩衝區中刪除指定主機的arp條目 e 以linux的顯示風格顯...
Linux命令學習 gzip gunzip命令
gzip是linux上用於壓縮檔案和解壓字尾為.gz檔案的命令。gunzip就是gzip的硬連線,用於解壓被gzip壓縮的.gz檔案。所以gzip命令壓縮檔案和解壓.gz檔案可以完全搞定,gunzip只是為解壓.gz檔案提供了另一種選擇。gzip acdfhllnnqrtvv s 壓縮字尾字串 壓縮...