say my name

DNS – Part 1 – My DNS Server

Problem

The fully qualified domain name (FQDN) of the server my website is served by is ugly (joaolino83.dynip.sapo.pt), I want a prettier one (joaolino.com).

I’m serving my website off a personal server, using apache2, PHP and mySQL that has a dynamic IP address. My telecom operator (where I work my day job) does not have the option of fixed IPv4, which would greatly simplify things as far as this article goes. In terms of cost, I have the domain name (joaolino.com) and the electric bill – running the server.

I love doing stuff low cost, everything has to be strictly necessary and elegant. At least that’s my take on in.

Solutions

There are a few to consider:

  1. Have GoDaddy serve my website;
  2. Make GoDaddy’s DNS point to my server;
  3. Make GoDaddy forward DNS requests to a DNS that points to my server.

Option 1: Have GoDaddy serve my website

This one costs money and GoDaddy and I have a history now:

  • The service is not great – just the other day GoDaddy’s domain name service (DNS) went down and clients got a “hey sorry” type of reply; after years of service my account gets “limited access” and I can’t configure a thing until I check my email (lovely);
  • Sneaks into my pocket – You get a lot of basic stuff sold in separate instead of packaged in a “Basic” package. I love low cost but compromising experience is just bad for everybody. Getting your credit card in and out of you pocket, metaphorically, just sucks.
  • Service goes down and everything is green – I have the A Lean Fox being server from GoDaddy and just yesterday hosting went down again. I was looking at the hosting configuration, the site was down and the GoDaddy interface was a beautiful and soothing green.

GoDaddy hosting, never again!

Option 2: Make GoDaddy’s DNS point to my server

There is a way to do this, GoDaddy basically has to do two things:

  1. Pose as the DNS server for my domain (joaolino.com);
  2. Update the DNS records when the dynamic IP changes.

On my side, I have to provide GoDaddy with an FQDN that constatly points to my dynamic IP address. This FQDN allows GoDaddy to check if there is a different IP address for that FQDN and update the joaolino.com records.

This is not a perfect solution, although my provider is lightning fast updating the IP address for my “dynamic” FQDN. (joaolino83.dynip.sapo.pt)

Although GoDaddy supports this, guess what, my credit card has to come out again. Now I start thinking “will it happen again a bit further in the configuration?”, “is the quality any good?”, “why can’t there be a trial?”, “this is so basic, even I could do it and have fun in the process…”

Let’s enjoy life, let’s have fun!

Option 3: Make GoDaddy forward DNS requests to a DNS that points to my server.

First off, GoDaddy does not charge for this. Buying a .com domain costs money and with it you get to choose the DNS server that will resolve the domain name. Thing is, DNS servers can come in the form of an IP address or a domain name.

Using my “dynamic” FQDN (joaolino83.dynip.sapo.pt) as a DNS server FQDN for my domain name (joaolino.com) will result in all DNS traffic from the Internet to be sent to my server. My server then only has to know it’s IP address and repply it as the location of the domain name (joaolino.com).

To make this work, I need to

  1. Install, configure and operate automatically my own DNS server;
  2. Make it match the served IP address with the public server’s dynamic IP address.

I’ll go with this approach. Don’t get me wrong, it also has cons because:

  • It is complex
  • May require maintenance
  • There is no redundancy
  • Guaranteed very shot periods of downtime

The thing is, these cons are also present in GoDaddy’s solutions and having my own solution is more fun, free, truthful and is guaranteed to work as long as I want it to.

Implementation: Setting up the DNS server with a dynamic IP address

Check out this post.

Final touches

Now that everything is setup, all I need to do is route the dns traffic through my network, to the LXC container where the DNS server is running on, and I’m ready to go.

Since I’m doing this on Linux, ipTables is the best way to do this. I just add the following rules where dns packet relaying is required and I’m done.

-A FORWARD -d 10.0.3.101/32 -p udp -m udp --dport 53 -j ACCEPT
-A PREROUTING -p udp -m udp -d 192.168.0.101 --dport 53 -j DNAT --to-destination 10.0.3.101:53

Conclusion

Check out joaolino.com 🙂

Leave a Reply