Shell one liner to convert DHCP reservation values from Vyatta config into a Bind zone file format
DHCP reservations in the Vyatta config.boot are in the following format:
---------------8<---------------
static-mapping HOST1 {
ip-address 192.168.1.91
mac-address aa:12:34:45:67:89
}
static-mapping HOST2 {
ip-address 192.168.1.92
mac-address bb:12:34:45:67:89
}
static-mapping HOST3 {
ip-address 192.168.1.93
mac-address cc:12:34:45:67:89
---------------8<---------------
The following shell one line script will convert the above into a format suitable for inclusion in a Bind DNS zone file:
$ grep -A1 static-mapping config.boot | awk '{print$2}' | tr "\n" " " | sed 's/\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\)/\1\n/g' | awk '{print$2 "\t" $1}'
192.168.1.91 HOST1
192.168.1.92 HOST2
192.168.1.93 HOST3
Leave a comment