Multiple search domains from DHCP server

Submitted by -
Status: New Idea

It would be nice to have an official way to set the domain-search option in dhcpd.conf. Right now the only way to configure this is by adding a subnet-parameters entry to the subnet configuration via the CLI.

Comments
by
on ‎08-15-2015 11:21 AM

Was actually just looking to do this, and was sad to find this. The DHCP server could use a few more options, like subnet based domainnames and multiple domains in the search context.

by
on ‎10-08-2015 08:15 AM
I would also like to be able to add more then one search domain to the DHCP server config. chaos215bar2, Can you give me some more information on how you are manually adding one? I've checked the /etc/dhcp folders but the config files there do not appear to be used by the router. A file path and an example would be great.
by
on ‎04-24-2017 05:48 AM

I just got bit by this one too, for any one else looking to do this manually on the CLI, just ssh to the USG, then enter these commands.

 

  1. configure 
  2. edit service dhcp-server
  3. show
    1. (find the subnet you wish to add the search domain to)
  4. edit shared-network-name <name_of_subnet> subnet <subnet_cidr>
  5. domain-name <desired_search_domain>
  6. top
  7. compare
    1. (make sure you changed what you thought you did)
  8. commit
    1. (make sure it workes the way you expected)
  9. save
  10. exit
  11. exit

Here is what it should look like

 

admin@USG:~$ configure
[edit]
admin@USG# edit service dhcp-server
[edit service dhcp-server]
admin@USG# show
 disabled false
 hostfile-update enable
 shared-network-name LAN_192.168.1.0-24 {
     authoritative enable
     description vlan1
     subnet 192.168.1.0/24 {
         default-router 192.168.1.1
         dns-server 192.168.1.10
         lease 86400
         start 192.168.1.100 {
             stop 192.168.1.254
         }
     }
 }
[edit service dhcp-server]
admin@USG# edit shared-network-name LAN_192.168.1.0-24 subnet 192.168.1.0/24
[edit service dhcp-server shared-network-name LAN_192.168.1.0-24 subnet 192.168.1.0/24]
admin@USG# set domain-name example.com
[edit service dhcp-server shared-network-name LAN_192.168.1.0-24 subnet 192.168.1.0/24]
admin@USG# top
[edit]
admin@USG# compare
[edit service dhcp-server shared-network-name LAN_192.168.1.0-24 subnet 192.168.1.0/24]
+domain-name example.com
admin@USG# commit
[ service dhcp-server ]
Stopping DHCP server daemon...
Starting DHCP server daemon...

[edit]
admin@USG# save
Saving configuration to '/config/config.boot'...
Done
[edit]
admin@USG# exit
exit
admin@USG:~$ exit
logout

 

by
on ‎06-19-2018 04:54 AM

This is already doable via the CLI without reaching for "shared-network-parameters", is it not? See the following snippet:

service {
    dhcp-server {
        disabled false
        shared-network-name test {
            authoritative enable
            subnet 10.0.0.0/8 {
                default-router 10.0.0.1
                dns-server 10.0.0.1
                domain-name "test.com test.net"
                start 10.0.0.2 {
                    stop 10.0.0.255
                }
            }
        }
    }
}

It translates to the following configuration file at "/opt/vyatta/etc/dhcpd.conf":

# generated by /opt/vyatta/sbin/dhcpd-config.pl

option space ubnt;
option ubnt.unifi-address code 1 = ip-address;

class "ubnt" {
        match if substring (option vendor-class-identifier , 0, 4) = "ubnt";
        option vendor-class-identifier "ubnt";
        vendor-option-space ubnt;
}

ddns-update-style none;

shared-network test {
        authoritative;
        subnet 10.0.0.0 netmask 255.0.0.0 {
                option domain-name-servers 10.0.0.1;
                option routers 10.0.0.1;
                option domain-name "test.com";
                option domain-search "test.com", "test.net";
                default-lease-time 86400;
                max-lease-time 86400;
                range 10.0.0.2 10.0.0.255;
        }
}

So the syntax is as follows:

domain-name "<primary> <searchdomainN> <searchdomainN+1> <etc>"

 

The first domains becomes the domain name in the dhcpd config file, the following domains become the search domains.