Changeset 31815


Ignore:
Timestamp:
2012-05-19T22:17:54+02:00 (6 years ago)
Author:
jow
Message:

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@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/dnsmasq/files/dnsmasq.init

    r31814 r31815  
    225225        config_get name "$cfg" name 
    226226        config_get ip "$cfg" ip 
    227         [ -n "$ip" ] || [ -n "$name" ] || return 0 
     227        [ -n "$ip" -o -n "$name" ] || return 0 
    228228 
    229229        macs="" 
     
    232232        [ -n "$macs" ] || return 0 
    233233 
    234         xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${ip:+,$ip}${name:+,$name}" 
     234        config_get tag "$cfg" tag 
     235 
     236        xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}" 
     237} 
     238 
     239dhcp_tag_add() { 
     240        local cfg="$1" 
     241 
     242        tag="$cfg" 
     243 
     244        [ -n "$tag" ] || return 0 
     245 
     246        config_get_bool force "$cfg" force 0 
     247        [ "$force" = "0" ] && force= 
     248 
     249        config_get option "$cfg" dhcp_option 
     250        for o in $option; do 
     251                xappend "--dhcp-option${force:+-force}=tag:$tag,$o" 
     252        done 
    235253} 
    236254 
     
    436454        config_foreach dhcp_boot_add boot 
    437455        config_foreach dhcp_mac_add mac 
     456        config_foreach dhcp_tag_add tag 
    438457        config_foreach dhcp_vendorclass_add vendorclass 
    439458        config_foreach dhcp_userclass_add userclass 
Note: See TracChangeset for help on using the changeset viewer.