0

I am trying to create my own Dynamic DNS Server. I would like to remotely access my owncloud and apache webserver running on my RaspberryPi at home. My ipv4 is not public, but I have ipv6 setup and publicly accessible.

I have a cloud based host (rpi.myownddns.abc) - running apache - from which I am planning to run my Dynamic DNS Service. Till now I:

  1. created a myip.php page on rpi.myownddns.abc which stores my current ipv6 address in a text file (currentIP.text) on the webhost (my rpi has a bash script (ddns update client) which contacts myip.php with my eth0 ipv6 address every hour).

  2. created an index.php page on rpi.myownddns.abc which redirects me to the latest updated ipv6 address.

index.php

<?php
$myFile = "currentIP.txt";
$fh = fopen($myFile, 'r');
$theIP = fread($fh, filesize($myFile));
fclose($fh);
//echo $theIP;
header('Location: https://['.$theIP.']');
?>

Whenever I visit rpi.myownddns.abc I am redirected to my home server ipv6 as expected. However the URL looks something like https://[20a2:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]/.

What I would like is to have my url show as rpi.myownddns.abc/owncloud for example, similar to what you get from ddns providers (ex noip). How do I achieve this?

I tried with apache mod_rewrite, but only managed to achieve the same redirect as with php. I checked into mod_alias, but this seems to require a domain name, and not an ip address.

Any help or pointers are appreciated. Thanks.

SimLun
  • 1
  • 1
  • Are you actually _creating_ a DNS service, for instance something written in C, Rust, Go, etc., are you _using_ an existing DNS service, or are you just creating a webpage that redirects to an IP address? I cannot quite tell from your question. – Chris Haas Sep 25 '20 at 17:16
  • Hi Chris. No nothing written in C or any other language. At most I would like to use php or maybe apache rewrites. The idea is to emulate what happens with dynamic dns provider such as no-ip. Say for example I have SimLun.ddns.net as a no-ip.com host. When I type that into my browser, I get to my home server. However the url will be simlun.ddns.net, and not my ip address. How is that done? I can only manage the redirection with my ip address in the address bar – SimLun Sep 25 '20 at 18:57
  • Okay, that makes sense. First, it is very important to understand then that you are **not** doing DNS in any way. DNS is a much lower-level protocol. You are 100% HTTP at this point, and browsers cannot use what you are using for DNS at all. Second, browsers are able to turn a name into an IP, however they will never do the reverse because there really is no registry of such a thing (ignoring PTR records). To have the browser actually show a domain name, you need to truly update the DNS records in the public internet, you can't just redirect in HTTP. I would look for a free Dynamic DNS service – Chris Haas Sep 25 '20 at 20:01
  • Thanks Chris. So I will have to dig deeper into DNS and see how I can make this work. I already use a free Dynamic DNS service. However these have their limits. My workplace blocks them, and the one I use does not seem to have a client which automatically updates ipv6. It's a good opportunity to learn something new :) I searched a bit and found this project. http://arkanis.de/weblog/2015-11-27-build-your-own-dyndns . I'll have a look into it. Can you please suggest some sources where I can learn more about DNS? Thanks again. – SimLun Sep 25 '20 at 20:20
  • You mention in your question that you connect to your could web site and are redirected to your home site. And you want that to happen without the domain name in the browser to change, right? Then setup a proxy on your cloud web site. When your browser asks for your cloud domain, the apache proxy will act as a client and talk to your home site. What your home site responds will be sent back to you. So from your browser's perspective, only your cloud web site wsa contacted. – Nic3500 Sep 26 '20 at 05:21
  • **Point 1**: be careful with this, I personally know 2 instances of IT employees being fired for circumventing corporate security like this. **Point 2**: look into mod_proxy. **Point 3**: redirections should be viewed as "I don't know, talk to this other guy". Proxy should be viewed as "wait, I'll ask him and let you know what he said". **Point 4** finaly, mod_alias maps URLs to filesystem directories. It is self contained, so nothing to do with redirections. – Nic3500 Sep 26 '20 at 05:23
  • Thanks for the pointer and for the explanation @Nic3500. After some research about it, mod_proxy sounds exactly like what I initially had in mind. However, I forgot to mention that my cloud based web hosting service is a commercial product (not under my control), and unfortunately it does not seem to have that module installed :( – SimLun Sep 26 '20 at 08:34
  • I may have managed a solution, but I'm not sure if it's long term. In cPanel on my webhost there is a DNS Management section. In there I created a CNAME entry for my subdomain, pointing to my no-ip hostname, which after some time started to point at my home ip. This seems to work. I also tried a different route where I created an AAAA entry pointing directly to my ipv6 address bypassing no-ip. This does not work yet (maybe ttl?). Ideally I would use the AAAA method but then find a way how to update the ip address when it changes. I'll post development, but thank you for any suggestions. Thanks – SimLun Sep 26 '20 at 11:51

0 Answers0