Community discussions

MikroTik App
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 511
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Export DHCP Server Lease Table

Thu Apr 30, 2015 2:22 am

I'm trying to copy the dhcp lease table into a spreadsheet. I can't find a way to copy it. Can this be done?
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Export DHCP Server Lease Table

Thu Apr 30, 2015 7:29 pm

I would run a script that outputs a CSV formatted list that you can copy/paste into a text document, save as myFile.csv, and then open that in Excel.

Example:
/ip dhcp-server lease
:foreach i in=[find] do={
	:put ([get $i address].",".[get $i mac-address].",".[get $i client-id].",".[get $i server])
}
To get all the options, I do something like this. Copy/paste this into the terminal:
/ip dhcp-server lease
:foreach i in=[find] do={
	:put ([get $i 
Then, press TAB a few times until the list of options shows up:
/ip dhcp-server lease> :foreach i in=[find] do={
{... :put ([get $i                                                            
active-address      agent-circuit-id  comment        lease-time       status     
active-client-id    agent-remote-id   disabled       mac-address      use-src-mac
active-mac-address  always-broadcast  dynamic        radius           value-name 
active-server       block-access      expires-after  rate-limit       
address             blocked           host-name      server           
address-list        client-id         last-seen      src-mac-address
...which you can then use to select which options you want to have in your CSV file. Just edit the first script to include the ones you want.
 
tabate47
Long time Member
Long time Member
Topic Author
Posts: 511
Joined: Wed Mar 13, 2013 5:23 am
Location: Los Angeles

Re: Export DHCP Server Lease Table

Fri May 01, 2015 8:56 am

That is great! Thank you very much. It's exactly what I was looking for.