<dhcpd> <opt3> <enable>1</enable> <numberoptions/> <range> <from>192.168.110.50</from> <to>192.168.110.55</to> </range> <staticmap> <mac>00:25:90:cd:0d:98</mac> <ipaddr>192.168.110.100</ipaddr> <hostname>110-100</hostname> <descr>Backup</descr> </staticmap> </opt3> <opt7> <enable>1</enable> <numberoptions/> <range> <from>192.168.245.46</from> <to>192.168.245.56</to> </range> <staticmap> <mac>c8:5b:76:4f:ae:a0</mac> <ipaddr>192.168.245.34</ipaddr> <hostname>245-34</hostname> <descr> laptop 28.11.2016</descr> <mac>c8:5b:76:4f:a4:f3</mac> <ipaddr>192.168.245.35</ipaddr> <hostname>245-35</hostname> <descr> laptop 28.11.2016</descr> <mac>50:7B:9D:E4:7B:F0</mac> <ipaddr>192.168.245.36</ipaddr> <hostname>245-36</hostname> <descr> laptop 20.12.2016</descr> </staticmap> </opt7>
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /usr/local/www/services_dhcp.php on line 1121 / 1124 /1127 /1130.
#!/bin/bash# read active ip-addr from isc-dhcp-server and write xml-structure for opnsense# etries in dhcpd.conf looks like:# host 110-100 { hardware ethernet 00:25:90:cd:0d:98; fixed-address 192.168.110.100; } # my commentdhcpin=/etc/dhcp/dhcpd.confdhcpout=$(hostname)-dhcp-4-opnsense.xmlgrep '^host' $dhcpin | while read linedo echo " <staticmap>" >> $dhcpout mac=$(echo $line | cut -d '{' -f 2 | cut -d ' ' -f 4 | cut -d';' -f 1) echo " <mac>$mac</mac>" >> $dhcpout ip=$(echo $line | cut -d ';' -f 2 | cut -d ' ' -f 3) echo " <ipaddr>$ip</ipaddr>" >> $dhcpout hn=$(echo $line | cut -d ' ' -f 2) echo " <hostname>$hn</hostname>" >> $dhcpout beschr=$(echo $line | cut -d '#' -f 2) echo " <descr>$beschr</descr>" >> $dhcpout echo " </staticmap>" >> $dhcpoutdone
#!/bin/bash# read active fixleases from /var/ipfire/dhcp/fixleases and write xml-structure for opnsense# entries in fixleases look like:# aa:00:aa:00:aa:00,192.168.0.31,on,,,,edv-pc20dhcpin=/var/ipfire/dhcp/fixleasesdhcpout=$(hostname)-dhcp-4-opnsense.xmlcat $dhcpin | while read linedo echo " <staticmap>" >> $dhcpout mac=$(echo $line | cut -d ',' -f 1) echo " <mac>$mac</mac>" >> $dhcpout ip=$(echo $line | cut -d ',' -f 2) echo " <ipaddr>$ip</ipaddr>" >> $dhcpout descr=$(echo $line | cut -d ',' -f 7) echo " <descr>$descr</descr>" >> $dhcpout echo " </staticmap>" >> $dhcpoutdone