How to configure a DHCP server in Linux

Source: Internet
Author: User
In Linux, configure DHCP server practices-Linux Enterprise Application-Linux server application information. The following is a detailed description. Configure DHCP
Redhat uses the dhcpd process to provide the DHCP service. At startup, dhcpd automatically reads its configuration file/etc/dhcpd. conf. Dhcpd saves the customer's lease information in the/var/lib/dhcp/dhcpd. leases file. This file is constantly updated, from which you can find the IP Address allocation.
To provide services to a subnet, dhcpd needs to know the network address and network mask of the subnet and the range of Address Allocation. Below is a simple dhcpd. conf file:
Subnet 192.168.100.0 netmask 255.255.255.0 {
Range 192.168.100.10 192.168.100.253;

}
In this example, dhcpd assigns an IP address from 192.168.100.10 to 192.168.100.253 to the 192.168.100.0 network.
The lease period can be from 0 seconds to an infinite length, which can be determined as needed. The default rental period is one day, that is, 86400 seconds. Two lease period lengths can be defined for the Host:
Default-lease-time: default lease period;
Max-lease-time the maximum lease period that a user can obtain.
The following configuration sets the default lease period to 10 minutes, and the maximum lease period is 1 hour:
Subnet 192.168.100.0 netmask 255.255.255.0 {
Range 192.168.100.10 192.168.100.253;
Default-lease-time 600;
Max-lease-time 3600;
}
DHCP can also provide more parameters to the customer, which can be specified by option. For example:
Subnet 192.168.100.0 netmask 255.255.255.0 {
Range 192.168.100.10 192.168.100.253;
Default-lease-time 600;
Max-lease-time 3600;
Option subnet-mask limit 255.0;
Option routers 192.168.100.254; default route
Option domain-name-servers 202.102.134.68; DNS Server
}
Now you should have an understanding of DHCP configuration. In fact, the process is so simple that there is a window in the middle.
Actual drills
Next we will give you an example to configure redhat9.0 as a DHCP server.
Vi/etc/dhcpd. conf
After configuration, the contents of this file on my machine are as follows (the comments have been deleted. For the original text, you can check/usr/share/doc/
Dhcp-3.0pl1/dhcpd. conf. sample file ):
[Root @ rh9 test] # more/etc/dhcpd. conf
Ddns-update-style interim;
Ignore client-updates;
Subnet 192.168.0.0 netmask 255.255.255.0 {
Option routers 192.168.0.1;
Option subnet-mask limit 255.0;
Option broadcast-address 192.168.0.255;
Option domain-name-servers
202.96.199.20., 202.96.133.134;
Range dynamic-bootp 192.168.0.1 192.168.0.255;
Default-lease-time 21600;
Max-lease-time 43200;
}

Here I will explain the configuration section. First, subnet defines the network address, and then option routers defines the gateway address; subnet-mask defines the subnet mask; broadcast-address defines the broadcast address; domain-name-servers defines the dns nameserver address; dynamic-bootp is the address assigned to the client, defining the whole network segment address of 192.168.0.1 -- 192.168.0.255; the last two rows indicate that the default lease period of the allocated address is set to 10 minutes, and the maximum lease period is 1 hour. In this way, a DHCP server is configured.
We can test the result: on another redhat linux7.2, set the IP address to the IP address of the DHCP host and use the netconfig command to configure the IP address.
Check Configuration:
[Root @ rh72 root] # more/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = dhcp
[Root @ rh72 root] #
Make sure that the NIC is already DHCP.
[Root @ rh72 root] # ifconfig
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: A3: C6: 71
Inet addr: 192.168.0.254 Bcast: 192.168.0.255 Mask: 255.255.255.0
Check the address and find that ETH0 has been assigned a 254 address, indicating that the DHCP server is configured successfully.
Summary
So far, we have completed the installation and configuration of a Linux DHCP server. In actual use, the above * steps should meet the needs of general applications, but we also need to study specific command parameters frequently so that the DHCP server can better serve us.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.