Windows7下arp绑定【原创】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| C:\Users\>arp -a
Interface: 192.168.1.100 — 0x14 Internet Address Physical Address Type 192.168.1.1 00-21-27-51-af-a4 dynamic #当前为动态的 224.0.0.251 01-00-5e-00-00-fb static
C:\Users\>arp -s 192.168.1.1 00-21-27-51-af-a4 #此命令在vista和Windows7下是禁止的
The ARP entry addition failed: Access is denied. C:\Users\>netsh -c “interface ipv4” netsh interface ipv4>show neighbors #查看下arp缓存 Interface 1: Loopback Pseudo-Interface 1 Internet Address Physical Address Type ——————————————– —————– ———– 224.0.0.251 Permanent Interface 11: Wireless Network Connection Internet Address Physical Address Type ——————————————– —————– ———– 224.0.0.251 01-00-5e-00-00-fb Permanent Interface 20: Local Area Connection Internet Address Physical Address Type ——————————————– —————– ———– 192.168.1.1 00-21-27-51-af-a4 Stale #网关ip-mac信息 192.168.1.113 00-00-00-00-00-00 Unreachable 224.0.0.251 01-00-5e-00-00-fb Permanent netsh interface ipv4>set neighbors “Local Area Connection” “192.168.1.1” “00-21-27-51-af-a4” #针对本地连接(此为英文系统,所以为 “Local Area Connection”,中文版的话是本地连接,一切以在网络连接那看到的为准)绑定网关ip-mac信息 netsh interface ipv4>quit
C:\Users\>arp -a
Interface: 192.168.1.100 — 0x14 Internet Address Physical Address Type 192.168.1.1 00-21-27-51-af-a4 static #已经绑定好了 224.0.0.251 01-00-5e-00-00-fb static
|
Linux下绑定IP和MAC地址,防止ARP欺骗
原文出处:http:#www.xxLinux.com/Linux/article/network/security/20070809/9234.html
一、应用背景
由于最近网上新出现一种ARP欺骗病毒,主要表现为:
中病毒的机器不仅影响自身,同时也会影响同网段的其它机器,将其它机器的HTTP数据包里加入病毒代码。代码例子如:
这种病毒危害非常大!即使你机器的安全性做得很好,可是没办法保证同网段的其它机器安全没有问题!
解决办法:
在网关和本机上双向绑定IP和MAC地址,以防止ARP欺骗。
二、约定
1、网关上已经对下面所带的机器作了绑定。网关IP:192.168.1.1 MAC:00:02:B3:38:08:62
2、要进行绑定的Linux主机IP:192.168.1.2 MAC:00:04:61:9A:8D:B2
三、绑定步骤
1、先使用arp和arp -a
查看一下当前ARP缓存列表
1 2 3 4 5
| [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
|
说明:
Address:主机的IP地址
Hwtype:主机的硬件类型
Hwaddress:主机的硬件地址
Flags Mask:记录标志,”C”表示arp高速缓存中的条目,”M”表示静态的arp条目。
1 2 3
| [root@ftpsvr ~]# arp -a ? (192.168.1.234) at 00:04:61:AE:11:2B [ether] on eth0 ? (192.168.1.1) at 00:16:76:22:23:86 [ether] on eth0
|
2、新建一个静态的mac–>ip对应表文件:ip-mac,将要绑定的IP和MAC地下写入此文件,格式为 ip mac。
1 2 3
| [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、设置开机自动绑定
1
| [root@ftpsvr ~]# echo ‘arp -f /etc/ip-mac ‘ >> /etc/rc.d/rc.local
|
4、手动执行一下绑定
1
| [root@ftpsvr ~]# arp -f /etc/ip-mac
|
5、确认绑定是否成功
1 2 3 4 5 6 7 8 9 10 11 12
| [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
|
从绑定前后的ARP缓存列表中,可以看到网关(192.168.1.1)的记录标志已经改变,说明绑定成功。
四、添加信任的Windows主机(192.168.1.10)
1、Linux主机(192.168.1.2)上操作
1 2
| [root@ftpsvr ~]# echo ‘192.168.1.10 00:04:61:AE:09:14’ >> /etc/ip-mac [root@ftpsvr ~]# arp -f /etc/ip-mac
|
2、Windows主机(192.168.1.10)上操作
1)清除ARP缓存
1
| C:\Documents and Settings\Administrator>arp -d
|
2)绑定Linux主机的IP和MAC地址
1
| C:\Documents and Settings\Administrator>arp -s 192.168.1.2 00-04-61-9A-8D-B2
|
你可以将上面2个步骤写在一个BAT(批处理)文件中,这样做的好处是,今后如果要增加其它机器的绑定,只需维护这个文件就可以了。例:
1 2 3 4 5 6
| @echo off
arp -d arp -s 192.168.1.2 00-04-61-9A-8D-B2
exit
|
注意:Linux和Widows上的MAC地址格式不同。Linux表示为:AA:AA:AA:AA:AA:AA,Windows表示为:AA-AA-AA-AA-AA-AA
五、参考文献
ARP协议揭密:http:#www.ibm.com/developerworks/cn/Linux/l-arp/
本文标题:win7及Linux下arp绑定
文章作者:凹凸曼
发布时间:2015-12-13
最后更新:2021-03-06
原始链接:https://sobaigu.com/win7-linux-arp-mac.html
版权声明:转载请务必保留本文链接和注明内容来源,并自负版权等法律责任。