What's new

DNSmasq to provide DHCP IP # and DNS name for systems on LAN

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

GraniteStateColin

New Around Here
I am new to ASUS and Merlin, but I've used DD-WRT for years. If I SSH into the Asus router (RT-AX86U Pro), I see that I can add lines to dnsmasqconf in /etc or dnsmasq.conf.add like:

address=/<system name>/192.168.100.101

And that if I do that, then all systems on the LAN can access <system name> by name w/o needing to know the IP#. That's perfect and exactly what I want for things like printers and other devices that don't make their names visible on the network like Windows computers do.

However, back in DD-WRT, there was a way to do this via the GUI in a single step like in the screen shot below: enter MAC, name that should be accessible from the network, IP address to assign it via DHCP. That was it. Just enter those 3 bits of information per system and it was done.
1694641330783.png


Is there any way to do this on the Asus router? I entered the same info, but it only assigned DHCP, entering the Host Name field didn't seem to do anything:
1694641619896.png


The above does not resolve DNS requests. The DHCP part of DNSmasq works through the GUI, but apparently not the DNS part, at least not for me yet. Should this work in the Merlin/Asus firmware like it did in DD-WRT? If so, is there another setting I have to make, or maybe I'm putting this in the wrong place?

If the only option is to do it via the dnsmasq.conf file and not via the GUI, is there a single line that sets up both the DHCP and DNS at the same time, or will I always need both, like:
dhcp-host=9C:8E:##:##:##:##,set:9C:8E:##:##:##:##,hp_printer,192.168.XX.XX
address=/hp_printer/192.168.XX.XX

If I must go that route, I can and it seems to work. I'm just hoping for a more elegant, and ideally GUI controlled solution. I know the real IT guys prefer the CLI, but I'll access this so rarely, and only make changes when a network device changes (about 1-3 times per year), that I'll have to look up everything to work at the CLI every time, but I can use the GUI cold every time without having to look stuff up in my notes. So, if possible, I prefer to do these via the GUI like I could in DD-WRT.

Thanks for any tips!
 
It is probably wise to either use the manual IP reservation method in the router's GUI (LAN - DHCP Server) or in the dnsmasqconf in /etc or dnsmasq.conf.add but not both (or all three).

You may need to check other settings like what you have configured for the LAN DNS servers. And the DHCP IP address scope range.

[Wireless Router] How to manually assign IP around the DHCP list?

Make sure to select the Yes option for Enable Manual Assignment.
f25b9bd3-a9ed-439d-b280-385dd68cec6b.png


No problem using the Manual IP Assignment initially on my RT-AX86U Pro router. Host names are resolved correctly. Since move to using YazDHCP for the exta feature(s) it provides.
 
What's your DNS servers setup in LAN section? The default is DNS proxy serving router's LAN IP as DNS to clients.

I currently have that assigned to the Asus router itself. I think that part is working, because if I manually modify the dnsmasq.conf file, it does properly provide the naming. So the router must be serving up DNS to the network. The problem for me is that I would prefer to enter the MAC/IP #/network name in the GUI instead of in the dnsmasq.conf file. Do you think there's a way to do that, or maybe that was a unique feature of the DD-WRT firmware?
 
Obviously it should work through the GUI or those options wouldn't be there. Remove all the other things you've done via the command line and just use the GUI.
 
The problem for me is that I would prefer to enter the MAC/IP #/network name in the GUI

You can do that, but for local host resolution to work you have to use your router as DNS server. This is the default setting and you don't have to enter anything in LAN DNS fields. Set local domain name as well. You don't need to modify any files. Use the GUI only. Don't get confused by Client Name and Host Name. Two different things stored in different places.
 
It is probably wise to either use the manual IP reservation method in the router's GUI (LAN - DHCP Server) or in the dnsmasqconf in /etc or dnsmasq.conf.add but not both (or all three).

You may need to check other settings like what you have configured for the LAN DNS servers. And the DHCP IP address scope range.

[Wireless Router] How to manually assign IP around the DHCP list?

Make sure to select the Yes option for Enable Manual Assignment.
f25b9bd3-a9ed-439d-b280-385dd68cec6b.png


No problem using the Manual IP Assignment initially on my RT-AX86U Pro router. Host names are resolved correctly. Since move to using YazDHCP for the exta feature(s) it provides.

Yes, that is set to "Yes", same is an your picture. Note that I don't have any problem with IP#'s. That works fine. The problem is the naming for DNS resolution. For example, we have several printers. For accessing those printers, we want new PC's to be able to connect to them directly, but we don't want to have to remember that a printer is 192.168.1.10 or 192.168.1.11, we want to just list it as hp.printer or brother.printer. In DD-WRT, that putting a name in the "Host Name" column would cause the DNSmasq system to use that for DNS resolution (see the top of the two pictures I posted).

