[root@server ~]# arp -a
?检查击及l脚 (103.231.15.222) at 00:00:5E:00:01:05 [ether] on eth0
? (23.154.118.254) at 0A:9D:C3:CC:81:C9 [ether] on eth0
[root@server ~]# cat /proc/net/arp
IP address HW type Flags HW address Mask Device
103.231.15.222 0x1 0x2 00:00:5E:00:01:05 * eth0
23.154.118.254 0x1 0x2 0A:9D:C3:CC:81:C9 * eth0
[root@server ~]# netstat -rn (获取网关地址)
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 23.154.118.254 0.0.0.0 UG 100 0 0 eth0
23.154.118.0 0.0.0.0 255.255.255.128 U 100 0 0 eth0
[root@server ~]# arping 23.154.118.254 (或者 arping -I eth0 23.154.118.254)
ARPING 23.154.118.254 from 43.254.218.29 eth0
Unicast reply from 23.154.118.254 [0C:C4:7A:B6:23:80] 1.949ms
Unicast reply from 23.154.118.254 [0C:C4:7A:B6:23:80] 0.814ms
Unicast reply from 23.154.118.254 [0A:9D:C3:CC:81:C9] 483.863ms (欺骗攻击的,响应时间比较长)
三:解决:arp绑定
1.首先,清空arp缓存。检查击及l脚
#arp -d 网关ip
2.找到网关真实mac地址。检查击及l脚
#arping 网关ip
3.绑定mac地址
#arp -s 网关ip 网关真实mac
如果是检查击及l脚暂时性arp欺骗攻击至此即可,如果网络中常有此问题,检查击及l脚继续以下:
4、检查击及l脚如下命令建立 /ect/ip-mac 文件
echo '网关IP地址 网关MAC地址' >/ect/ip-mac
通过下面的检查击及l脚命令查看文件是否写的正确
more /ect/ip-mac
5、arp -f /ect/ip-mac 加载静态绑定arp记录。检查击及l脚
6、如果想开机自动绑定
echo 'arp -f /ect/ip-mac' >> /etc/rc.d/rc.local
防止ARP攻击的shell脚本,使用命令route、grep、ifconfig等,需要的朋友可以参考下就不废话了,直接上代码了。
#!/bin/bashdeclare gw=`route -n | grep -e '^0.0.0.0'`declare gwname=`echo $gw | grep -oe '\w*$'`declare gwip=`echo $gw | grep -oe '[0-9]\{ 2,3\}\.[0-9]\{ 1,3\}\.[0-9]\{ 1,3\}\.[0-9]\{ 1,3\}'`declare gwmac=`arp -n | grep -e $gwip | grep -oe '[0-9A-F]\{ 2\}:[0-9A-F]\{ 2\}:[0-9A-F]\{ 2\}:[0-9A-F]\{ 2\}:[0-9A-F]\{ 2\}:[0-9A-F]\{ 2\}'`echo "switch $gwname arp: $gwip - $gwmac to static"arp -s $gwip $gwmacecho "done, off arp reuqest .."ifconfig $gwname -arpecho "all done."