DHCP, DNS and hostname problem

I am running a dns server on my router, and it serves example.com as 1.2.3.4.

I have also set the hostname to example.com. This causes a problem with dnsmasq, especially the way it is configured in openwrt. If i service dnsmasq stop and run dnsmasq in the foreground, then everything works fine - example.com is served as 1.2.3.4.

However, if I run dnsmasq on startup, example.com is served as 192.168.1.1, the value of the ipaddr option for lan in /etc/config/network, using /tmp/hosts/dhcp.configxx

How can I set the hostname to example.com without making dnsmasq serve example.com as 192.168.1.1?

You might ask why not change the hostname? I am running a mailserver as well that relies on the hostname, and if i change it something like openwrt.lan, then the mailserver won't listen/respond to mails to example.com

1 Like

Try disabling add_local_fqdn and/or add_local_hostname:
https://openwrt.org/docs/guide-user/base-system/dhcp#all_options

2 Likes

Try adding your dns server to dnsmasq dns forwardings list, and in the advanced tab enable strict order. Have you tried making an entry in the hosts file?

Thanks a lot, adding add_local_hostname 0 in the dnsmasq section at /etc/config/dhcp worked.

1 Like

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