Build a DHCP server

Source: Internet
Author: User
Tags failover

DHCP introduction:

The original name of DHCP (Dynamic Host Configuration Protocol, Dynamic Host Configuration Protocol) is a LAN network protocol that uses UDP protocol for two purposes: an IP address is automatically assigned to an internal network or network service provider. The IP address is described in RFC 2131 as a central management method for all computers. DHCP has three ports, of which udp67 and udp68 are normal Dhcp Service ports, respectively used as DHCP server and DHCP Client Service ports; port 546 is used for dhcpv6 client, not for dhcpv4, it is a DHCP failover service, which requires special activation. DHCP failover is used for "Hot Standby.

 

Next we will build a simple DHCP server.

Lab environment: Prepare two redhat5.9 virtual machines

Virtual Machine 1:

DHCP server's first Nic IP Address: 192.168.1.254/24 Host Name: dhcpsvr network adapter: only host

Set the IP address to the static mode.

IP address of the second NIC: 192.168.4.254/24 network adapter: vmnet7

Virtual Machine 2:

Client: automatically obtain IP host name: pc205 network adapter: vmnet7

Objective: to automatically assign IP addresses from 192.168.4.10 to 192.168.4.50 to Virtual Machine 2 through the DHCP server

192.168.4.100 to 192.168.4.120

Bind an IP address based on the MAC address (192.168.4.19)

Set gateway 192.168.4.1

Set the default search domain "tarena.com"

Set the DNS server address: "202.106.0.20, 8.8.8.8"

Prerequisites: configure the yum Source

1. Configure the DHCP server

[[Email protected] ~] # Rpm-q dhcp // check whether the DHCP software package is installed

Dhcp-3.0.5-31.el5_8.1

[[Email protected] ~] # Yum-y install DHCP // use Yum if not installed

[[Email protected] ~] # Vim/etc/DHCPD. conf // modify the DHCP configuration file

[[Email protected] ~] # Cat/etc/DHCPD. conf | grep-IV "^ #"

Ddns-Update-style interim; // type of Dynamic Update

Ignore client-updates;

Subnet 192.168.4.0 netmask 255.255.255.0 {// declare the network segment

Option routers 192.168.4.1; // default gateway address

Option subnet-mask limit 255.0; // Subnet Mask

Option domain-name "tarena.com"; // default search domain

Option domain-name-servers 202.106.0.20, 8.8.8.8; // DNS server address

Range 192.168.4.10 192.168.4.50; // declare the address pool (IP Address allocation range)

Range 192.168.4.100 192.168.4.120;

Default-lease-time 21600; // default lease period (can be omitted)

Max-lease-time 43200; // maximum lease period (can be omitted)

Host NS {// identify the name

Next-server marvin.redhat.com;

Hardware Ethernet 00: 0C: 29: 3B: C9: 58; // client MAC address

Fixed-address 192.168.4.19; // fixed IP Address

}

}

[[Email protected] ~] # Service DHCPD restart // restart Dhcp Service

Client test:

[[Email protected] ~] # Service network restart // restart the NIC Service

[[Email protected] ~] # Ifconfig eth0 // check whether the IP address is obtained

 

View IP address lease information

[[Email protected] ~] # Less/var/lib/DHCPD. Leases // check the address allocation on the server

// Check the obtained IP lease on the client

[[Email protected] ~] # Less/var/lib/dhclient. Leases

[[Email protected] ~] # Less/var/lib/dhclient/dhclient-eth0.leases

 

Check the listening port of the DHCP service on the server:

[[Email protected] ~] # Netstat-anptu | grep DHCP

 

Modify the connection mode of the NIC:

[[Email protected] ~] # Dhclient-D eth0 // debug mode

[[Email protected] ~] # Dhclient-r eth0 // release address

// Restart the service after all service changes

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Build a DHCP server

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.