简体   繁体   English

Bash脚本来检查路由器的IP到Mac地址是否已从计算机更改

[英]Bash script to check if router's IP to mac address has changed from a computer

I'm trying to create a script to check if my router's IP to MAC address has changed from the view of my computer. 我正在尝试创建一个脚本,以从计算机的角度检查路由器的IP到MAC地址是否已更改。 Basically trying to check if a MITM attack is taking place. 基本上是尝试检查是否发生了MITM攻击。 I cannot get this to work; 我无法使它正常工作; the IP 172.16.213.254 is my gateway IP. IP 172.16.213.254是我的网关IP。

arp -a 172.16.213.254 | cut -d" " -f 4 >> routersmac.txt
if [[ cat routersmac.txt = "00:01:32:23:23:23"]]
then
  echo "You are safe"
else
  echo "MITM in progress"
fi

简化:

arp -a 172.16.213.254 | awk '{if ("00:01:32:23:23:23"==$4) print "OK"; else print "Bad"}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM