Hosting with a Dynamic IP via Dynamic DNS
ISPs typical have a large block of IP addresses that are assigned dynamically via DHCP. This means that at a specified interval set by your ISP, your IP address will change, breaking any links to your website. We can avoid this issue by setting up Dynamic DNS.
Dynamic DNS is a system where your computer or router will send a message to an outside server every time your ISP changes your IP, updating the DNS entry in a database. This way, everytime your IP changes, the record for your domain name will change so that it continues to be accessible. This means that Dynamic DNS works in two parts: The Dynamic DNS Server, which is in a static location, and keeps records as to where the clients are located. The second part is the client, which is installed on a local machine or router, and sends an update to the server any time the IP address of the client changes.
This means that when you are accessing your dynamic domain, it asking the nameserver of the dynamic dns company what the current IP is, and pointing your browser there.
Choosing a Dynamic DNS provider
This should be based on two factors: do you need a first level domain (youraddress.com, youraddress.org, etc.) or would you be happy with a second level domain (youraddress.dyndns.org, youraddress.no-ip.org, etc)?
Second Level Domain
If you are okay with a second level domain, Either No-IP or DynDNS will let you do this with a free plan. It is possible to update either company from a client on the server, but it is far easier to use functionality built into your router, so if your router supports either company natively that's probably the better way to go. Once you set up an account with either company you can go ahead and Set up an Update Client.
First Level Domain
While either company will let you register a first level domain with them, they charge you around 30 dollars a year to maintain it, and route it dynamically. If you plan on using a First Level Domain, I recommend that you buy it from an ICANN accredited retailer, such as GoDaddy (If you wait for a deal, you can get a 2 year registration for around 11 dollars) and then use ZoneEdit for the dynamic DNS functionality. ZoneEdit works somewhat differently than the other two. ZoneEdit is simply a Name Server that will accept updates from update clients. So instead of doing everything for you, it allows you to create your own Name Server entries, and just update the IP attached to them through an update client. While it requires more configuration, it means that they will dynamically update any domain that you own for free (up to two domains, then they charge you).
Registering with DynDNS or No-IP
Registering with DynDNS or No-IP is obviously just like registering with any other internet site. Know that DynDNS hides their free option in small print underneath the paid options, but it is still available. The free option is a lot easier to find on No-IP, but they ask you to certify that you will only create one free account.
During the account set-up, they may ask you for your current IP. You can obtain it at whatsmyip.org. After this initial set-up, we'll set up a client to update the server automatically.
Setting up DDNS with ZoneEdit
As I said before, ZoneEdit is a bit more difficult, though not terribly. Once you've set up an account, you can create a new zone, on the left hand pane of the member center. It will pompt you for a Zone Name. This should be the root of your domain. So if your domain is www.linuxhomeserverguide.com, then you would enter the Zone Name as linuxhomeserverguide.com. Once you've created the Zone, you will see this screen:
This is my actual entry (obviously my with my information blotted out). As you can see, you need to enter your IP address in an “A” Entry. An A entry is an absolute entry. It defines a specific IP address for a domain to point to. The @ sign stands for the root of the domain. That means that it is pointing linuxserverguide.com with no www or any other subdomain to our IP.
You see that I also create a “CNAME” entry. This is an alias, that tells the nameserver to point the subdomain to the same IP as the main domain. If you have a static IP, you can just create another A entry for it, but DDNS clients will only update the root entry for the server.
Make sure that you have chosen two separate name servers at the bottom, and write down the nameservers that you chose so that we can use them in a second.
Once you have all your settings correct, you can click Save, and then Publish Changes.
Pointing your Registrar at the Name Servers
If, as I do, You use GoDaddy.com for your domain registration needs, than all we have to do is define our nameservers in the dashboard. Once you open the dashboard there should be a button in the main section that says Name Servers. Click on this, and enter the two Name Servers you chose at ZoneEdit. Click OK, and you should be done! Don't be alarmed if your domain name doesnt immediately point to your page, it often takes GoDaddy an hour or so to register the changes.
From Here, Make sure you set up a client to keep your DDNS server up to date, and you're in business!
Setting up a Client for DDNS
As I said before, If your router supports DDNS, this is probably the easiest way to go, as all you have to do is enter your username, password, and the domain you wish to update. If you are using DD-WRT Firmware (which I thorougly recommend, by the way), then all three of the servers I discussed are suppported out of the box. You just need to go to [Setup → DDNS], choose your client, and you're in business.
If your router does not support DDNS, then you can always install a client on your server. The standard client for Ubuntu Server is ddclient. You can install it with:
sudo apt-get update && sudo apt-get install ddclient
During the install script, it will lead easily through setting up the client. You'll need to choose your DDNS provider, then provide your username and password for the server, the interface from which your server connects to the internet (eth0 for wired internet, wlan0 for wireless), and the full hostname you've chosen (For DynDNS it will be yourhostname.dyndns.org or similar, if you use ZoneEdit, it will be the name of your Zone.)
When it finishes, there is one more step we need to complete. The ddclient by default will pull the IP from your ethernet interface. This will of course give it our local IP, since you're most likely using a router, so we need to edit the /etc/ddclient.conf to change how it finds our IP. Go ahead and open the configuration file for editing:
sudo nano /etc/ddclient.conf
and replace use=if, if=eth0 with:
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
once you've finished editing the file, go ahead and check that the configuration is working by running ddclient in verbose mode:
sudo ddclient -daemon=0 -debug -verbose -noquiet
If it gives you a success code and shows the proper IP address, then your finished! The ddclient daemon will handle checking your IP against the server every so often.