My DHCP server configures Gateway incorrectly and DNS does not forward queries

I needed to make some changes in my openWRT router, and reconfigure it.

IAfter doing it I have a problem: it is the DHCP server of the lan network, I have configured it as DNS server too, but it is not the gateway, the gateway is another router.

So I configured it with an ip 172.16.255.2 the DHCP server to serve IPs from IP net 172.16.0.0, net mask 255.255.0.0 and gateway 172.16.255.1 (the other router).
It is the only DHCP server in the net, the other router has no DHCP server.

But when a client gets a lease, it configures 172.16.255.2 as the gateway and not 172.16.255.1.
DNS is correctly configured as 172.16.255.2
I have checked that the lease was served by the DHC server (172.16.255.2)

Here is the configuration of the lan interface:


Obviously other setting is overriding the gateway, by I cannot find it, never happened this to me.

The DNS does not work either, it responds but do not forward DNS queries (when I use nslookup and make a local query it works, but when I try to resolve an external domain like microsoft.com it answers query refused).

This is the config, 172.16.255.2 is configured as the DNS server in DHCP, as I want to resolve first local queries for domain .home.
So in lan interface adapt oprtions I did not add any DNS.

And in DHCP and DNS config (I am using default dnsMasq as dhcp and dns server):

I cannot find what is wrong either.
Thank you for your help, I've been trying to solve it all the day.

https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
router = gateway.

2 Likes

Thank for the answer.
I have already read the documentation, but it did not help me, because I cannot find what is wrong in my config.
Besides it does not describe the LUCI interface options, only the config files that are quite obscure for me.

I meant the gateway is the device directly connected to the internet where all forwarded packets with no local destination should be sent. I this case is propoerly a gateway as it connects two differente medium, ethernet and fiber.
It has router capabilities too, but is only use for internet connection (well and as access point).

The router does internal net packets distribution (for now there is only one lan, but I am going to create another one soon for iot devices).
Mainly it is the DHCP and DNS server but traffic to internet should be directed to the other device (what I was calling the gateway).

That was what I meant with "router" and "gateway".

It has been working for many time, but I had a problem with the router and had to reset.
Now I have forgotten something that I cannot find, and the DHCP clients are configured with the DHCP server as gateway, instead of the gateway I have put in the interface.

So in the lan interface of the DHCP server I have put the IP of the other device (gateway, 172.16.255.1) as ipV4 gateway.

I cannot find any other place in the DHCP Luci config interface where you can put the gateway/router to serve to the DHCP clients.

In the DNS section I have configured two well known external DNS servers that I have tested are reacheable from the router and from the internal lan. But it does not seem to forward the requests.
Obviously, some parameter is missing.

This is the response I get using nslookup from a PC connected to the lan:

C:\Users\ferna>nslookup
Servidor predeterminado:  routerSalon.casa
Address:  172.16.255.2

> routersalon.casa
Servidor:  [172.16.255.2]
Address:  172.16.255.2

Nombre:  routersalon.casa
Addresses:  fdf3:d760:bc14::1
          172.16.255.2

> microsoft.com
Servidor:  routerSalon.casa
Address:  172.16.255.2

*** routerSalon.casa no encuentra microsoft.com: Query refused
> server 208.67.222.222
Servidor predeterminado:  [208.67.222.222]
Address:  208.67.222.222

> microsoft.com
Servidor:  [208.67.222.222]
Address:  208.67.222.222

Respuesta no autoritativa:
Nombre:  microsoft.com.casa
Addresses:  52.85.187.67
          52.85.187.93
          52.85.187.121
          52.85.187.127

> quit

As can be seen, it answers internal .casa domain queries, but does not seem to forwared queries for other domains using the configured dns forwareders.
That dns forwareders are accesible from the net, as can be seen using the server command to stablish one of them as dns query and making a query.

I think you need to pass an option through with DHCP. Option 3 is a change for the default gateway for DHCP and there is a place in the DHCP server on LuCi to put that in.

It is not visible if you have configured the upstream dns servers. Network/Interfaces/Edit LAN/ Advanced Settings tab -> Use custom DNS servers
Then go to DHCP Sever tab, Advanced Settings subtab, in DHCP-Options add 3,172.16.255.1
Save and apply changes.

1 Like

Thank you both and specially @trendy. It seems that the problem is mostly solved.
Option 3 has solved the DHCP issue, now client DHCP gets the correct gateway.

I have used the same dns servers in the interface config page and the dns server forwarders config (I don't understand why you have to put them twice, may be you don't need to put them as forwarders?)

Now it works, nslookup works from the connected PCs to th lan.

But it seems there remains a slight problem

If I connect to the router using ssh and make a nslookup query from ther, it responds with the correct IPs, but allways ends with error messages.
It seems that after querying the dns forwarders it makes other query that fails, as there remained some other dns that is not working.

Let me put an example . This is the query run in the router connecting through ssh:

root@routerSalon:/etc# nslookup www.1and1.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:      www.1and1.com
Address 1: 74.208.255.133
*** Can't find www.1and1.com: No answer
root@routerSalon:/etc#

root@routerSalon:/etc# nslookup microsoft.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:      microsoft.com
Address 1: 40.113.200.201
Address 2: 104.215.148.63
Address 3: 13.77.161.179
Address 4: 40.76.4.15
Address 5: 40.112.72.205
*** Can't find microsoft.com: No answer
root@routerSalon:/etc#


It does not happen in all domains.

The DNS forwardings configuration you have is wrong, delete them. Keep only the custom DNS servers entries in LAN interface.

It is the non existing AAAA IPv6 record. Nothing wrong there.

1 Like

Thank a lot, it seems I had misunderstood that dns forwareder were.

I will delete them, then.

Now it seems that openwrt activates IPv6 nameserver by default.
Until now I just ignored IPv6. But may be time I learn a bit about IPv6, as it is getting quite more common, and activated by default in MS windows too.

Some easy tutorial about IPv6 and how to configure openWRT to support it? At a basic level, as documentation in openWRT about it is too deep for me.

It is suppose to not have the problems with assigning IPs, just get a ramdon part of address for your entire internet (be higher part of the addresses) and then the dhcpv6 would give the devices the other part of the 128 bit address. But don't understand how routing or other tasks work.

IPv6 is by default enabled and will work with most common settings. If you are not sure about something, you can open a new topic here.

2 Likes

Thanks, for now I dont't really need IPv6, and as you say new installations of openWRT configured DHCPv6 automatically, it is strange to write nslookup and get the answer for such a large IPv6 address...

Just wanted to know how IPv6 works and the differences in routing and address assigments.
I read about it some years ago, but the info I found was quite obscure an complex.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.