Adding a name to DNS

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Mon Sep 19, 2022 6:53    Post subject: Adding a name to DNS Reply with quote
Router: Netgear XR500
Firmware: DD-WRT v3.0-r50146 std (09/10/22)

I'm not sure if this is an issue with this particular router, or even the chipset of the router, or even this build of dd-wrt, but more than likely this is just me doing something incorrectly. I just got this router and got it configured. Previously, I was using an about 8 year old Buffalo router with the stock dd-wrt firmware that came with it, so I'm sure a lot has changed, but I've tried to configure the new router as closely as possible to the old one.

I'm trying to add an address to DNSMasq so that it will resolve from any of my machines. For example sakes, let's say the name I want is mycustom.local and the address I want it to resolve to is 192.168.1.25.

I've added the following line to the Services->Dnsmasq Infrastructure->Additional Options text box as follows:
Code:
address=/mycustom.local/192.168.1.25

And that is followed by some other options for the DNS address info for my visitor network.

After applying changes or rebooting the router, I see this option in the "/tmp/dnsmasq.conf" file below my static leases. Here's a snippet of that file:
Code:

...
dhcp-host=48:E2:44:XX:XX:XX,SONYBRAVIA,192.168.1.210,1440m
dhcp-host=44:67:55:XX:XX:XX,BHYVE,192.168.1.211,1440m
bogus-priv
conf-file=/etc/rfc6761.conf
clear-on-reload
dhcp-option=252,"\n"
cache-size=1500
address=/mycustom.local/192.168.1.25
interface=wlan1.1
dhcp-option=wlan1.1,3,172.16.1.1
dhcp-range=wlan1.1,172.16.1.100,172.16.1.200,255.255.255.0,12h


My problem is that the name does not resolve anywhere, including if I ssh into the router and try to ping it:
Code:

root@MYROUTER:~# ping mycustom.local
ping: bad address 'mycustom.local'


What am I missing? There are obviously a lot more dnsmasq options in the GUI than there were in my old router.

Sponsor
matjazk
DD-WRT User


Joined: 21 Aug 2019
Posts: 120
Location: Here, There And Everywhere

PostPosted: Mon Sep 19, 2022 7:07    Post subject: Reply with quote
Why don't you use a static lease for this purpose?
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Mon Sep 19, 2022 10:59    Post subject: Reply with quote
If you want the router to have a domain name its in services tab under DHCP Server Setup and fill in LAN Domain field. Used Domain should be switched LAN & WLAN
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12837
Location: Netherlands

PostPosted: Mon Sep 19, 2022 11:40    Post subject: Reply with quote
Do not use .local
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
kalrez
DD-WRT Novice


Joined: 28 Jan 2022
Posts: 39

PostPosted: Mon Sep 19, 2022 12:53    Post subject: Reply with quote
DNS Naming works 100% on my XR500. Follow the Instructions on previous Posts for DHCP server setup (under services tab) Also helps to give Static leases. Make sure your Network devices have a name setup in their own hardware pages.
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Mon Sep 19, 2022 20:23    Post subject: Reply with quote
matjazk wrote:
Why don't you use a static lease for this purpose?


It's just an alias to another device that is already getting a static lease. The device at that address forwards to the proper device I want via a port forward. So, I want to keep the names separate in case my approach changes in the future.

It used to work in my old router and I'm just curious why it isn't working now.
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Mon Sep 19, 2022 20:46    Post subject: Reply with quote
There are obviously ways to work around this, but I was just curious why it used to work on my old router, but is not working on the new router. Seems like that's exactly what the "address" DNSMasq option is for.

I'll try to describe in a bit more detail what I'm doing. I have a second dd-wrt router that plugs into my main network and that router has all my IoT devices and security cameras. The IoT device in question is managed by HomeAssistant/ESPHome which resides on my main network. When it compiles a new version of the sensor code, it then tries to do an OTA update by connecting to a particular port, i.e. "mycustom.local:1234" which should point to my second router that has a port forward setup to the actual device.

So, yes, I could hard code the address of the 2nd router in the source code of the sensor, but I preferred to give it a unique name that would resolve to that address should I change methodologies in the future.

It's not a huge deal and it's easily worked around, but I was just curious as to why the "address" option doesn't seem to be getting picked up anymore.
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1899

PostPosted: Tue Sep 20, 2022 0:58    Post subject: Reply with quote
The address option is for domain names, not specific hosts, isn't it?

Dnsmasq man page wrote:
-A, --address=/<domain>[/<domain>...]/[<ipaddr>]
Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a domain, use repeated --address flags. To include multiple IP addresses for a single query, use --addn-hosts=<path> instead. Note that /etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.net domain to some friendly local web server to avoid banner ads. The domain specification works in the same way as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive. As for --server, one or more domains with no address returns a no-such-domain answer, so --address=/example.com/ is equivalent to --server=/example.com/ and returns NXDOMAIN for example.com and all its subdomains. An address specified as '#' translates to the NULL address of 0.0.0.0 and its IPv6 equivalent of :: so --address=/example.com/# will return NULL addresses for example.com and its subdomains. This is partly syntactic sugar for --address=/example.com/0.0.0.0 and --address=/example.com/:: but is also more efficient than including both as separate configuration lines. Note that NULL addresses normally work in the same way as localhost, so beware that clients looking up these names are likely to end up talking to themselves.

_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
M2
DD-WRT Novice


Joined: 08 Oct 2020
Posts: 1

PostPosted: Tue Sep 20, 2022 3:19    Post subject: Reply with quote
If I understood your post right. Hopefully this will help.

