DNS: Domain name goes to router when on the network, not the web server
Solution 1
This effect is due to hairpin NAT. https://serverfault.com/search?q=hairpin+nat
Externally the firewall/router handles it fine, but internally, you need to point at the local internal IP address.
Solution 2
The DNS name probably resolves to the external IP-address of the router, where port-forwarding rules forward the traffic to the internal IP-address of your web-server.
You need to use the internal IP-address or an internal name when on the web-server LAN or you need to implement split-DNS - configure your LAN DNS service to resolve www.example.net to the internal IP-address.
UPDATE: Or, as Joseph mentions in a comment, add an entry to the hosts
file on any PC on your office LAN that needs access to the webserver. Usually C:\Windows\System32\drivers\etc\hosts
Chad Whitaker
Updated on September 18, 2022Comments
-
Chad Whitaker over 1 year
I recently set up a web server on my office network with a domain let's say example.net
Everything works perfect outside of the network when I visit example.net, it connects to the webpage just fine.
Although when I visit example.net while on the same network as the webserver it pulls up my Comcast Business router's configuration page.
What would I need to do in order to have example.net route to the proper IP and pull up the web server and not the router.
Thank you.
-
uSlackr almost 13 yearsIt would be helpful to know what changes you made to the router to make it work externally.
-
Chad Whitaker almost 13 yearsI opened up port 80 and 443 to make the webserver work externally.
-
-
Chad Whitaker almost 13 yearsI understand. Although what could I implement on the network so that example.net would work the same on and off the local network.
-
Chad Whitaker almost 13 yearsWould this mean I would want to install a local DNS server and point my router to the local DNS?
-
Joseph Redfern almost 13 yearsThat does seem slightly... overkill. How many machines are on the network? It might be worth manually editing each machines hosts file, to make example.net point to the internal IP of the machine.
-
user5249203 almost 13 years@Chad, Joseph is right, if your office LAN doesn't have a DNS server already then there's no need to add one. Just add a hosts file entry to any PC that needs to access your web-server. The usual location on Windows PCs is C:\Windows\System32\drivers\etc\hosts (see hosts.sam for sample entries)