A clever way to build a DHCP server in Linux !!!

Source: Internet
Author: User
Tags get ip

Reproduced http://dreamfire.blog.51cto.com/418026/178680   A clever way to build a DHCP server in Linux !!! A clever way to build a DHCP server in Linux !!!

Tutorial Background:

Xiaonuo uses the Linux server built by RHEL4. To better manage the IP Address Allocation of all users in the company, it decided to use the Linux server to build a DHCP server, assign IP addresses and other network parameters for all employees.

DHCP is a service for centralized management of network information such as IP addresses. Build a Linux host in the LAN as the DHCP server, and set other hosts to obtain the network configuration information of the host from the DHCP server, this can greatly simplify the network configuration of all hosts by the system administrator, as well as reasonable planning and allocation of IP addresses. Note:: In fact, most servers in Linux have templates. This means that you do not need to remember all configurations when learning how to build Linux network services. This is not realistic, you only need to understand the meaning of the options in the configuration.

Tutorial network topology:

Tutorial steps:

1. Install DHCP server software

The RHEL4 system installation CD contains the rpm-format DHCP server software package, the package file name is dhcp-3.0.1-12_EL.i386.rpm, You can also download the new upgrade software package or tar package on the corresponding website for compilation and installation.

Run rpm-Qa | grep DHCP to check whether the DHCP software package is installed in the system.

Mount the fourth RHEL4 Disc

Run the rpm-IVH command to install the DHCP package.

After the installation is complete, you can use the man manual to access more detailed settings of DHCP.

2. DHCP. conf configuration file parsing

The configuration file name of DHCPD is DHCPD. conf and should be located in the "/etc" subdirectory. However, this file is not included in the DHCP software package and needs to be manually created by the Administrator. But you have already created it in rhel5. You only need to add the necessary configuration.

For ease of configuration, the system provides a template for the DHCP server. You can copy the template to the configuration file for modification and editing.

Note: The template has a deep location. You can use the rpm-ql dhcp command to search for the template without any memory.

Copy the content in the template to DHCPD. conf.

Use the VI editor to modify DHCPD. conf.

The format is as follows:

The entire format includes global settings and local settings. The global settings take effect for the scope of all local settings, which is equivalent to the server setting options in Windows. The local settings take effect for all users in the Department, it is equivalent to some settings in the Windows region. If some settings are set, the global settings are invalid. If some settings are not set, the global settings take effect.

Ddns-Update-style interim | ad-hoc | noneThe parameter is used to set the dynamic information update mode between the DHCP server and the DNS server. This setting is not considered for general DHCP servers, but must be included in the global setting so that the DHCPD can be started normally, interim is the DNS interactive update mode, ad-hoc is the special DNS update mode, and none is the dynamic update mode.

Ignore client-UpdatesTo ignore client updates.

Subnet IP netmask 255.255.255.0Declares a DHCP address range. The IP address is a network address, and the subnet mask must be set to 255.255.255.0.

Opriton routesThe gateway that dynamically obtains the IP address for the client.

Option subnet-MaskObtain the subnet mask of the IP address dynamically for the client.

Option Nis-DomainIs the Domain Name of the NIS Server

Option domain-nameHost domain name obtained for the client

Option domain-name-serversThe DNS address obtained by the client. Up to three DNS addresses can be written.

Range dynamic-BOOTPSet the range for the client to obtain the IP address

Default-lease-timeObtain the default lease time of network parameters for the client

Max-lease-timeMaximum lease time after obtaining network parameters for the client

HostApply for a reserved host address, followed by a name

Hardware EthernetMAC address of the client Ethernet Interface

Fixd-addressAssign a fixed IP address to the client

You can use the getmac or ipconfig/all command at the command prompt to obtain the MAC address of the client.

Restart the DHCPD service after/etc/DHCPD. conf is modified. Configuration takes effect.

Use the client to dynamically obtain the IP address. You can see the obtained parameters. The following is the IP address requested by the host. The IP address obtained by other hosts is obtained from the maximum IP address, which is exactly the opposite of windows.

3. Linux client settings

The DHCP client host needs to be set in the network interface configuration file ifcfg-eth0 To Get IP addresses using DHCP.

After the configuration is complete, restart the netwrok service by running the/etc/rc. d/init. d/network restart, ifdown eth0, IFUP eth0, netconfig eth0, or dhclient commands.

4. How to create multiple scopes

Use the VI editor to edit/etc/DHCPD. conf, Press ESC, enter: Enter command mode, enter SET nu to display the number, then check the range of the subnet region, copy M: NY to the bottom, and edit it.

Use more/var/lib/DHCP/DHCPD. lerase to view the lease documents of all user computers.

5. How to use Linux for DHCP relay

Install the DHCP software package, and then use the command "dhcprelay Server IP Address" to point to the IP address of the DHCP server.

The above settings only take effect temporarily. You can edit them in the/etc/sysconfig/dhcery file, and then restart the computer to take effect permanently.

The following is the IP address obtained by the client through DHCP relay.

This article is from the blog of "the Linux open source technology blog", please be sure to keep this source http://dreamfire.blog.51cto.com/418026/178680

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.