diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-19 20:17:54 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-19 20:17:54 +0000 |
commit | 38cf8379b0bc991cda914c0a5c96d1dac3cff73b (patch) | |
tree | fdca30d20c57a382dea64db42d612f9512e97bde /package | |
parent | 3eb18205322ac6660904c9df5fdff50c3de9e5de (diff) | |
download | mtk-20170518-38cf8379b0bc991cda914c0a5c96d1dac3cff73b.zip mtk-20170518-38cf8379b0bc991cda914c0a5c96d1dac3cff73b.tar.gz mtk-20170518-38cf8379b0bc991cda914c0a5c96d1dac3cff73b.tar.bz2 |
dnsmasq: add support for set: and tag: pairs
On my network, I have a variety of machines and appliances, some of which need different configuration issues than the default options.
For example:
config host
option name 'client'
option mac '00:01:02:03:04:05'
option ip '192.168.1.20'
option tag 'acme'
config tag acme
option force '1'
list dhcp_option 'option:router,192.168.1.253'
list dhcp_option 'option:domain-name,acme.com'
list dhcp_option 'option:domain-search,acme.com,redfish-solutions.com'
which allows me to override the default router for my client's host, as well as its domain-name, and its domain-search.
this causes the following config lines:
dhcp-host=00:01:02:03:04:05,set:acme,192.168.1.20,client
dhcp-option-force=tag:acme,option:router,192.168.1.253
dhcp-option-force=tag:acme,option:domain-name,acme.com
dhcp-option-force=tag:acme,option:domain-search:acme.com,redfish-solutions.com
This could be useful elsewhere, for instance, if you have an IP CCTV that you don't want to have a default-route, etc.
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
SVN-Revision: 31815
Diffstat (limited to 'package')
-rw-r--r-- | package/dnsmasq/files/dnsmasq.init | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init index 33fc177..f3d438e 100644 --- a/package/dnsmasq/files/dnsmasq.init +++ b/package/dnsmasq/files/dnsmasq.init @@ -224,14 +224,32 @@ dhcp_host_add() { config_get name "$cfg" name config_get ip "$cfg" ip - [ -n "$ip" ] || [ -n "$name" ] || return 0 + [ -n "$ip" -o -n "$name" ] || return 0 macs="" config_get mac "$cfg" mac for m in $mac; do append macs "$m" ","; done [ -n "$macs" ] || return 0 - xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${ip:+,$ip}${name:+,$name}" + config_get tag "$cfg" tag + + xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}" +} + +dhcp_tag_add() { + local cfg="$1" + + tag="$cfg" + + [ -n "$tag" ] || return 0 + + config_get_bool force "$cfg" force 0 + [ "$force" = "0" ] && force= + + config_get option "$cfg" dhcp_option + for o in $option; do + xappend "--dhcp-option${force:+-force}=tag:$tag,$o" + done } dhcp_mac_add() { @@ -435,6 +453,7 @@ start() { echo >> $CONFIGFILE config_foreach dhcp_boot_add boot config_foreach dhcp_mac_add mac + config_foreach dhcp_tag_add tag config_foreach dhcp_vendorclass_add vendorclass config_foreach dhcp_userclass_add userclass config_foreach dhcp_circuitid_add circuitid |