Monday, January 9, 2017

Making a DHCP Server by Raspberry Pi

I wanted to connect my lab equipment to an external dedicated DHCP server but the problem is my home ADSL router is too far to connect via a cable. So I decided to use my Pi to do DHCP work. It's simple but many online tutorials would not work if you are using newer R-Pi (Ex:- Model B-3). So I decided to take a note on it. There are many ways to do this & this is how I did it..

First of all, you should assign a static IP address to your Ethernet interface of Pi..
Best way is to use GUI..

Go to the network icon of the front right corner and edit settings.

Give your interface a static IP and a DNS server address. I want the DHCP service to run on Ethernet interface only. So I did it to Eth0 only. If you want it to go wireless, you have to edit the Wlan0 settings.

Enter the following command to download the required package..
sudo apt-get install dnsmasq

Now enter following commands to create a backup default config file for the DHCP server..
cd /etc
sudo mv dnsmasq.conf dnsmasq.default

Now goto the file and specify the parameters and save & exit..
sudo nano dnsmasq.conf


It says that the interface which listens DCHP requests is eth0 and the range of IPs to offer are - with a subnet mask of and the leased time is for 12 hours..

Now enter the following command to start the service effectively..
sudo service networking restart

Even though the Pi is rebooted the DHCP service will be delivered..

0 comments to “Making a DHCP Server by Raspberry Pi”

Post a Comment