@georgiana.senger
To set up a DHCP server on Ubuntu, you can follow these steps:
- Open a terminal window on your Ubuntu machine.
- Install the DHCP server software by running the following command:
1
2
|
sudo apt-get update
sudo apt-get install isc-dhcp-server
|
- Configure the DHCP server by editing the /etc/dhcp/dhcpd.conf file. You can use any text editor you prefer to open the file, but we will use nano in this example:
1
|
sudo nano /etc/dhcp/dhcpd.conf
|
- In the dhcpd.conf file, you need to specify the network parameters that you want to assign to clients. Here's an example configuration:
1
2
3
4
5
6
|
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option broadcast-address 192.168.1.255;
}
|
This configuration specifies that the DHCP server will assign IP addresses in the range 192.168.1.100-192.168.1.200 to clients, and the default gateway (router) will be 192.168.1.1. The DNS servers are set to 8.8.8.8 and 8.8.4.4, and the broadcast address is set to 192.168.1.255.
- Save the dhcpd.conf file and exit the text editor.
- Configure the DHCP server to listen on a specific network interface. To do this, edit the /etc/default/isc-dhcp-server file:
1
|
sudo nano /etc/default/isc-dhcp-server
|
- Uncomment the line that specifies the network interface, and change it to the appropriate interface name for your system. For example:
- Save the isc-dhcp-server file and exit the text editor.
- Start the DHCP server by running the following command:
1
|
sudo systemctl start isc-dhcp-server
|
- Enable the DHCP server to start automatically at boot time:
1
|
sudo systemctl enable isc-dhcp-server
|
That's it! You now have a DHCP server set up on your Ubuntu machine. You can test it by connecting a client computer to the network and verifying that it receives an IP address from the server.