Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to bind IP address and MAC address in Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to bind IP address and MAC address under Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Agreement

1. The following machines have been bound on the gateway. Gateway IP:192.168.1.1 MAC:00:02:B3:38:08:62

2. IP:192.168.1.2 MAC:00:04:61:9A:8D:B2 of the Linux host to be bound

Second, binding steps

1. Use arp and arp-a to view the current ARP cache list.

[root@ftpsvr ~] # arp

Address HWtype HWaddress Flags Mask Iface

192.168.1.234 ether 00:04:61:AE:11:2B C eth0

192.168.1.145 ether 00:13:20:E9:11:04 C eth0

192.168.1.1 ether 00:02:B3:38:08:62 C eth0 description:

Address: IP address of the host

Hwtype: hardware type of the host

Hwaddress: hardware address of the host

Flags Mask: record flag, "C" represents an entry in the arp cache, and "M" represents a static arp entry. [root@ftpsvr] # arp-a

? (192.168.1.234) at 00:04:61:AE:11:2B [ether] on eth0

? (192.168.1.1) at 0015 1622 on eth0 23 [ether] on eth0 2, create a static mac-- > ip corresponding table file: ip-mac, write the IP and MAC to be bound underground, in the format of ip mac.

[root@ftpsvr ~] # echo '192.168.1.1 00:02:B3:38:08:62' > / etc/ip-mac

[root@ftpsvr ~] # more / etc/ip-mac

192.168.1.1 00:02:B3:38:08:62 3. Set auto binding on boot

[root@ftpsvr ~] # echo 'arp-f / etc/ip-mac' > > / etc/rc.d/rc.local 4, perform binding manually

[root@ftpsvr ~] # arp-f / etc/ip-mac 5. Confirm whether the binding is successful.

[root@ftpsvr ~] # arp

Address HWtype HWaddress Flags Mask Iface

192.168.0.205 ether 00:02:B3:A7:85:48 C eth0

192.168.1.234 ether 00:04:61:AE:11:2B C eth0

192.168.1.1 ether 00:02:B3:38:08:62 CM eth0 [root@ftpsvr ~] # arp-a

? (192.168.0.205) at 00:02:B3:A7:85:48 [ether] on eth0

? (192.168.1.234) at 00:04:61:AE:11:2B [ether] on eth0

? (192.168.1.1) at 00:02:B3:38:08:62 [ether] PERM on eth0 from the list of ARP caches before and after binding, you can see that the record flag of the gateway (192.168.1.1) has changed, indicating that the binding was successful.

Add a trusted Windows host (192.168.1.10)

1. Operation on Linux host (192.168.1.2)

[root@ftpsvr ~] # echo '192.168.1.10 00 etc/ip-mac 61V AEV 09VR 14' > > / etc/ip-mac [root@ftpsvr ~] # arp-f / etc/ip-mac 2, Windows host (192.168.1.10)

1) clear the ARP cache

C:\ Documents and Settings\ Administrator > arp-d 2) bind the IP and MAC address of the Linux host

C:\ Documents and Settings\ Administrator > arp-s 192.168.1.00-04-61-9A-8D-B2 you can write the above two steps in a BAT (batch) file. The advantage of this is that if you want to add bindings to other machines in the future, you only need to maintain this file. Example:

@ echo off

Arp-d

Arp-s 192.168.1.200-04-61-9A-8D-B2

Exit Note: the MAC address format on Linux and Widows is different. Linux is expressed as: AA:AA:AA:AA:AA:AA,Windows is expressed as: AA-AA-AA-AA-AA-AA.

This is the end of the introduction of "how to bind IP address and MAC address under Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report