Updating the Name of static IP/MAC mapping is not allowed in the GUI and there is no easy way to do these changes in bulk. With the approach below, you can also update the assignment of IP and organise things to your hearts content.
- Format the existing mapping into a tab delimited format in the order of Name, IP and MAC. You can get the existing mapping by downloading the config file.
- Copy the entries from config.boot file.
static-mapping name1 {
ip-address 192.168.0.49
mac-address xx:xx:xx:xx:xx:xx
}
static-mapping name2 {
ip-address 192.168.0.126
mac-address xx:xx:xx:xx:xx:xx
}
- Convert this to tab delimited format using Sublime text or Notepad.
name1 192.168.0.49 xx:xx:xx:xx:xx:xx
name2 192.168.0.126 xx:xx:xx:xx:xx:xx
- Tweak the bulk import code (script.x) from here using the order of your leases.txt, LAN name and subnet.
ubnt@router:
~$
vi script.x
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
while read name ip mac
do
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 static-mapping $name ip-address $ip
set service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 static-mapping $name mac-address $mac
done < leases.txt
commit
save
exit
- Paste the tab delimited text.
ubnt@router:
~$
vi leases.txt
- Delete the existing static mapping.
ubnt@router:~$delete service dhcp-server shared-network-name LAN subnet 192.168.0.0/24 static-mapping
- Run the script.
ubnt@router:
~$
sh script.x