1

I have a VPS hosting account with a provider and I have been given an IP address. Now when we say that 'set up a private nameserver', what exactly do we mean? does it mean that I will turn my web hosting server into a nameserver also? If yes, does it mean that queries to my websites will be resolved by my namesever first and then my web hosting server will be sent request for the webpages?

In nutshell, my questions is: can a web hosting server become nameserver also?

  • A private nameserver is a nameserver that is only accessible to clients connected to your private network, this nameserver indicates where the domain should be routed to a domain, that isn't defined otherwise. – Ramhound May 26 '15 at 15:29
3

Short answer: Yes, all of the above.... almost.

First off, let's clarify the word "server". Server can refer to both the machine (virtual or physical), and to the individual processes handling client requests. for example apache (http) or named (dns). In this answer I will use "server" to refer to the processes, and "machine" to refer to, in your case, the VPS.

A private nameserver generally means a DNS server - the server that translates between IP addresses (for example 123.123.123.123) and hostnames (example.com). This DNS server can either be a slave used just by you, or what is more applicable, a zone master. In general, what you do is set up your DNS server such that it acts as master for a domain name you control. Let's call this domain name example.com.

The process of operation is roughly this:

  1. Peter the PC eater tries to go to the website www.example.com
  2. Peters computer makes a DNS lookup for www.example.com by asking whatever DNS server Peter gets from his ISP.
  3. Said DNS server doesn't know, so it refers Peters PC up the chain. Eventually Peters PC reaches the root DNS server, which refers Peters PC to the master for the .com zone. With whoever you purchased the domain from, you should have set up that the DNS server for your domain is located on the IP of your VPS, and this is the reply that Peter eventually gets. While it sounds fairly tedious, a DNS request is usually very small, so this rarely takes more than a few miliseconds on a decent connection.
  4. Peter, knowing the IP of the DNS server for example.com now makes a DNS request to said IP. DNS requests are done via port 53, and on that you (should) have a DNS server listening for requests. If set up properly, the DNS server responds with the IP of your webserver.
  5. Peters PC then connects its webbrowser to the IP returned earlier, and if all is set up correctly, loads the website as intended.

It does not matter that your machine run both a DNS server and a webserver. These run on different ports (port 53 and 80 respectively). Neither does it matter that all of the lookups and connections end up on the same IP.

I use the same machine for many services:

  • DNS
  • Web
  • Mail
  • SSH
  • Loads more

Why this works is that they all run on different ports. Every server that has an IP has a port associated with it. Ports range from 1 to 65535, and many of them are reserved. In particular the ones below 1024. See here for a long list. Of particular interest to you in this case are port 53 and 80, as briefly mentioned earlier on.

While I do not know any details about your VPS, I can give you some pointers on what to read up on to get you started:

  • DNS servers - for example named
  • Web servers - for example apache, also just called httpd
  • IP addressing and port numbering
  • Basic socket operation
  • 1
    Further, each domain information is stored in a separate DNS ZONE file and there could many such files for a server to read and reply. DNS server knows where to look for these files.. Am I correct? – KawaiKx May 26 '15 at 16:19
  • 1
    Correct. My server handles around 10 defferent domain names and serves as master for all of those. Each domain is considered a zone, and my DNS main config references each of these zones from the domain names it might get queried about, such as requests for jarmund.net pointing to a file named jarmund.net.db – Jarmund May 26 '15 at 18:09
  • 1
    Another thing to note is that each zone can also include more than one physical machine. Some subdomains of mine point to separate machines, and some subdomains point to the same machine. – Jarmund May 26 '15 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.