Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bulk Insert of active EdgeOS dhcp leases into /etc/hosts aka regenerate entries in /etc/hosts
## do this before hand
## vyatta will try to eval show under the wrong circumstances
show dhcp leases > /tmp/leases.txt
### dump below in a file, execute with bash
MY_INTERNAL_DOMAIN=your_internal_domain.local
IFS=$'\n'
for line in $(printf "$(cat /tmp/leases.txt|tail -n +3|awk '{print $6, $1, $2}')")
do
client_name=$(echo $line|awk '{print $1}')
client_ip=$(echo $line|awk '{print $2}')
client_mac=$(echo $line|awk '{print $3}')
dumb_command="/opt/vyatta/sbin/on-dhcp-event.sh commit $client_name $client_ip $client_mac $MY_INTERNAL_DOMAIN enable no"
eval "$dumb_command"
done 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.