Skip to content

Instantly share code, notes, and snippets.

@g3rhard
Created May 23, 2020 11:04
Show Gist options
  • Save g3rhard/60815e340a9abda06ef9d6970bcea1be to your computer and use it in GitHub Desktop.
Save g3rhard/60815e340a9abda06ef9d6970bcea1be to your computer and use it in GitHub Desktop.
##
## Send a message to Slack on DHCP Bound
## https://github.com/massimo-filippi/mikrotik
##
## script by Maxim Krusina, maxim@mfcc.cz
## based on: http://jeremyhall.com.au/mikrotik-routeros-slack-messaging-hack/
## created: 2018-09-23
## updated: 2018-09-23
##
## usage:
## use this script as DHCP Lease Script
##
:global leaseBound
:global leaseServerName
:global leaseActMAC
:global leaseActIP
# Do the stuff on Bind
:if ($leaseBound = 1) do={
/ip dhcp-server lease {
:foreach i in [find dynamic address=$leaseActIP] do={
:local hostName [/ip dhcp-server lease get $i host-name];
:global SlackChannel "#mindless-administrating"
:global SlackMessage "New guest connected to *Wi-Fi*"
:global SlackMessageAttachements "*Host name*: $hostName\n *IP*: $leaseActIP\n *MAC*: $leaseActMAC"
/system script run "Message To Slack";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment