Linux DHCP server setup tutorial

Source: Internet
Author: User
Linux DHCP server setup tutorial-Linux Enterprise Application-Linux server application information, the following is a detailed description. 1. Install the DHCP package
Install the DHCP server software package. Run yum install dhcp directly.

2. Understand the directory where the configuration file is located
After DHCP is installed, you need to know the location of the Data configuration file related to the DHCP service.
1./etc/dhcpd. conf this file is the main configuration file of dhcp, NO content by default, we can copy the template to help us configure. Command cp/usr/share/doc/dhcp-3.0.5/dhcpd. conf. sample/etc/dhcpd. conf
2,/usr/share/doc/dhcp-3.0.1/dhcpd. conf. sample # This file is a template file that can be copied as a configuration file
3./var/lib/dhcp/dhcpd. leases # This file is a dhcp database file, and detailed client lease information is recorded here.
4./etc/sysconfig/dhcpd # This file is the NIC listening configuration file of the DHCP server. If the server has multiple NICs, "DHCPDARGS =" in this file can be configured as the NIC that needs to listen to DHCP requests, such as eth0. The default value is "all monitors.
5./etc/sysconfig/dhcrelay # relay configuration file (used as a DHCP relay proxy)

3. Configure the DHCP server
The main configuration file is/etc/dhcpd. conf. The common declaration formats, parameters, and options are described as follows:

1. Common statements
Subnet 1.1.1.0 netmask 255.255.255.0 {
Range 1.1.1.100 1.1.1.110;
}
This statement is similar to the scope in the windows environment, indicating distribution in the 1.1.1.0/24 network segment
IP address. Note that the left side of a pair of braces after the declaration must be the same line as the declaration.
Range 1.1.1.100 1.1.1.110; # indicates that the DHCP client can dynamically send
The IP address range, defined by the starting IP address and ending IP address. The Rows must be separated by semicolons.
Tail.

Host client {
Hardware ethernet 00: 11: 22: 33: 44: 55;
Fixed-address 1.1.1.222;
}
This statement is similar to a reservation in a windows environment. It is set in the subnet declaration to reserve IP addresses for specific DHCP clients in the network segment declared by subnet. The client indicates the name of this Sub-statement, the common practice is to name the host declaration based on the host name of the client. hardware ethernet 00: 11: 22: 33: 44: 55; indicates the MAC address of the client, fixed-address 1.1.1.222; indicates the IP address issued when this MAC address applies for an IP address.
Shared-network test {
}
This statement is similar to the super-level scope in windows. Multiple subnet statements can be included, and test is the declared name.

2. Common Parameters
Dns-update-style (none | interim | ad-hoc );
Defines the supported DNS dynamic update type. This parameter is required and must be placed in the first row and can only be used in global configuration (global configuration is not included in any declaration ). Optional values: None; not supported. Interim; DNS interactive update mode. Ad-hoc; Special DNS update mode.
Ignore client-updates; ignore client updates. This parameter can only be used in global configuration.
Default-lease-time 21600; default IP lease time, in seconds. This parameter can be set globally or locally. (The so-called local is used in the declaration, and the scope of action is only this Declaration)
Max-lesase-time 43200; maximum Client IP lease time, in seconds. This parameter can be set globally or locally.

3. Common options
Option routes 1.1.1.11; # default gateway. This option can be used in both global and local configurations.
Option subnet-mask limit 255.0; # subnet mask. This option can be set globally or locally.
.
Option domain-name-servers 1.1.1.11; # DNS server address.
Multiple DNS servers must be separated by commas.
Option domain-name "abc.com"; # DNS suffix. This option can be configured globally or locally.
Available.
Note: parameters and options are configured in separate lines and end with a semicolon. For other declarations, parameters, and options, enter man dhcpd. conf in the terminal for reference.

4. Summary
Always remember that/etc/dhcpd. conf is divided into global configuration and local configuration. Local configuration refers to its common declaration of subnet or shared-network.
Parameters and options can only be used in local configuration (For details, refer to the template file ).
The configuration line must end with a semicolon. When multiple IP addresses need to be configured in the same line, the IP addresses must
Otherwise, the system prompts that DHCP cannot be started.

4. Start and Stop DHCP servers
Enter service dhcpd start/stop/restart/status in the terminal.




Five DHCP server instances
The company's network environment is: Use 192.168.60.0/24 as the company's internal IP address segment, Gateway: 192.168.60.1. DNS address: 192.168.60.254 192.168.60.253. For the reserved addresses, see the following configuration line.
[Root @ localhost ~] # Cat/etc/dhcpd. conf
Ddns-update-style interim;
Ignore client-updates;

Subnet 192.168.60.0 netmask 255.255.255.0 {

# --- Default gateway
Option routers 192.168.60.1;
Option subnet-mask limit 255.0;

Option nis-domain "edscha-anhui.com ";
Option domain-name "edscha-anhui.com ";
Option domain-name-servers 192.168.60.254, 192.168.60.253;

Option time-offset-18000; # Eastern Standard Time
# Option ntp-servers 192.168.60.254;
# Option netbios-name-servers 192.168.60.254;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- You understand Netbios very well
# Option netbios-node-type 2;

Range dynamic-bootp 192.168.60.20 192.168.60.240;
Default-lease-time 21600;
Max-lease-time 43200;

# We want the nameserver to appear at a fixed address
Host congqianlu {
Next-server marvin.redhat.com;
Hardware ethernet 00: 26: 22: de: bd: 04;
Fixed-address 192.168.60.13;
}

Host yuanjing {
Next-server marvin.redhat.com;
Hardware ethernet 44: 37: e6: 14: d4: 09;
Fixed-address 192.168.60.162;
}

Host hpprinter {
Next-server marvin.redhat.com;
Hardware ethernet 00: 1e: 0b: 0d: 56: db;
Fixed-address 192.168.60.113;
}

Host hpprinter {
Next-server marvin.redhat.com;
Hardware ethernet 00: 1a: 4b: 1b: 3b: f3;
Fixed-address 192.168.60.118;
}

Host lilingyu {
Next-server marvin.redhat.com;
Hardware ethernet 00: 1e: 90: b8: 13: a7;
Fixed-address 192.168.60.125;
}

Host projdesignprinter {
Next-server marvin.redhat.com;
Hardware ethernet 00: 0d: 87: da: 8b: 6d;
Fixed-address 192.168.60.56;
}

}

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.