VaticanUK
VaticanUK

Reputation: 1197

Set domain name for unifi DHCP server

Today I received a Unifi Security Gateway (USG) which amongst other things can act as the DHCP server for your network (in fact, it's a bit tricky to get it working just right without it being the DHCP server!)

The DHCP options in the Ubiquiti Unifi UI do not allow you to enter a domain name, but this is quite a common requirement. How can this be acheived?

I found lots of people asking this question over on the Ubiquiti forums, but no answers, so having figured it out and posted the answer there, I thought I'd share it here too

Upvotes: 2

Views: 7940

Answers (1)

VaticanUK
VaticanUK

Reputation: 1197

the trick is to look carefully at the existing config which can be done using the following commands:

configure
show

In my case, my LAN network is called LAN_192.168.0.0-16 and the subnet is called 192.168.0.0/16, so the command to set the domain name (for me!) was:

set service dhcp-server shared-network-name LAN_192.168.0.0-16 subnet 192.168.0.0/16 domain-name foo.bar

Once you have issued this command, run

show

and it will show the changes it will make to the config, which should look something like this:

 service {
     dhcp-server {
         disabled false
         hostfile-update enable
         shared-network-name LAN_192.168.0.0-16 {
             authoritative enable
             description vlan1
             subnet 192.168.0.0/16 {
                 default-router 192.168.1.1
+                domain-name foo.bar
                 lease 86400
                 start 192.168.1.100 {
                     stop 192.168.1.254
                 }
             }
         }
     }

(note the "+" showing the line that has been added)

Now, run

commit

and it will commit the changes

That's not it though... at the moment if you change any settings via the unifi UI, it will overwrite the domain name change that we just made, so you need to export the config:

mca-ctrl -t dump-cfg

copy the output and paste it into a file called "config.gateway.json" in the following folder the machine where your controller is running:

Linux:

/var/lib/UniFi/data/sites/{side id}/

Windows:

c:\users\{your user}\Ubiquiti UniFi\data\sites\{site id}

and that should do the trick :)

Upvotes: 6

Related Questions