Forwarding hostnames across subnets

I have 2 networks each with their own internet. 10.0.0.0 and 192.168.1.0 networks. I have static routing configured to share files and the plex media server. The only way I can connect to any device that is on a different subnet is by using the IP address. Hostnames don't work nor do they show up under My Network. Hostnames only show up and work if they are devices on the same subnet. How can I forward the hostnames back and forth across the routers so the hostnames can be properly resolved? Both routers use Openwrt.

Use the DNS which knows the host names as upstream DNS ?

Or use one DNS for both.

I don't quite follow or understand the concept I guess. Can I get an example of what you mean?

One of the DNSes knows the host names, the other one doesn't, right ?

Use the one who knows, as upstream DNS to the one that doesn't.

[clueless DNS]->[knowing DNS]->8.8.8.8 or whatever.

There are devices on both subnets. They each have their own modem for internet as well. Router 1 can see all hostnames of devices on router 1. Router 2 can see all hostnames of devices on router 2. They just can't see hostnames of each other. I have to manually type in IPs to access devices on the other router regardless of which subnet I am on.

Can you show a diagram of what you described?

Lastly, what prevents you from configuring the DNS on Routers 1 and 2 as @frollic noted:

?

Bump
Anyone have any guidance?

Lets say one router has domain lan1 the second router lan2.
In lan1 dhcp you add:
server=/lan2/ip-address-of-lan2-dns-server

In lan2 dhcp add:
server=/lan1/ip-address-of-lan1-dns-server

Disable rebind protection

Disable local-service

2 Likes

Will try that when I get home from work. Thanks

1 Like

Hmm. Not working for me. It could be an IP address issue.

Router 1 is 10.0.0.1 and has a dns of 192.168.1.1 (modem) (fixed IP can't be changed)

Router 2 is 192.168.1.1 and has a dns of 192.168.0.1 (modem)

The modem for Router 1 was acquired later down the road after the static routing was already configured.

Would I have to change the IP of Router 2?

IPs don't matter, as long as you correctly setup static routing for 10.0.0.0/24 and 192.168.1.0/24 on each router.

What prevents the following:

R2(DNS 10.0.0.1) -> R1(DNS 8.8.8.8 or any other DNS resolver with Internet connection)

Caveat, this method means all Internet lookups use the Internet of Router/Modem 1.

The method described here should work specifically for your local issue.

Feel free to share the configs you entered in the /etc/config/dhcp file.

1 Like

Yea each router has its own internet connection.

I've tried variations of ips for the dns servers. I know the dns server matches the the gateway ip (router) on the local devices so it's set to that right now.

10.0.0.0/24 router

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option local '/lan/'
	option domain 'lan1'
	option rebind_protection '0'
	option localservice '0'
	option serversfile 'server=/lan2/192.168.1.1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv6 'server'
	option ra 'server'
	option ra_management '1'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

192.168.0.0/24 router

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option ednspacket_max '1232'
	option local '/lan/'
	option domain 'lan2'
	option rebind_protection '0'
	option localservice '0'
	option serversfile 'server=/lan1/10.0.0.1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'

Not sure if that syntax is correct.
That is where you set the path/filename to a file with additional servers.

To set just one server use Forwards > DNS Forwards and then it will look like:
list server '/lan2/192.168.1.1'

Like this?

config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option local '/lan/'
	option domain 'lan1'
	option rebind_protection '0'
	option localservice '0'
	list server '/lan2/192.168.1.1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv6 'server'
	option ra 'server'
	option ra_management '1'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'


config dnsmasq
	option domainneeded '1'
	option localise_queries '1'
	option expandhosts '1'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option ednspacket_max '1232'
	option local '/lan/'
	option domain 'lan2'
	option rebind_protection '0'
	option localservice '0'
	list server '/lan2/10.0.0.1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'
	option loglevel '4'


Yes that is how it works for me :slight_smile:

I restarted both routers. Maybe this will just take time to work. Who knows? Lol or I'm just cursed. At least it works for you!

This line should use lan1 instead of lan2.

1 Like