IoT Bytes

Bits and Bytes of IoT

Configure Tiny Core Linux as DHCP Server using udhcpd

Pradeep Singh | 18th Aug 2017


Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an IP Host with its IP address and other related configuration information such as the subnet mask and default gateway.

udhcpd is the DHCP Server demon which is part of BusyBox and is included by default with core OS (no need to install any additional package). It is a perfect candidate for simple and lightweight DHCP Server. Let’s explore how to create a Tiny Core based DHCP Server –

1. Configure the Ethernet Interface with Static IP Address:

1.1 Create the ethernet config script using the “sudo vi /opt/” command with the following contents  (For more details on this you can refer to this Article) –


# If you are booting Tiny Core from a very fast storage such as SSD / NVMe Drive and getting 
# "ifconfig: SIOCSIFADDR: No such Device" or "route: SIOCADDRT: Network is unreachable"
# error during system boot, use this sleep statemet, otherwise you can remove it -
sleep .2

# kill dhcp client for eth0
sleep 1
if [ -f /var/run/ ]; then
kill `cat /var/run/`
sleep 0.1

# configure interface eth0
ifconfig eth0 netmask broadcast up

# Start the DHCP Server Process once the Interface is Ready with the IP Add
sleep .1
sudo udhcpd /etc/udhcpd.conf &

1.2 Assign execute permission to “” script –

sudo chmod 777 /opt/

1.3 Execute the script to configure the “eth0” Ethernet interface using the following command –

sudo /opt/

1.4 Check the Ethernet interface “eth0” –


2. Create “/etc/udhcpd.conf” File:

Create a DHCP Configuration file with the “sudo vi /etc/udhcpd.conf” command and fill it will following template (make the changes according to your DHCP Range requirements) –

interface eth0
option subnet
option router
option lease 43200
option dns
option domain local

3. Start DHCP Daemon:

Start the DHCP process using the following command –

sudo udhcpd /etc/udhcpd.conf

Note: In case your DHCP Server is not working try using “-f” option with “udhcpd” command to run it in the foreground and see the error messages on the console. For Example – “sudo udhcpd -f /etc/udhcpd.conf

4. Verify the DHCP Server Process:

You can use following commands to verify if the DHCP process is running properly using the following commands –

ps -ef | grep udhcpd
sudo netstat -anp | grep udhcpd

You should see something like following console output (DHCP Server listens at UDP port 67) –

tc@box:~$ ps -ef | grep udhcpd
  913 root     udhcpd /etc/udhcpd.conf
  933 tc       grep udhcpd
tc@box:~$ sudo netstat -anp | grep udhcpd
netstat: /proc/net/tcp6: No such file or directory
udp        0      0    *                           913/udhcpd
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory

4. Make DHCP Server Configuration Persistent:

As Tiny Core runs from system RAM, it would loose the DHCP configuration on system reboot. To make your DHCP configuration persistent use the following commands –

sudo echo '/etc/udhcpd.conf' >> /opt/.filetool.lst
sudo echo '/opt/' >> /opt/.filetool.lst
sudo echo '/opt/ &' >> /opt/ -b

Following is the console output with sample contents of “.filetool.lst” and “” files –

tc@box:~$ sudo echo '/etc/udhcpd.conf' >> /opt/.filetool.lst
tc@box:~$ sudo echo '/opt/' >> /opt/.filetool.lst
tc@box:~$ cat /opt/.filetool.lst 
tc@box:~$ sudo echo '/opt/ &' >> /opt/
tc@box:~$ cat /opt/ 
# put other system startup commands here
/opt/ &
tc@box:~$ -b
Backing up files to /mnt/sda1/tce/mydata.tgztc@box:~$ 

5. Reboot the Server:

With this your DHCP Server is ready. You may test the configuration persistence by rebooting the server.


/etc/udhcpd.conf – Man Page

/etc/udhcpd.conf – Sample Configuration File 1

/etc/udhcpd.conf – Sample Configuration File 2


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: