Domain name isn't available on local network, but outside it is!

In our local network we have an Ubuntu Server 20.4, where it hosts a web application. I configured my router and the DNS of the domain, I installed Lets'Encrypt certificate and I have succeed that to show my web application.

My issue is that when I try to see the domain from inside the local network, the browser responds that `This site can’t be reached, but when I am connected outside the site is visible.

I have to apply a new setting in the Ubuntu Server or this is a router's configuration matter?

One solution...

I edited hosts file in my pc (C:\Windows\System32\Drivers\etc\hosts) adding a record

192.168.0.100 mydomain.com

and the site is visible now, but I would like to know how can I apply a setting to Ubuntu server.

Edit 1If I run nslookup mydomain.com from the command line of Windows I get:

Server: one.one.one.one
Address: 1.1.1.1
Non-authoritative answer:
Name: mydomain.con
Address: My_External_IP

Both Ubuntu Server and my PC are on the same subnet. I have added some port forwards (80, 443) to the router, in order to make public the server.

4

1 Answer

Well the "problem" is that your Windows machine (and other machines on your network) resolves to the domain name to a public IP address, which is different than 192.168.0.100... Thus the routing is different. When you try to access 192.168.0.100 the traffic stays inside your LAN. If you use a public IP address then your traffic will transit on the Internet and come back to you through the router.

So indeed you should set up port forwarding on your router, so that incoming requests to ports 80 & 443 are forwarded to the local address of the server, that is 192.168.0.100 in your example.

If you had your own DNS resolver in your LAN, then you could simply configure that domain (the "zone") locally to return a private IP address instead, only for local users. See split-horizon DNS.

Editing the hosts file may be acceptable for testing, short-term usage, if you don't have many clients to maintain. Otherwise my suggestion would be to set up a local DNS resolver (and forwarder) for your LAN. Example: dnsmasq.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like