Ubuntu: Install and set up the DHCP server - how it works
This practical tip shows you how to set up a DHCP server on Ubuntu.
Ubuntu: Install and set up the DHCP server
A DHCP server on Ubuntu is easy to set up:
- First install the required package with the "sudo apt install isc-dhcp-server" command.
- Now edit the file "/ etc / default / isc-dhcp-server" and define the interfaces here. For example, if you want to use "eth0", use the command »INTERFACES =" eth0 "«.
- Then you have to configure the DHCP server. To do this, use the sudo vi /etc/dhcp/dhcpd.conf command to edit the corresponding configuration file. Now use the commands »option domain-name" chip.lan ";«, »option domain-name-servers ns1.chip.lan, ns2.chip.lan;«, »default-lease-time 3600;«, "Max-lease-time 7200;" and "authoritative;" set the corresponding parameters. Adapt this to your personal DHCP server.
- Then you have to configure the subnetwork. For example, this works with: »subnet 192.168.10.0 netmask 255.255.255.0 {« ⮩ »option routers 192.168.10.1;« ⮩ »option subnet-mask 255.255.255.0;« ⮩ »option domain-search" chip.lan ";« ⮩ »Option domain-name-servers 192.168.10.1;« ⮩ »range 192.168.10.10 192.168.10.100;« ⮩ »range 192.168.10.110 192.168.10.200;« ⮩ »}«.
- Next, you can assign static IP addresses to certain client PCs. An example of this is the command »host centos-node {hardware ethernet 00: f3: m4: 6y: 66: 0g; fixed address 192.168.10.105; } ".
- In the next step you have to start the DHCP server and specify that it should always be started. Starting works with either "sudo systemctl start isc-dhcp-server.service" or "sudo service isc-dhcp-server.service start". Then execute the command "sudo systemctl enable isc-dhcp-server.service" or "sudo service isc-dhcp-server.service enable".
- Now you have to use the commands "sudo ufw allow 67 / udp", "sudo ufw reload" and "sudo ufw show" to allow the service on your firewall.
- With your client devices, you can now select your DHCP server in the network settings.
In the next practical tip, you will learn how you can also use Ubuntu under Windows 10.