linux MAC地址綁定

來源:互聯網
上載者:User

1、先使用arp和arp -a查看一下當前ARP緩衝列表
[root@ftp]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.0.145            ether   00:13:20:E9:11:04   C                     eth0
192.168.0.1              ether   00:02:03:18:08:00   C                     eth0

說明:
Address:主機的IP地址
Hwtype:主機的硬體類型
Hwaddress:主機的硬體地址
Flags Mask:記錄標誌,"C"表示arp快取中的條目,"M"表示靜態arp條目。

[root@ftp]# arp -a
(192.168.0.145) at 00:13:20:E9:11:04 [ether] on eth0
(192.168.0.1) at 00:02:03:18:08:00 [ether] on eth0

2、建立一個靜態mac-->ip對應表檔案:ip-mac,將要綁定的IP和MAC地下寫入此檔案,格式為 ip mac

。
[root@ftp]# echo '192.168.0.1 00:02:03:18:08:00 ' > /etc/ip-mac
[root@ftp]# more /etc/ip-mac
192.168.0.1 00:02:03:18:08:00

3、設定開機自動綁定
[root@ftp]# echo 'arp -f /etc/ip-mac ' >> /etc/rc.d/rc.local

4、手動執行一下綁定
[root@ftp]# arp -f /etc/ip-mac

5、確認綁定是否成功
[root@ftp]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.0.145            ether   00:13:20:E9:11:04   C                     eth0
192.168.0.1              ether   00:02:03:18:08:00   CM                    eth0

[root@ftp]# arp -a
(192.168.0.145) at 00:02:B3:A7:85:48 [ether] on eth0
(192.168.0.1) at 00:02:03:18:08:00 [ether] PERM on eth0

從綁定前後的ARP緩衝列表中,可以看到網關(192.168.0.1)的記錄標誌已經改變,說明綁定成功。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.