Sunday 15 September 2013

Publishing your Raspberry Pi web server with Dynamic DNS

This is actually for any home web server, but I'm doing my blog mostly for the Pi. I doubt many people have anything else running a web server at home, and I REALLY wouldn't want anyone running a web server on a PC unless you want every security problem there is.

Back to doing it on your Pi. Here's how to have your own domain name, or a host on someone else's, pointing to a web server that's running on a private IP address behind your broadband router. I'm not going into the details of name servers, A/CNAME/@ records here, because if you don't know them then you shouldn't be fiddling with them.

For now, this tutorial just gives you a A name server record for a host. Note, when using other free/shared domain names such as linkto.me then you won't be able to have the hostname www but you can pick something else. If you have your own domain, you can have both www hostname and domain pointing to your dynamic DNS service.

Dynamic DNS


There are a few free dynamic DNS services, just Google for one you like. I personally used www.no-ip.com though I have used others in the past. No-IP have a variety of services, the free and simple DNS hosting is what I went for. You can select from a list of free domains and just add your own host, or you can pay for a domain, or host a domain you already own.

Following the instructions on the no-ip website, it only took a few minutes to set up and choose a hostname. Then select which domain to put it under, either one of their free ones, one of their paid ones, or one of your own.

Note your hostname including the domain name, username, and password you created on no-ip.com

My router has dynamic DNS built in, so it was a simple matter of entering the options on the router. Put your no-ip (or other dynamic DNS service) details into the section on the router, and it will take care of the rest. When the router gets a different IP address, for example if you turn it off and back on, it will update the dynamic DNS servers and your web server will still be published on the net.

Be aware, DNS changes can take between 24-48 hours to propogate through the internet, particularly if you are using a newly registered or transferred domain. Using the no-ip free host and domain was instant though.

Then you need to set port forwarding to your Pi, which is why your Pi should have a static address. Port forwarding on home routers usually comes under the heading of application sharing. Simply forward port 80 (http) to the internal IP address of your Pi, or web server.

You can also forward other ports, like ftp and others - but be aware of the security implications as each port added means another layer of security needed.

If your router doesn't support dynamic DNS then you need to install a client on the web server. Each one is different depending on who's service you use. So you'll need to follow their instructions.

No comments:

Post a Comment