Raspberry Pi DNS, NTP, DHCP and Active Directory server
In this project, I’m going to set up my original Raspberry Pi model B to do the functions that would be done by an office network.
So what is this bad scrabble hand of letters, and what can they do for me?
DNS – Domain Name Server.
These servers perform the job of looking up the ip addresses of the computers on the internet. When you type in http://google.co.uk/ a DNS server will translate this to mean 62.252.232.30 and send the http request to that IP Address. This is the one of the IP addresses that google uses, and it will know how to deal with a request for http://google.co.uk/
Having my own DNS server will server two functions. Firstly, for internet services that I use alot, an index will be created locally so that I don’t have to go out onto the internet to look them up. This is called a DNS Cache, having this information locally means that the lookups will be faster. Especially if there are lots of computers all looking for the same thing. For example if a school has a wifi, and all the kids can attach. At break time, they a loarge number jump on facebook, they need to lookup facebook.com. Say 100 kids do that, that’s 100 times that the internet is accessed for the same thing. So having a machine in the network that can do it, can lower costs. Also, as the lookup isn’t done on the internet it will work faster. This gives a faster response to web browsing. It can quite literally speed up the internet.
NTP – Network Time Protocol
Ever wonder how your computer knows what the time is? And that it get’s it right? This is what NTP does for you, this is a service where computers can connect to time servers on the internet and get the time. Some get them from public time servers – this is the default for windows desktops. Just like the DNS server, having lots of time requests – every computer on your network will do it once in a while, just to make sure that it is still in sync with the rest of the world. Just like checking that your watch is showing the correct time.
DHCP – Dynamic Host Configuration Protocol
This is a service that gives your computer it’s IP address. Some devices have a static IP Address. That means every time they start, they shout out I am Number 6. Now this is all very well and good, but with lots of devices, we can’t all be number 6. So, if there is already a device that has numer 6, there’s a clash, lots of errors and someone has to fix it. To make life easier, rather than have each device hard coded to a specific number, how about have the device shout out “can I have a number please?”. This is what the DHCP does, it can assign the IP Addresses to the computers in your network. Most likey your router will be providing this function for you. Most home users don’t need to worry about it if they are only using their computers to browse the internet, write e-mails, or play games. Having a dedicate DHCP server becomes more important when you start to want to do crazy things like connect to your network from remote places and make use of the computers that you have on that network.
Active Directory Server
This is a very advanced thing. What this does is allows you to setup a single username and password for your entire network. Office computers tend to use this technology. It’s commonly known as a domain login. The computers join the domain, at that point the network administrators can assign access rights to all the computers on the network. So Johhny Oick can use the computers in the engerineering department, but not in the accounts department. This is called a domain level privilege. This is a very advanced thing and I might not get round to setting this one up.
Pulling it all together
The reality is that all these services are important to have and for the most part they do not require a lot of processing power. A raspberry Pi makes an ideal candidate for these services. My original Raspberry Pi is great for these tasks as it’s small, veyr low power and linux can do all of these things. My Raspberry Pi 2 would be an even better choice as I have a Hat based Pico UPS for it, the Hat has a real time clock (RTC) built in, so if I can get the ntp service to update that, it could even read the time from the RTC on initial boot or if the internet is down. I would have to rebuild it for this. At the moment it is serving my Wake on lan functionality, which complicates things quite a bit. So for now, I’ll built it on my original Pi model B with 256Mb ram. It’ll be plenty for my needs.
Setting up the Pi
First things first, I’m going to give my PI a static IP. As it will be serving as the DCHP and DNS Server, this is essential so that everything else can be configured to work with it. I’m going to assign it to IP 192.168.1.6. This means that IP numbers 1-5 can be for routers, I already have two, so there’s room for more. My current DHCP server (built into my router is assining IP Address between 100 and 200, so using 192.168.1.6 is fine)
Let’s start off with
raspi-config
Using the menus expand the file system – I’m using a 16GB Memory card in my PI, which will be more than enough.
Change the user password – For servers, it’s always a good idea not to use the default password for an admin account. This would be a vulnerability for hackers. In this case it’s not too bad as only devices on my private network will be able to access this server, however if one of those has been hacked it would be too easy.
Overclock – normally, I would suggest overclocking however in this case, I’m sure that it isn’t going to gain anything worthwhile, so we’ll stick to the default speed. If I need more power, I’ll consider switching to a Pi 2 instead as that is faster anyway.
Advanced options
Hostname – It’s always better to have a relevent hostname for your device, so I’m going to call mine “dhcpserver”
Memory Split – As I’m going to run this without a monitor, and it’s not doing graphics I’m going to set the GPU to have 16MB of ram, meaning that the rest is available for programs
finish and save. Don’t bother to reboot, as we’ll be doing that after assigning a static IP.
My PI is using rasbian jessie, same as my vpn server. so here’s how to set a static IP Address.
nano /etc/dhcpcd.conf
Scroll to the bottom of the file and add the following code.
# Custom static IP address for eth0. interface eth0 static ip_address=192.168.1.6/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
press ctrl-x, y, enter to save the file, now type
sudo reboot
this will reboot your PI on the new IP Address, don’t forget your new password.
Now that the basic config it done, next post I’ll get one of the other services up and running.