I have personal webserver with ownCloud installed. This webserver has no public IP address because my internet connection does not offer it. I ordered virtual linux webserver with a public IP address and I use it just for port forwarding via SSH to allow my ownCloud server be accessible from the internet. Everything works fine and I am accessing the ownCloud via a hostname - example: "mytunneledowncloud.com".
But as I have limited high speed data on my internet connection, I would like to save some data by synchronizing ownCloud via LAN private IP address when I am at home and not via ssh tunneled public ip address of my virtual server. I am thinking whether this is even possible. I would need to resolve "mytunneledowncloud.com" as:
- private ip address - in case I am on home LAN
- public ip address - in case I am not on home LAN
To be honest, I know this is a bit "ridiculous" request, but maybe there is some "workaround" for it.
Note: I use Ubuntu on all my servers and PCs.
Finally I got the resolution for the "problem" and it is very simple. I followed these steps:
Now it works perfectly. My home server now acts as dhcp/dns/web server and it assigns its own private ip as a dns server to the connected LAN clients. Then clients send the requests for the DNS resolution to my home server. My home server's dnsmasq looks into its /etc/hosts whether there is an entry for the requested domain name and if there is a match, provide the IP from there and if there is no match, then it uses the "internet's" DNS servers to resolve it.