Is there any way to do that on an Asus router through the GUI? If the answer is 'no', I'll just stick with doing it via dnsmasq.conf edts, but I'm hoping to avoid that.

(oh and to your point that I should only do it one place, yeah, the actual file ends up being the dnsmasq.conf.add file, because any changes made directly to dnsmasq.conf get erased when the dnsmasq service restarts)
 
In DD-WRT, that putting a name in the "Host Name" column would cause the DNSmasq system to use that for DNS resolution (see the top of the two pictures I posted).

The same in Asuswrt.
 
Obviously it should work through the GUI or those options wouldn't be there. Remove all the other things you've done via the command line and just use the GUI.

I only dug into the command line because it did not work from the GUI. Is there another setting needed to get it to use those host names in its DNS resolution?
 
The same in Asuswrt.

How? As far as I can tell, it doesn't work. Works fine if I modify the dnsmasq.conf file, but it ignores the names in the GUI. See my screenshots above. The one in DD-WRT works. The one on the ASUS yields no name resolution when I try to access that from a PC, unless I add the address=/<system name>/IP# to the dnsmasq.conf file. Then it works fine.
 
No. In your example the host name is hp_printer. As the post above notes, make sure you have also set a valid domain name.

OMG, I'm so sorry and I feel like an idiot!! OK, so there's still an issue, but it's a little different from what I originally said.

Modified question: is there any way to include dots in the names in the GUI? Currently, it prevents entering dots. I could use them in DD-WRT and I can enter them in the dnsmasq.conf file, but not in the Asus GUI.

If you try to use a dot in the name, Asus responds with, "At least two characters. Only alphanumeric characters, underscore, and dash symbols are accepted. The first character cannot be a dash - or a underscore _."

This matters because we have dozens of systems already set up (from our DD-WRT days) to look for hp.printer (and many other names). So while you are absolutely correct (and I was wrong, because I'd forgotten how this started) that hp_printer works, it doesn't actually solve the real problem I have.

Again, sorry for losing track of my own question at the outset.
 
No, because technically hostnames cannot contain dots as that is the separator character for FQDNs.

Yes, but, as internal names, these could be different domains, all the way to TLDs (either like our .printer, or I could add our own company domain to the end -- .printer.ourco.com or printer.local, etc.). Originally, we managed this via our own DNS servers on a Windows domain, but we've recently stopped that (it was overkill for our small company), moved our systems to Azure and cut a lot of cost and management time.

Oh, well, at least we resolved this issue. So periods can't be in the names in the GUI, but can via the dnsmasq.conf file and that's easier to understand as a definitive rule. Because of the way we had set everything up from DD-WRT, I guess we'll just have to use the dnsmasq.conf file edits and I'll need to find a way to document that so it's quick and easy to make that change every time it's needed.

This is still all much better than modifying the hosts file on every PC, which was the leading internal suggestion. :)

Now I understand the issue and the reasoning. From one Colin to another, THANK YOU!
 
either like our .printer, or I could add our own company domain to the end -- .printer.ourco.com or printer.local,

printer.local is actually a problem, as .local is reserved for mDNS...

working with dnsmasq - you have a lot of options, but also consider that hostnames/TLD's do matter, and improperly done, it will break things like avahi/bonjour and samba (for netbios).

I do maintain a list of reserved items such as hostnames and other parametrics/use cases - they're not specific to AsusWRT, but they're good guidance, and I try to keep that list current...


I'm not saying you have to follow the guidance presented, but as a developer, I do suggest you at least read it thru...
 
Yes, but, as internal names, these could be different domains, all the way to TLDs (either like our .printer, or I could add our own company domain to the end -- .printer.ourco.com or printer.local, etc.). Originally, we managed this via our own DNS servers on a Windows domain, but we've recently stopped that (it was overkill for our small company), moved our systems to Azure and cut a lot of cost and management time.

Oh, well, at least we resolved this issue. So periods can't be in the names in the GUI, but can via the dnsmasq.conf file and that's easier to understand as a definitive rule. Because of the way we had set everything up from DD-WRT, I guess we'll just have to use the dnsmasq.conf file edits and I'll need to find a way to document that so it's quick and easy to make that change every time it's needed.

This is still all much better than modifying the hosts file on every PC, which was the leading internal suggestion. :)

Now I understand the issue and the reasoning. From one Colin to another, THANK YOU!

If you're trying to break the spec, don't expect the GUI to do it for you.

