Configuration of DHCP service under Linux

Source: Internet
Author: User

  • DHCP Server

  • Lab Requirements:

  • The company requires a Linux host that is idle to be configured as a DHCP server to provide automatic IP address assignment services for employees in local area networks, improving the efficiency of network management and maintenance.

  • The basic requirements that need to be met are described below:

  • 1. Automatically configures network parameters for clients of the 192.168.10.0/24 network segment.

  • The range of IP addresses used to automatically assign clients to the client is: 192.168.10.50-192.168.10.100 192.168.10.120-192.168.10.200.

  • The client's default gateway address is set to 192.168.10.1

  • The DNS server used by the client is set to 192.168.10.4, 61.139.2.69, and the default search domain suffix is tarena.com.

  • Set the default lease time to 8 hours, maximum lease time 24 hours

  • 2. Assigning a reserved address (Win7) to a print server

  • Each time this printer is powered on, it should have an IP address of 192.168.10.8.

  • 3. Verifying DHCP server IP assignment, client lease information

  • First, the construction of the DHCP server

  • The DHCP service on the VMnet1 on which the test is located is first closed on the virtual machine.

  • 1. Set Rhel5.9_a IP//must be fixed IP

  • [[Email protected] ~] #vim/etc/sysconfig/network-scripts/ifcfg-eth0

  • Device=eth0//Device name

  • Onboot=yes//Boot load

  • bootproto=static//manual DHCP is automatically obtained, the following IP parameters do not have to be set

  • ipaddr=192.168.10.254//IP Address

  • netmask=255.255.255.0//Subnet mask

  • macaddr=00:0c:29:e5:c7:7c//Modify MAC address, hwaddr=00:0c:29:e5:c7:7c can also

  • Peerdns=no//Disable modification of resolv.conf files when DHCP is obtained

  • [[Email protected] ~]# Service Network restart//restart NIC

  • Shutting down interface eth0: [OK]

  • Close Loopback interface: [OK]

  • Eject loopback interface: [OK]

  • Popup interface eth0: [OK]

  • [Email protected] ~]# ifconfig eth0 | grep "InetAddr"//view NIC

  • inetaddr:192.168.10.254 bcast:192.168.10.255 mask:255.255.255.0

  • 2. Install the Package

  • [[email protected] ~]# Yum Clean all//clear Yum Cache

  • [[email protected] ~]# yum-y Install DHCP//installation DHCP, automatic installation complete

  • 3. Modify the master configuration file

  • [Email protected] ~]# ls/usr/share/doc/| grep DHCP//Get DHCP version, template location

  • dhcp-3.0.5

  • dhcpv6-client-1.0.10

  • [Email protected] ~]# vim/etc/dhcpd.conf

  • # DHCP Server Configuration file.

  • # See/usr/share/doc/dhcp*/dhcpd.conf.sample//prompts you to see the template under this location

  • Press CTRL +: After entering the//vim inside the operation

  • : r/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample//Read template file

  • [[email protected] ~]# cat/etc/dhcpd.conf//The following is the place to be modified

  • Ddns-update-style Interim; Represents the dynamic information update mode for DHCP servers and DNS servers. This line must have a DHCP server to be started.

  • Ignore client-updates; Ignore the user's DNS update feature

  • Subnet 192.168.10.0netmask 255.255.255.0 {

  • RANGEDYNAMIC-BOOTP 192.168.10.50 192.168.10.100; Allocated address Pool 1

  • RANGEDYNAMIC-BOOTP 192.168.10.120 192.168.10.200; Allocated Address Pool 2

  • Optionrouters 192.168.10.254; Specify Gateway Address

  • Optionsubnet-mask 255.255.255.0; Specify Subnet mask

  • Optiondomain-name-servers 192.168.10.254,202.106.0.20; Specify DNS

  • Optionnis-domain "domain.org"; NIS domain name

  • Optiondomain-name "tarena.com"; Configure domain Names

  • default-lease-time28800; Default Lease Period

  • max-lease-time86400; Maximum rental Period

  • hostwin7 {//IP and Mac bindings, when the new host, Win7 this name will change, not the same

  • # (fixed IP and Mac)

  • Hardware Ethernet 00:0c:29:6c:d1:85; The Mac that binds the host,

  • Fixed-address 192.168.10.8; IP of the bound host

  • }

  • }

  • 4. Start the service

  • [[Email protected] ~]# service DHCPD configtest//Determine if the configuration file is wrong

  • [[email protected] ~]#/ETC/INIT.D/DHCPD configtest//troubleshooting with config file

  • [[email protected] ~]# VIM/ETC/INIT.D/DHCPD//modify it in error

  • [Email protected] ~]# service DHCPD restart

  • Close dhcpd:[OK]

  • Start dhcpd:[OK]

  • [[email protected] ~]# chkconfig DHCPD on//boot automatically start DHCP service

  • [Email protected] ~]# Netstat-ln | grep:67//Monitor DHCP port 67 after reboot to verify that the DHCP service can be turned on automatically when it restarts

  • UDP 0 0 0.0.0.0:67 0.0.0.0:*

  • Second, the client's test

  • Linux:

  • [[Email protected]~]# cat/etc/sysconfig/network-scripts/ifcfg-eth0

  • To see if the client is set to get automatically

  • #Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

  • Device=eth0

  • BOOTPROTO=DHCP//Auto Get IP

  • Onboot=yes

  • hwaddr=00:0c:29:01:94:66

  • [[Email protected]~]# Service Network restart//restart NIC

  • [[Email protected]~]# ifconfig eth0//view acquired IP

  • Eth0 Link encap:ethernet HWaddr 00:0c:29:01:94:66

  • inetaddr:192.168.10.200 bcast:192.168.10.255mask:255.255.255.0

  • INET6ADDR:FE80::20C:29FF:FE01:9466/64 Scope:link

  • Upbroadcast RUNNING Multicast mtu:1500 metric:1

  • rxpackets:54 errors:0 dropped:0 overruns:0 frame:0

  • txpackets:71 errors:0 dropped:0 overruns:0 carrier:0

  • collisions:0txqueuelen:1000

  • rxbytes:7534 (7.3 KiB) TX bytes:12356 (12.0 KiB)

  • Windows:

  • Open the network and Sharing Center, set the local connection to get IP automatically, disable-and then enable local Area Connection

  • Cmd:ipconfig//View IP

  • Ipconfig/release//Disable IP

  • Ipconfig/renew//re-acquiring IP

  • Third, turn on the route forwarding function

  • If there are two and more than two network segments on this DHCP server, you can turn on the routing and forwarding function of Linux and realize the communication between the two network segments.

  • [Email protected] ~]# vim/etc/sysctl.conf

...

7 Net.ipv4.ip_forward = 1 ... [Email protected] ~]# sysctl-p: 1. Port UDP server UDP client2. Lease time 50%---DHCP request/ /Request Renewal 87.5%---DHCP Discover//re-obtain lease file server side:/var/lib/dhcpd/dhcpd.leases client:/var/lib/dhcl Ient/dhclient.leases hwaddr= and Macaddr= set the difference between Mac Hwaddr=, which is the hardware address of the Ethernet device in the form of AA:BB:CC:DD:EE:FF. On a machine with multiple network card devices, this field is extremely        , it ensures that the device interface is assigned the correct device name, regardless of the load order in which each NIC module is configured. This field cannot be used with MACADDR. Macaddr=, where the hardware address of the Ethernet device is in the form of AA:BB:CC:DD:EE:FF. On a machine with multiple network card devices. This field is used to assign a MAC address to an interface, overwriting the physically assigned MAC address. This field cannot be used with HWADDR.

This article from "Dylan Linux career" blog, declined reprint!

Configuration of DHCP service under Linux

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.