Script to set DHCP using System Identy

I have some radio’s out in the field that constantly check an update script. I’m trying to modify the script to remove static IP addressing and configure the radio as a DHCP client.


Here is my current script:


/ip route {remove [find address=0.0.0.0/0]}

/ip address {remove [find interface=bridge1]}
/ip address { remove [find interface=“wlan2 R52H”] }

/ip dhcp-client {remove [find interface=bridge1]}
/ip dhcp-client add add-default-route=yes comment=“” default-route-distance=0 disabled=no host-name=TestMikrotik interface=bridge1 use-peer-dns=yes use-peer-ntp=yes


Everything works fine, but here’s my dilemma. I want to reset the dhcp-client “name” value to whatever the current system ID is set to. So I want to query for the /system identity and use that value to set the name on my dhcp-client.


Any help would be appreciated.

John

Ok, I was able to answer my own question:

/ip dhcp-client {remove [find interface=bridge1]}
/ip dhcp-client add add-default-route=yes comment=“” default-route-distance=0 disabled=no host-name=[/system identity get name] interface=bridge1 use-peer-dns=yes use-peer-ntp=yes