Community discussions

MikroTik App
 
plisken
Forum Guru
Forum Guru
Topic Author
Posts: 2509
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

script that warned me by email that a user has been added to my DHCP server

Thu Nov 16, 2017 1:53 am

Hello, I want a script that warned me by email that a user has been added to my DHCP server. Not as a wireless user but as an intruder on my network.
I have a fixed number of devices on the router board.
If there is still a device, I want this script to warn me.
Does anyone have experience with that?
thanks in advance
 
icosasupport
newbie
Posts: 29
Joined: Fri Oct 13, 2017 8:37 pm

Re: script that warned me by email that a user has been added to my DHCP server

Tue Nov 21, 2017 11:52 pm

Hello, I want a script that warned me by email that a user has been added to my DHCP server. Not as a wireless user but as an intruder on my network.
I have a fixed number of devices on the router board.
If there is still a device, I want this script to warn me.
Does anyone have experience with that?
thanks in advance
Hi plisken,
This shoud get you started, just insert it in your DHCP server script window.
Make sure you have the email configured in Tools->Email first.
:local recipient "you@mail.com"
/ip dhcp-server lease
:if ($leaseBound = 1) do={
	:do {
		:tool e-mail send to=$recipient subject="DHCP Address Alert [MAC: $leaseActMAC]" body="The following MAC address [$leaseActMAC] received an IP address [$leaseActIP] from the DHCP Server [$leaseServerName]"
		:log info "Sent DHCP alert for MAC $leaseActMAC"
	} on-error={:log error "Failed to send alert email to $recipient"}
}
Icosa.
 
PavelV
just joined
Posts: 2
Joined: Tue Jan 22, 2019 7:23 pm

Re: script that warned me by email that a user has been added to my DHCP server

Tue Jan 22, 2019 7:30 pm

Hello,
sorry for me English. This script working fine, but is possible edit for this function? All my devices in lan working with DHCP server. All devices is address reservation. Can script edit for send email, when is new devices in lan?
Thank you,
Pavel
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1071
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: script that warned me by email that a user has been added to my DHCP server

Thu Jan 24, 2019 10:21 pm

Do your own devices have static leases? If no...
/ ip dhcp-server lease make-static [ find where dynamic ]
Then replace
:if ($leaseBound = 1) do={
with
:if ($leaseBound = 1 && [ get [ find where mac-address=$leaseActMAC ] dynamic ] = true) do={
 
PavelV
just joined
Posts: 2
Joined: Tue Jan 22, 2019 7:23 pm

Re: script that warned me by email that a user has been added to my DHCP server

Fri Jan 25, 2019 6:49 pm

Hello,
super, thank you very much.
 
Qlimax
just joined
Posts: 2
Joined: Mon Apr 24, 2017 11:37 am

Re: script that warned me by email that a user has been added to my DHCP server

Mon Mar 11, 2019 1:52 pm

Does someone know how to add active host name to that script?

Who is online

Users browsing this forum: No registered users and 29 guests