Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F117520837
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh
index 70a563d4c..af7c86ee7 100755
--- a/src/system/on-dhcp-event.sh
+++ b/src/system/on-dhcp-event.sh
@@ -1,71 +1,73 @@
#!/bin/bash
# This script came from ubnt.com forum user "bradd" in the following post
# http://community.ubnt.com/t5/EdgeMAX/Automatic-DNS-resolution-of-DHCP-client-names/td-p/651311
# It has been modified by Ubiquiti to update the /etc/host file
# instead of adding to the CLI.
# Thanks to forum user "itsmarcos" for bug fix & improvements
# Thanks to forum user "ruudboon" for multiple domain fix
# Thanks to forum user "chibby85" for expire patch and static-mapping
if [ $# -lt 5 ]; then
echo Invalid args
logger -s -t on-dhcp-event "Invalid args \"$@\""
exit 1
fi
action=$1
client_name=$2
client_ip=$3
client_mac=$4
domain=$5
file=/etc/hosts
changes=0
if [ -z "$client_name" ]; then
logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead"
client_name=$(echo "client-"$client_mac | tr : -)
fi
if [ "$domain" == "..YYZ!" ]; then
client_fqdn_name=$client_name
client_search_expr=$client_name
else
client_fqdn_name=$client_name.$domain
client_search_expr="$client_name\\.$domain"
fi
case "$action" in
commit) # add mapping for new lease
grep -q " $client_search_expr " $file
if [ $? == 0 ]; then
echo host $client_fqdn_name already exists, exiting
exit 1
fi
# add host
/usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip"
;;
+ ((changes++))
release) # delete mapping for released address
# delete host
/usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip"
;;
+ ((changes++))
*)
logger -s -t on-dhcp-event "Invalid command \"$1\""
exit 1;
;;
esac
if [ $changes -gt 0 ]; then
echo Success
pid=`pgrep pdns_recursor`
if [ -n "$pid" ]; then
sudo rec_control reload-zones
fi
else
echo No changes made
fi
exit 0
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Sep 26, 12:31 PM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4285143
Default Alt Text
(2 KB)
Attached To
Mode
rVYOSONEX vyos-1x
Attached
Detach File
Event Timeline
Log In to Comment