8

I just bought a raspberry pi and made it a web server. I have a network with 1 IP. I created a DMZ and I am able to access my raspberry pi web server from the internet. I bought a domain that I intend to use for my web site but I found that I need to create some name servers(primary and secondary) and provide IPs for those name server to those from which I bought my domain name.

My questions are: Can I have my DNS server and my web site using the same IP? Is it really needed to have a secondary name server(as I have only one IP I don't think I could have a secondary name server)? What is it to be done next? Should I install a DNS server on my raspberry and configure it? Can I have my website up and running with just 1 IP and 1 raspberry pi? How can I achieve all of these things(having my website on my raspberry up and running and my domain name pointing to it)?

Thanks!

1

5 Answers 5

14

There's nothing wrong with having two services go to the same IP address, as long as the destination ports do not conflict with one another.

In this case, you would be using port 53 for DNS, and port 80 for your web server.

You can also have both (or all) of your nameservers set to the same IP address.*

You will need to set up an authoritative DNS server on your raspberry pi, then let your registrar know the IP addresses of your nameservers, and delegate authority of your domain to your dns server.

*It goes against normal recommendations, but it is possible.

9
  • 1
    Upvoted to counter a down you got. This is borderline because it runs counter to RFC 2182. Still, this user is clearly just getting started and this is a reasonable compromise to make when you really have just 1 IP at your disposal.
    – dmourati
    Aug 8, 2014 at 7:36
  • 1
    Absolutely. It's dodgy. I do it at home, simply because I want to test things... Eg. WebApps that interact with an authoritative BIND server (I can't do that when my DNS is hosted with my registrar) Aug 8, 2014 at 7:37
  • dmourati: sorry, what? Which bit of RFC2182 do you think this violates?
    – MadHatter
    Aug 8, 2014 at 7:41
  • 5
    Well, having all your nameservers in the same building already goes against the best practices specified in that RFC. Aug 8, 2014 at 7:44
  • 4
    I agree with that. I'd focussed on the bit of the question about having the DNS server and other services on the same server/ address, and rather ignored the bit about "do I need two nameservers". The answer to the latter question is a resounding "hell, yes". And as Vasili and others have said, they shouldn't be anywhere near each other, either in address space or real space.
    – MadHatter
    Aug 8, 2014 at 7:47
16

Ugh. I don't normally chime in after so many good people have answered, but I can't entirely agree with any of the answers so far posted. After 20 years of DNS admin, here's my take:

  • Should DNS just be outsourced? No. It's perfectly fine to run your own DNS server (though a static IP address is to my mind essential), and as Vasili notes, it's a good learning experience. We see a number of questions here on SF that arise because the web interfaces of some DNS providers are so appalling that they lead people into making basic DNS errors.

  • Can you run DNS service on a server that offers other services? Yes, of course. The main DNS server for teaparty.net is also the web server (the IP addresses are slightly different, but that's only because my colocated server has several addresses allocated to it).

  • Do you need more than one DNS server? Hell, yes. RFC2182 discusses this explicitly, and notes that:

An argument is occasionally made that there is no need for the domain name servers for a domain to be accessible if the hosts in the domain are unreachable. This argument is fallacious.

Your secondary server should be on a completely different network, and preferably continent, than your primary server. Note that my secondary name server, ns2.teaparty.net, is nowhere near ns.teaparty.net in address space, and in a different country to boot. In the good old days, operators of primary name servers would swap services with each other, so that my primary would also be your secondary, and vice-versa. Alternatively, in these days of cheap VPSes, a tiny, cheap VPS will do the job of 2ary very well.

Don't forget to tie down your DNS server(s) so that they will only recursively-resolve for people in your own organisation. Open DNS servers are lovely, but unless carefully configured they can be used for amplified reflection DDoS attacks, which are bad.

Finally, whilst best-practice questions are arguably the lifeblood of SF, requests for learning material recommendations are explcitly off-topic. If I were you, I'd edit that bit out of your question lest it accumulate any more close votes.

4
  • I like the Idea of nameserver trading. A shame that this isn't done anymore. Aug 8, 2014 at 12:33
  • 1
    It is! My secondary is my friend Marcus' primary, and vice-versa. It just requires a more personal relationship than was usual in the old days, when nearly everyone did it for nearly anyone.
    – MadHatter
    Aug 8, 2014 at 12:37
  • Thank you for your answer, it is very informing. I edited the learning material recommendations part but why is it off-topic?
    – user181840
    Aug 8, 2014 at 15:35
  • See our help guide for more information: that limitation is pretty clearly expressed.
    – MadHatter
    Aug 8, 2014 at 15:41
2

Yes, DNS and web server can be on the same IP.

However the way DNS is usually configured, it has to be a static IP. Running a web server on a dynamic IP is simple, as long as the DNS server supports it.

Moreover, you really should have two DNS servers with IPs in different subnets. So it may be simpler to just host you domain at one of the many free DNS hosting providers. I know of HE, other answers have mentioned other providers.

If you really want to host your own DNS server on a dynamic IP, the way to do it is to register dynamic hostnames at a couple of providers. Now you can have the NS records for your domain pointing at those two dynamic hostnames. Since those are outside your own domain, you don't need glue.

1
  • Very nice - the tl;dr version of my answer <grin>. +1 from me!
    – MadHatter
    Aug 8, 2014 at 8:00
0

This is no problem technically speaking. But that's not what you want for your "home server" needs. Register yourself to some DynDNS service (DynDNS, no-ip, etc...) and point your domain there, thats it. Don't run a DNS Server if you don't know what you are doing. In your case it is also not needed to run one yourself.

3
  • What if the OP wants to learn how to use DNS server software? Aug 8, 2014 at 7:35
  • "I intend to use for my web site" thats what he wrote. ALso "but I found that I need to create some name servers", so seems like he misunderstood something. He does not need to run a name server in this scenario.
    – duenni
    Aug 8, 2014 at 7:39
  • Even if that's the case, I'm pretty happy to send him on a wild hunt to set up his own DNS. It will make a good learning experience. Aug 8, 2014 at 7:40
-2

DNS is pretty central to all serving. Consider moving your DNS to a dedicated provider:

Dyn

UltraDNS

Route53

Doing so will fix the one problem you've identified, namely that your domain registrar wants you to provide at least two (some regions three or more) DNS servers for your domain.

Sometimes, your domain registrar will provide this service for free.