Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install DHCP server in Ubuntu and Debian

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to install DHCP server in Ubuntu and Debian". In daily operation, I believe many people have doubts about how to install DHCP server in Ubuntu and Debian. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to install DHCP server in Ubuntu and Debian". Next, please follow the editor to study!

Dynamic Host configuration Protocol (DHCP) is a network protocol used to enable hosts to automatically assign IP addresses and related network configurations from a server.

The IP address assigned by the DHCP server to the DHCP client is in the "leased" state, and the lease time usually depends on the time the client computer requires the connection or the time configured by the DHCP server.

How does DHCP work?

The following is a brief description of how DHCP actually works:

Once the client (a machine configured to use DHCP) is connected to the network, it sends DHCPDISCOVER packets to the DHCP server.

When the DHCP server receives the DHCPDISCOVER request message, it uses the DHCPOFFER packet to reply.

The client then gets the DHCPOFFER packet and sends a DHCPREQUEST packet to the server indicating that it is ready to receive the network configuration information provided in the DHCPOFFER packet.

*. After receiving the DHCPREQUEST message from the client, the DHCP server sends the DHCPACK message, indicating that the client is now allowed to use the IP address assigned to it.

In this article, we will show you how to set up a DHCP server in Ubuntu/Debian Linux, and we will use the sudo command to run all commands to gain root user privileges.

Test environment settings

In this step, we will use the following test environment.

DHCP Server-Ubuntu 16.04

DHCP Clients-CentOS 7 and Fedora 25

Step 1: install the DHCP server in Ubuntu

1. Run the following command to install the DHCP server package, which is dhcp3-server.

$sudo apt install isc-dhcp-server

2. After the installation is complete, the editor / etc/default/isc-dhcp-server uses the INTERFACES option to define the interface that DHCPD uses to respond to DHCP requests.

For example, if you want the DHCPD daemon to listen to eth0, set it as follows:

INTERFACES= "eth0"

Also remember to configure a static address for the interface above.

Step 2: configure the DHCP server in Ubuntu

3. The main file of DHCP configuration is / etc/dhcp/dhcpd.conf. You must fill in all the network information that will be sent to the client.

And two different declarations are defined in the DHCP configuration, which are:

Parameters-specifies how and whether to perform the task, as well as the network configuration options to be sent to the DHCP client.

Declarations-define a network topology, specify a client, provide an address for a client, or apply a set of parameters to a set of declarations.

4. Now open and modify the main file to define the DHCP server options:

$sudo vi / etc/dhcp/dhcpd.conf

Set the following global parameters at the top of the file, which will be applied to all of the following declarations (please specify a value that applies to your situation):

Option domain-name "tecmint.lan"; option domain-name-servers ns1.tecmint.lan, ns2.tecmint.lan; default-lease-time 3600; max-lease-time 7200; authoritative

5. Now define a subnet. Here we set the DHCP for 192.168.10.0 and 24 LAN (please use the parameters applicable to your situation):

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 "tecmint.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;}

Step 3: configure a static address on the DHCP client

6. To assign a fixed (static) IP to a specific client, you need to explicitly add the machine's MAC address and the statically assigned address to the following section.

Host centos-node {hardware ethernet 00VOV F0 fixed-address m4VERV 6yLV 89G; fixed-address 192.168.10.105;} host fedora-node {hardware ethernet 00VOV 4g RV 8hRV 13hRV 3a; fixed-address 192.168.10.106;}

Save and close the file.

7. Next, start the DHCP service and let it boot itself next time, as shown below:

-SystemD-$sudo systemctl start isc-dhcp-server.service $sudo systemctl enable isc-dhcp-server.service-SysVinit-$sudo service isc-dhcp-server.service start $sudo service isc-dhcp-server.service enable

8. Next, don't forget the firewall permissions that allow the DHCP service (the DHCP daemon listens on port 67 UDP):

$sudo ufw allow 67/udp $sudo ufw reload $sudo ufw show

Step 4: configure the DHCP client

9. At this point, you can configure the client computer to automatically receive IP addresses from the DHCP server.

Log in to the client and edit the configuration file for the Ethernet interface (note interface name / number):

$sudo vi / etc/network/interfaces

Define the following options:

Auto eth0 iface eth0 inet dhcp

Save the file and exit. Restart the network service (or restart the system):

-SystemD-$sudo systemctl restart networking-SysVinit-$sudo service networking restart

You can also use GUI to set the settings, as shown in the screenshot (on the Fedora 25 desktop), to automatic (DHCP).

Set up DHCP network in Fedora

At this point, if all the settings are complete, your client should be able to automatically receive the IP address from the DHCP server.

At this point, the study on "how to install DHCP server in Ubuntu and Debian" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report