https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

--host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-address>][,<TTL>]
Add A, AAAA and PTR records to the DNS. This adds one or more names to the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may appear in more than one --host-record and therefore be assigned more than one address. Only the first address creates a PTR record linking the address to the name. This is the same rule as is used reading hosts-files. --host-record options are considered to be read before host-files, so a name appearing there inhibits PTR-record creation if it appears in hosts-file also. Unlike hosts-files, names are not expanded, even when --expand-hosts is in effect. Short and long names may appear in the same --host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100



Long version/examples:

Code:
host-record=GatewayAX.lan,GatewayAX,192.168.3.1,fe80::bd0d:13ff:fe3a:7b9f
host-record=OpenWRT.lan,OpenWRT,192.168.3.2,fe80::f81e:6cff:fe5d:cf01
host-record=DDWRT.lan,DDWRT,192.168.3.3,fe80::3b95:a4ff:feae:5ffe
host-record=OpenWRTx86.lan,OpenWRTx86,192.168.3.4,fe80::119b:25ff:feb9:c1d2
host-record=Sony-TV.lan,Sony-TV,192.168.3.240,fe80::7277:81ff:fe24:40fd


Code:
ping Sony-TV.lan
Pinging Sony-TV.lan [fe80::7277:81ff:fe24:40fd%8] with 32 bytes of data:
Reply from fe80::7277:81ff:fe24:40fd%8: time=4ms
Reply from fe80::7277:81ff:fe24:40fd%8: time=7ms
Reply from fe80::7277:81ff:fe24:40fd%8: time=3ms


Code:
ping -4 Sony-TV
Pinging Sony-TV.lan [192.168.3.240] with 32 bytes of data:
Reply from 192.168.3.240: bytes=32 time=4ms TTL=64
Reply from 192.168.3.240: bytes=32 time=7ms TTL=64
Reply from 192.168.3.240: bytes=32 time=6ms TTL=64


You can have multiple host-record entries. IPV6 ips are optional.

.local is mostly meant (understood) to be used for mDNS. So in my example it's automatic and it ends up being something like android.local or XBRmodelnumber.local or LGWebOS.local while .lan I define myself if it's needed
Code:

ping -4 Android.local

Pinging Android.local [192.168.3.240] with 32 bytes of data:
Reply from 192.168.3.240: bytes=32 time=4ms TTL=64
Reply from 192.168.3.240: bytes=32 time=8ms TTL=64
Reply from 192.168.3.240: bytes=32 time=8ms TTL=64
Reply from 192.168.3.240: bytes=32 time=6ms TTL=64




Same can be done via hosts file.

Code:
fe80::7277:81ff:fe24:40fd   Sony-TV.lan Sony-TV Sony-TV-Whatever-LL-6.lan
192.168.3.240   Sony-TV.lan Sony-TV


The first entry should be resolved as default.

DNSMASQ is pretty awesome and extensible. But it does require some experimenting as there's multiple versions and half the time I don't even understand it still. I have entries for IoT lights and other random stuff where needed. Including on locked down TP-Link routers thanks to nice people who keep fixing the old & mutilated versions of OpenWRT that most OEMs love to use.

I use an identical setup on different versions of OpenWRT/DDWRT for myself and friends. So it's possible there's an even simpler solution but this allows me to quickly make changes regardless of what the actual gateway is and whether or not I have access to it (boingo wifi, comcrap modem, etc). By simply plugging in a an opened up router and uploading a dnsmasq.conf/etc/hosts or adding some entries WebUI. Even if it's only as a wifi client. Then use my own DNS/VPN. Or reverse of that by connecting to a router located in a place in Germany which has access to US Hulu/Netflix along with local European services and content. Very useful when I find myself in europe... This probably makes the studios rather unhappy, but good luck blocking residential ips in any country and sharing is caring Wink
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Thu Sep 22, 2022 0:40    Post subject: Reply with quote
Your "Additional Options" syntax for adding an address to dnsmasq looks fine and I use this heavily all the time. Try dropping the .local as egc suggested (egc knows networking).

When you ssh into dd-wrt what does cat /etc/resolv.conf show?

What does nslookup mycustom show?

What does nslookup mycustom 192.168.1.1 show? (use your own dd-wrt address if not 192.168.1.1)

I don't see why something this generic that worked no longer works on a different router.
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Thu Sep 22, 2022 2:33    Post subject: Reply with quote
yoyoma2 wrote:
Your "Additional Options" syntax for adding an address to dnsmasq looks fine and I use this heavily all the time. Try dropping the .local as egc suggested (egc knows networking).


Yes, he certainly does! I changed it to be mycustom.iot instead of using the .local and it all works now as expected.

Seems somewhere over the last 8 years, ".local" has become persona non grata for this use Razz
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1899

PostPosted: Thu Sep 22, 2022 3:52    Post subject: Reply with quote
Using .local isn't advised, however, did you have the domain name set in the webUI on the Services -> Services tab under DHCP Server Setup?

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=329964

_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Thu Sep 22, 2022 13:02    Post subject: Reply with quote
dale_gribble39 wrote:
Using .local isn't advised, however, did you have the domain name set in the webUI on the Services -> Services tab under DHCP Server Setup?


I wasn't using ".local" as my lan domain. I was just using it for that one device. My lan domain is something different (bhprivate.net) and that's what's set in the UI field. I was just using ".local" because it was a local name for a device that resides on another network (behind my second router).

Good info in the wiki link from that post you point to:
https://wiki.dd-wrt.com/wiki/index.php/DNSMasq_as_DHCP_server
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum