Answer the question
In order to leave comments, you need to log in
How to find out which user plugged the cable into the LAN router?
Good idea. Maybe someone will need this interesting solution. There are 50 subscribers connected through simple unmanaged swichs. We have Mikrotik as a server. Everyone is given a static pool of dhcp addresses, correspondingly fixed poppy addresses. A problem arises when someone inadvertently confuses the wan ports with lan on the router. So, let's go a little off topic. With personal observations of this problem, I noticed such a nuance that 99.9% of routers of all manufacturers of poppy addresses of wan and lan ports differ in the last two, and from the beginning to the last two characters are the same. And I decided to write a script that will notify who exactly confused the ports.
we hang dhcp-client on the local interface of Mikrotik, so that from the inside our local interface receives an unauthorized ip by user error.
/ip dhcp-client add interface="Local" use-peer-dns="no" add-default-route="no" script="
and let's go..:local tturlASH "https://api.telegram.org/botхххххххх:хххххххххх/sendmessage\?chat_id=хххххх&text=";
:local ttmessage "obnarujen DHCP ip na lokalke";
:local a;
:local dhcpgw;
:local arpall;
:local fmac;
:local macfound;
:local b;
:local g;
:local h;
:local i;
:local c;
:foreach a in=[/ip dhcp-client find interface=Local] do={:set dhcpgw [/ip dhcp-client get $a gateway];/ping $dhcpgw count=5};
:foreach arpall in=[/ip arp find where address=$dhcpgw] do={:set fmac [/ip arp get $arpall mac-address];:set fmac [:pick $fmac 0 ([:len $fmac]-2)]};
:foreach macfound in=[/ip dhcp-server lease find mac-address~"$fmac"] do={
/ip dhcp-server lease set $macfound comment="dhcpfound";
:foreach b in=[/ip dhcp-server lease find comment="dhcpfound"] do={
:set g [/ip dhcp-server lease get $b address];
:foreach h in=[/ip firewall address-list find address="$g"] do={
:if ($h != "") do={
:set i [/ip firewall address-list get $h comment];
/tool fetch url="$tturlASH $ttmessage %0A%0ADHCP SERVER IP ---> $dhcpgw %0A%0AADDRESS LIST ---> $i%0A%0ACLIENT IP ---> $g" keep-result=no;
} else={
:log warning message="ip not address list";
}
}
}
} else={:log warning message="not find mac-address in leases..."};
:foreach a in=[/ip dhcp-client find interface=Local] do={:set dhcpgw [/ip dhcp-client get $a gateway];/ping $dhcpgw count=5};
:foreach arpall in=[/ip arp find where address=$dhcpgw] do={:set fmac [/ip arp get $arpall mac-address];:set fmac [:pick $fmac 0 ([:len $fmac]-2)]};
:foreach macfound in=[/ip dhcp-server lease find mac-address~"$fmac"] do={
/ip dhcp-server lease set $macfound comment="dhcpfound";
:set g [/ip dhcp-server lease get $b address];
Answer the question
In order to leave comments, you need to log in
I think that on the previous question, here the question itself has disappeared, but I'll write it off anyway.
:local varIP 192.168.240.253
:if ([:len [/ip firewall address-list find address=$varIP]]>"0" ) do={
:log info ("$varIP: found");
} else={
:log info ("$varIP: not found");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question