2
Situation
I have a server on my LAN running a LAMP server, I use it for TeamSpeak, nextcloud, personal webhosting etc.
I own a domain "through" cloudflare, redirecting to my public ip address.
I access the server from the LAN and the outside.
my issue / what I want to change
Due to my server being on my LAN it has the same public ip address as my client (only when I am at home, obviously). Therefore I can't access my server because pinging my own public IP doesn't work (normal behavior, i guess).
So to overcome this problem I use my hosts-file to redirect my domain to my server's local IP address. But everytime I change position (nearly every day) I have to edit this file.
And this also works on only the few devices I can edit this file on. So on my phone (android) for example I can't access my websites or anything domain-specific.
is there any way to overcome this issue?
I actually have some ideas
- finding some way so that my public ip address is "pingable" from my LAN
- setting up a local DNS server
- different DNS zonefiles depending on the requesting ip address, if that is even possible (maybe cloudflare offers this feature). (if the requesting ip address is the same the domain redirects to, it answers with my local ip for the server)
edit (17.03.17)
I forgot to mention that I also want to use this server for mail in the future. So it has to be prepared for that.
I have now installed a DNS server on it which resolves my domain into the local IP address of the server (using bind9
; also for reverse). This works perfectly fine, but for that I had to manually set my DNS servers (the ones my computer is requesting), resulting in slower loading times (of other websites). But this is also not the perfect solution, because then someone like friends of mine can't access the server due to them not having my own DNS server in their list. Would changing the default DNS servers of my router solve this problem?
Unfortunately I have a dynamic public ip address, it changes about every three weeks. Until now I have changes my DNS entry manually, but that has to change (that's why I switched to cloudflare, they offer an API for that).
To access my server from the outside at all I had to redirect/forward some ports to it. Here is a screenshot of them:
1You need to enable hairpin NAT on your router. – EEAA – 2017-03-12T02:56:36.943
Per EEAA's comment, a link to the Wikipedia hairpinning article.
– moonpoint – 2017-03-12T03:08:02.743thanks for your answers. I googled a bit about hairpin / NAT and I found out that my router (Speedport W 724V Typ A) doesn't support it.but that would have been the ideal way :/ – Iuppiter Zeus – 2017-03-12T21:35:41.860