Resolving hostnames of all local networks

Hi. Im trying to figure out how to make openwrt propagate hostnames to three local networks (192.168.1.0, ..10.0, ..100.0). These are physical owrt routers.

I would like to be able to access the hosts in these networks by name.

Im not familiar with DNS, so after looking at the huge number of options in the settings, I went to AI for help... this is the answer:

To propagate hostnames across multiple local networks in OpenWrt, you can use the following approach:

  1. Configure DNS and DHCP: Ensure that your main router is handling DNS and DHCP for all three networks. You can do this by setting up the DHCP server on the main router to assign IP addresses and hostnames for devices in all three subnets.

  2. Edit /etc/config/dhcp: On your main router, edit the /etc/config/dhcp file to include the necessary configurations for each subnet. For example:

    config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        list dhcp_option '6,192.168.1.1'
    
    config dhcp 'lan2'
        option interface 'lan2'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        list dhcp_option '6,192.168.10.1'
    
    config dhcp 'lan3'
        option interface 'lan3'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        list dhcp_option '6,192.168.100.1'
    
  3. Set Up DNS Forwarding: Ensure that DNS requests from all subnets are forwarded to the main router. You can do this by configuring the DNS settings on each router to point to the main router's IP address.

  4. Use dnsmasq: On the main router, ensure that dnsmasq is configured to handle DNS for all subnets. You can add the following lines to the /etc/dnsmasq.conf file:

    server=/lan/192.168.1.1
    server=/lan2/192.168.10.1
    server=/lan3/192.168.100.1
    
  5. Restart Services: After making these changes, restart the DHCP and DNS services on the main router:

    /etc/init.d/dnsmasq restart
    /etc/init.d/odhcpd restart
    

By following these steps, you should be able to propagate hostnames across your three local networks and access hosts by name.

Does that make sense? It is using "option 6" which as i understand redirects requests to a specific server right?

I should point out that DOH is running on all the routers and an Intercept-DNS forward is set on the main one as well just in case (at least i think thats why i initially set it up), so presumably Ill need to disable it as well...

Thanks in advance for any pointers, not sure I trust AI to do this just yet :slight_smile:

What you desire works by default in OpenWrt. You don't need to use DHCP Option No. 6.

If you must, this setting must point to the OpenWrt as resolver (or another service that will point to it, i.e., DoH).

It does not seem to. I am able to connect to devices on a different subnet using their IP, but not their hostname...

All routers?

  • You just need 1 resolver
  • They must ultimately be configured to upstream to your main OpenWrt device (i.e. the one you showed confgs for and knows all host names)

It seems you're missing that second config point.

What happens when you dont add all these special configurations suggested by an AI?

Again, default OpenWrt resolves all hostnames without special configurations from an AI.

EDIT:

(If this doesn't work, we may need a summary diagram of the network, and configurations of all routers.)

1 Like

At least in main sourcecode, dnsmasq nowadays support multi instances for dnsmasq. Don’t know if it was released with 24.10?

That will make it possible to set up completely unique dnsmasq configs per interface.

Technically it works, but luci haven’t cought up in development yet so active leases and static leases in luci doesn’t work at all with dnsmasq multi instances.

1 Like

Apologies to everyone who chimed in, i broke by shoulder i think literally that same day!

I will look into the separate dnsmaq instances - i just started looking at pihole which i believe can be set up to do the same. Seems like a waste though for my use case, im not really interested in malware or ad protection... though it may be fun to check the dashboard, i remember years ago i quite enjoyed that part :slight_smile: