Code: Select all
### Static IP - Hostname - Comment / script will take host-name of all static IP's that dont have existing comments, and insert host-name into comment. will not overwrite comments.
:foreach leaseId in=[/ip dhcp-server lease find where !comment && !dynamic] do=[
:local ip [/ip dhcp-server lease get $leaseId address];
:local hostname [/ip dhcp-server lease get $leaseId host-name];
:ip dhcp-server lease set $leaseId comment="$hostname"
:log info "set Static IP $ip comment to $hostname"]