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

My system is as follows:

  1. A wireless router at
  2. A webserver at
  3. dnsmasq running on the webserver box with the following settings: lines conf-dir=/etc/dnsmasq.d,.bak and conf-dir=/etc/dnsmasq.d,.bak uncommented in dnsmasq.conf and the additional settings


in a file in dnsmasq.d.

  1. /etc/hosts in my server looks like localhost 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

  2. The router configured to use as primary and secondary DNS.

  3. Port 53 ALLOW in ufw rules on webserver.

My webserver can ping itself using ping mydomain.tld and nslookup mydomain.tld shows it's resolving correctly to 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?

migrated from serverfault.com Apr 25 at 3:16

This question came from our site for system and network administrators.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.