I have a home server hosting a small website that I want to be able to access by name from within my LAN. Outside the LAN everything works fine, but my router does not support NAT hairpinning and, seemingly as a result, I cannot resolve my domain name from inside the LAN. I am trying to set up dnsmasq to resolve my domain to its local IP, and forward all other requests to, say 22.214.171.124.
My system is as follows:
- A wireless router at 192.168.2.1
- A webserver at 192.168.2.100
dnsmasq running on the webserver box with the following settings: lines
dnsmasq.confand the additional settings
domain-needed bogus-priv listen-address=127.0.0.1 listen-address=192.168.2.1 listen-address=192.168.1.1 domain=mywebsite.com expand-hosts local=/mywebsite.com/ no-dhcp-interface=enp2s0f0 no-resolv no-poll server=126.96.36.199 server=188.8.131.52
in a file in
/etc/hostsin my server looks like
192.168.2.100 MyServerName mydomain.tld
The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
The router configured to use 192.168.2.100 as primary and secondary DNS.
- Port 53 ALLOW in
ufwrules on webserver.
My webserver can ping itself using
ping mydomain.tld and
nslookup mydomain.tld shows it's resolving correctly to 192.168.2.100. But nslookup from any other machine on the network gives back the external IP of my website, and no other machine can ping my webserver at mydomain.tld from insider the LAN.
I feel my setup is close in principle but that either I'm missing something obvious, or something needs to be restarted or reloaded in order to get things working. I have tried flushing the dns cache of another machine on the LAN, and still nothing. Suggestions?