Set a domain on the router such as ourco.com. Then name your devices using proper format (technically underscore is out of spec but it works, but definitely no dots). This works perfectly fine for me 100% of the time. If you need to be able to do external lookups (against public dns) for ourco.com, then use lan.ourco.com or intra.ourco.com on the Asus so that only those stay local and the rest get forwarded upstream.

If you want multiple subdomains, you need to do it via the CLI and scripts, or addons (not sure if yazdhcp can do this). Overkill for a small network though.
 
If you're trying to break the spec, don't expect the GUI to do it for you.

Set a domain on the router such as ourco.com. Then name your devices using proper format (technically underscore is out of spec but it works, but definitely no dots). This works perfectly fine for me 100% of the time. If you need to be able to do external lookups (against public dns) for ourco.com, then use lan.ourco.com or intra.ourco.com on the Asus so that only those stay local and the rest get forwarded upstream.

If you want multiple subdomains, you need to do it via the CLI and scripts, or addons (not sure if yazdhcp can do this). Overkill for a small network though.

Yes, it's really subdomains that are the issue. I do understand that's not really needed for our small network. They were added for convenience only, but we could achieve the same thing just using naming conventions: like instead of hp.printer, where printer is a subdomain of our onsite local domain, we could just flatten it and use names like hp_printer or printer_hp without the intermediate subdomain of printer. I.e., there is effectively no risk of a separate hp.phone, and even if there is a conflict like that, with our small network, we can manage those in other ways.

While it would force us to rename network connections (especially for printers) on a lot of network systems, as you and others have pointed out, this is probably a cleaner solution and therefore more easily managed in the future, so maybe worth the one-time pain of re-doing all the local systems, changing the hp.printer -> hp_printer, etc. Then, we would have simple GUI management through Asus/Merlin WRT. Because it seems DD-WRT is no longer actively being developed for modern routers, this would probably be a wise change on our end.
 
Yes, it's really subdomains that are the issue. I do understand that's not really needed for our small network. They were added for convenience only, but we could achieve the same thing just using naming conventions: like instead of hp.printer, where printer is a subdomain of our onsite local domain, we could just flatten it and use names like hp_printer or printer_hp without the intermediate subdomain of printer. I.e., there is effectively no risk of a separate hp.phone, and even if there is a conflict like that, with our small network, we can manage those in other ways.

While it would force us to rename network connections (especially for printers) on a lot of network systems, as you and others have pointed out, this is probably a cleaner solution and therefore more easily managed in the future, so maybe worth the one-time pain of re-doing all the local systems, changing the hp.printer -> hp_printer, etc. Then, we would have simple GUI management through Asus/Merlin WRT. Because it seems DD-WRT is no longer actively being developed for modern routers, this would probably be a wise change on our end.

Just an update for anyone else who stumbles on this. We did go ahead and rip off the band-aid so to speak, eliminating all the dot naming that had worked fine through DD-WRT. So, where before we had subdomains of printer, phone, and some media objects, we have flattened all of those and just use the prior subdomains as part of the names, like hpcp5525_printer, hpclj4550_printer, konica_printer, brother_printer, etc.

This took a fair amount of work to fix port assignments on PC's, but it was a one-time change that should not be needed ever again. All new systems will get the proper (no dot) names from the dnsmasq entries. Good enough.

Thanks for the help!
 
Just an update for anyone else who stumbles on this. We did go ahead and rip off the band-aid so to speak, eliminating all the dot naming that had worked fine through DD-WRT. So, where before we had subdomains of printer, phone, and some media objects, we have flattened all of those and just use the prior subdomains as part of the names, like hpcp5525_printer, hpclj4550_printer, konica_printer, brother_printer, etc.

This took a fair amount of work to fix port assignments on PC's, but it was a one-time change that should not be needed ever again. All new systems will get the proper (no dot) names from the dnsmasq entries. Good enough.

Thanks for the help!

Hate to break it to you but underscore is not valid in DNS/bind spec. It works fine with many (most from what I've seen) systems but you may very well change to another router someday that doesn't like it.
 
Hate to break it to you but underscore is not valid in DNS/bind spec. It works fine with many (most from what I've seen) systems but you may very well change to another router someday that doesn't like it.
Yes, underscores can be problematic. Even if routers handle them in DNS names, not all hosts can. Probably not a problem in this particular situation, but QNAP NASs (as of a couple years ago, at least) could not have underscore in their host names and could not talk with other hosts (such as Synology NASs) whose names contained underscores. Not likely that a QNAP NAS would need to talk with one of those printers, but ya never know.

If it becomes problematic you can give dnsmasq some CNAME records to map the names with underscores to complaint names so picky hosts can access them.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top