Hey! I’ve made a little tool that makes creation DHCP Option 43 for Ruckus and UniFi Access Points way more easy.
With the tool you can encode an IP address for your RUCKUS SmartZone or ZoneDirector controller and UniFi, or decode an existing Option 43 string to figure out what ip address is behind the string.
And it even give in some examples for setting it up on Cisco IOS, MikroTik, or dnsmasq. Want to try it ? Head over to https://www.d0wn.com/option_43.php and check it out!
Category: Networking
MikroTik Script to Resolve Bridge Host IPs and Hostnames
This script for MikroTik RouterOS maps bridge-connected devices by linking their MAC addresses to IP addresses and hostnames. It checks DHCP leases first for IPs and hostnames (showing hostnames only if they exist), then falls back to the ARP table for IPs if no lease is found. Devices without matches in either DHCP or ARP are skipped, displaying results like “interface=ether1 mac=00:11:22:33:44:55 ip=192.168.1.10” or adding “hostname=pc1” when available.
{
:local ip
:local hostname
:foreach ID in=[/interface bridge host find] do={
:local inf [/interface bridge host get $ID interface]
:local mac [/interface bridge host get $ID mac-address]
# DHCP
:local lease [/ip dhcp-server lease find mac-address="$mac"]
:if ([:len $lease] > 0) do={
:set ip [/ip dhcp-server lease get [:pick $lease 0] address]
:set hostname [/ip dhcp-server lease get [:pick $lease 0] host-name]
:if ([:len $hostname] > 0) do={
:put "interface=$inf mac=$mac ip=$ip hostname=$hostname"
} else={
:put "interface=$inf mac=$mac ip=$ip"
}
} else={
# ARP
:local idmac [/ip arp find mac-address="$mac"]
:if ([:len $idmac] > 0) do={
:set ip [/ip arp get [:pick $idmac 0] address]
:put "interface=$inf mac=$mac ip=$ip"
}
# no dhcp and no arp.
}
}
}
the output will look someting like that
/tool fetch url=”http://d0wn.com/host.rsc” mode=http ; /import host.rsc
status: finished
downloaded: 1KiB
total: 1KiB
duration: 1s
interface=ether05-CAM-PLACE mac=00:12:31:11:XX:XX ip=192.168.1.102 hostname=LocalHost
interface=ether03-SALON mac=00:90:27:E8:XX:XX ip=192.168.1.90 hostname=proxmox
interface=ether03-SALON mac=02:B9:B5:D3:XX:XX ip=192.168.1.13 hostname=homeassistant
interface=ether06-PC mac=30:9C:23:0E:XX:XX ip=192.168.1.25 hostname=PC1
interface=ether02-CUISINE mac=3C:61:05:30:XX:XX ip=192.168.1.22 hostname=bedroom
interface=ether02-CUISINE mac=3C:61:05:32:XX:XX ip=192.168.1.17 hostname=kitchen
interface=ether03-SALON mac=48:8F:5A:22:XX:XX ip=192.168.1.3 hostname=AP-Livingroom
interface=ether02-CUISINE mac=48:8F:5A:71:XX:XX ip=192.168.1.4 hostname=AP-Kitchen
interface=ether03-SALON mac=64:90:C1:01:XX:XX ip=192.168.1.18
interface=ether01-GW mac=6C:61:F4:33:XX:XX ip=192.168.1.1
interface=ether01-GW mac=8C:AA:B5:05:XX:XX ip=192.168.1.12 hostname=shellyem-05D60F
interface=ether03-SALON mac=9C:9D:7E:3F:XX:XX ip=192.168.1.10 hostname=Xiaomi
interface=ether03-SALON mac=A0:B7:65:56:XX:XX ip=192.168.1.11 hostname=salon
interface=ether03-SALON mac=BC:DF:58:57:XX:XX ip=192.168.1.87 hostname=Tele
interface=ether01-GW mac=C4:AC:59:4C:XX:XX ip=192.168.1.21 hostname=Client
interface=ether02-CUISINE mac=C4:AC:59:50:XX:XX ip=192.168.1.20 hostname=Client
interface=ether03-SALON mac=D4:53:83:5D:XX:XX ip=192.168.1.19 hostname=Client
interface=ether03-SALON mac=E4:5F:01:E8:XX:XX ip=192.168.1.100 hostname=nvr
Script file loaded and executed successfully
Using the REST api to read sensors on Home assistant
During one of my little project of making timelapses videos with some IP cameras, I had the following problem : How do you stop capturing new images at night when the camera see nothing,
After all , the sun rise and sun set time are changing everyday ! and i didn’t see a simple way to calculate this.
then i remembered the sun.sun integration in Home assistant.
If i had a simple way to query this integration in my script , i could very simply stop my script when the sun was no longer present in the sky !
The Home assistant REST API
In any home assistant installation there is access to a REST API that lets you do a lot a things , but in my case, I don’t want much , I just want to know if the sun is above or below the horizon.
- Get a Authorization: Bearer token
you first have to generate a token to authenticate your request . You have to go to your user section , this is the circle a the bottom of the toolbar, then at the bottom of the page , you can create a long term token ,
Please take note of this token because Home assitant can only display it one time , if you loose it , you must recreate an other one. - Then in my script i can use this
- it will return either above_horizon or below_horizon, I can then use this in my script to stop the capture when it’s below_horizon
I used jq filter the json result , but , if you can’t or don’t want to install it , you can replace it with this simple awk