Hi,
I notice that in RouterOS 7.x.. the UI includes a column for “Bridge Port”
How do I get this listed in terminal?
Neither of these seems to include it in the results:
/ip/dhcp-server/lease/print
/ip/dhcp-server/lease/print detail
Seems useful to help me get which CAP interface a particular DHCP client is associated with.
Jotne
January 26, 2022, 7:10am
2
This is clearly a bug on 7.1.1 and 7.2.rc1. Please report this to support@mikrotik.com
I did try to find it and its not in termial.
:put [/ip dhcp-server/lease get *1 ]
active-address address-lists block-access dhcp-option-set insert-queue-before queue-type src-mac-address
active-client-id agent-circuit-id blocked disabled last-seen radius status
active-mac-address agent-remote-id client-id dynamic lease-time rate-limit use-src-mac
active-server allow-dual-stack-queue comment expires-after mac-address routes value-name
address always-broadcast dhcp-option host-name parent-queue server
“Bridge Port” that are shown in Winbox are not to find in CLI
:put [/ip dhcp-server/lease get *1]
.id=*1;
active-address=172.16.1.254;
active-client-id=1:0:50:79:22:68:3;
active-mac-address=00:50:79:22:68:03;
active-server=dhcp1;
address=172.16.1.254;
address-lists=;
blocked=false;
client-id=1:0:50:79:22:68:3;
dhcp-option=;
disabled=false;
dynamic=true;
expires-after=00:07:24;
host-name=VPCS1;
last-seen=2m36s;
mac-address=00:50:79:22:68:03;
radius=false;
server=dhcp1;
status=bound
mane
February 16, 2022, 12:36pm
3
Same here, hap ac3 with 7.1.2 and half of leases are without a bridge port in DHCP Server > Leases
Hi,
has this bug been fixed yet?
has anyone managed to fix it?
With version 7.6 it still persists,
:put [/ip dhcp-server lease get value-name=bridge-port number=[/ip dhcp-server lease find address=192.168.88.15]]
Output:
input does not match any value of value-name
/ip/dhcp-server/lease/pr detail terse where address=192.168.88.15
Output:
0 D address=192.168.88.15 mac-address=6C:C7:EC:49:6A:70 client-id=1:6c:c7:ec:49:6a:70 address-lists= server=dhcp-bridge dhcp-option= status=bound expires-after=57m29s last-seen=2m31s active-address=192.168.88.15 active-mac-address=6C:C7:EC:49:6A:70 active-client-id=1:6c:c7:ec:49:6a:70 active-server=dhcp-bridge host-name=Galaxy-S8
In Winbox if this field appears:
BR.
Jotne
December 2, 2022, 12:39pm
5
Should be easy to fix, så MT please fix.
I have written an email to support but have had no response.
BR.
No solution? A pity that no one from Mikrotik even responds.
Thank you.
Jotne
December 13, 2022, 10:41am
8
Normal its the other way around. You see some in CLI that are not shown in WinBox.
This should be easy to fix, but since 7.7 are in RC state, I guess it will not be fixed in 7.7 version.
mrz
December 13, 2022, 11:41am
9
Winbox just like in many other places just takes the info from somewhere else, in this case it just compares the lease mac address with bridge host table entries and shows the port.
Hello,
I share with you my script with the solution to obtain the “bridge-port” that appears in Leases and that is obtained from the Bridge Hosts table.
The script is located in my DHCP-Server and works correctly.
:if ($leaseBound = 1) do={
:do {
:local deviceName [/system identity get name];
/ip dhcp-server lease
:local hostName [get value-name=host-name number=[find address=$leaseActIP]]
:local Comment [get value-name=comment number=[find address=$leaseActIP]]
/interface/bridge/host
:local interFace [get [find mac-address=$leaseActMAC] on-interface]
# START Send Telegram Module
:local MessageText "\E2\84\B9 <b>$deviceName: Info DHCP</b> %0D%0A Name: $hostName \
%0D%0A IP: $leaseActIP %0D%0A MAC: $leaseActMAC %0D%0A Interface: $interFace %0D%0A $Comment"
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
$SendTelegramMessage MessageText=$MessageText
# END Send Telegram Module
:log warning "DHCP Alert: $hostName [ $leaseActMAC ] is connect to $interFace"
} on-error={:log error "Telegram notification failure"}
}
BR.
Jotne
December 13, 2022, 8:05pm
13
Here is my version that I may implement in the Splunk to get all active DHCP leases with bridge port.
It injects the bridge-port inn to the dhcp lease array.
/ip dhcp-server lease
:foreach id in=[find where [:typeof $"active-address"]="ip"] do={
:local dhcplease "$[get $id]"
:local mac "$[get $id active-mac-address]"
:local bridgeport
:do {
:set $bridgeport [/interface bridge host get [find mac-address=$mac] interface]
} on-error={
}
:set ( "$dhcplease"->"bridge-port" ) "$bridgeport"
:put "$dhcplease"
}
@rextended
I did not see any way around the on-error on this, since not all mac address do have a bridge port.
But if you have any idea, they are welcome
I check but…
while I read the rest… this??? (I understand why…)
[find where active-address~"."]
is this…
[find where [:typeof $"active-address"]="ip"]
for coherence must be used active-mac-address and not mac-address than on static lease can be altered later…
also, for the same reason, must be checked real “on-interface” than “interface”…
Jotne
December 13, 2022, 9:54pm
15
Thanks rextended, script updated.
Ehhh…
/ip dhcp-server lease
:foreach id in=[find where [:typeof $"active-address"]="ip"] do={
:local activeMAC [get $id active-mac-address]
:local if "undefined"
:local outstring "undefined"
/interface bridge host
:local searchresult [find where mac-address=$activeMAC]
:if ([:len $searchresult] > 0) do={
:set if [get $searchresult on-interface]
:set outstring "For bridge host table the $activeMAC is coming from $if"
} else={
:set outstring "Not find any result on bridge host table with MAC $activeMAC"
/ip arp
:set searchresult [find where mac-address=$activeMAC]
:if ([:len $searchresult] > 0) do={
:set if [get ($searchresult->0) interface]
:set outstring "$outstring, but for ARP table $activeMAC is coming from $if"
} else={
:set outstring "$outstring, neither on ARP table."
}
}
:put $outstring
}
The previous script is updated, because on ARP table is possible have multiple results for more than one IP for same MAC, and I fix the probable error.
Tested only on v6.
Cleaned again, removed inconsistencies and tested on v7.
If you tried the script before reading this, use the new version.
My script check also the ARP table, because not everytime the DHCP server is on one bridge…