DHCP server and DHCP relay server test

Installing the DHCP Service

1, scene service used: DHCP services for the company assigns IP addresses to client
2, protocol and port services
             comply with udp protocol
             client is a 68-port  
            server is a 67-port view the service ports are open: netstat -lnup | grep: 67
            DHCP server by listening to port 67 UDP protocol work, client work through port 68 UDP protocol
3, configure the DHCP service
main configuration file is: /etc/dhcp/dhcpd.conf
execute the program: / usr / sbin / dhcpd
script name services is: dhcpd  
start the service with: systemctl start dhcpd

Turn off the firewall and security mechanisms
iptables -F
systemctl STOP firewalld
setenforce 0
DHCP installation package depends
mkdir / Media / CDROM
Mount / dev / CDROM / Media / CDROM
RPM -ivh /media/cdrom/Packages/dhcp-4.2.5-36.e17.centos.x86_64.rpm
RPM DHCP -q

For the first time there will be prompted to open /etc/dhcp/dhcpd.conf contents of the file reference the following two files
so with yes | cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
Next in the configuration file for editing
 input vim /etc/dhcp/dhcpsd.conf
file is modified, retaining only the following, other fully delete
the Option domain-name "crushlinux.com";             // define the allocation of domain
option domain-name- servers 202.106.0.20,8.8.8.8; // definition is assigned to the DNS server information
default-lease-time 21600; // default assigning IP addresses progenitor about time, in seconds
max-lease-time 43200; // custom distribution the maximum IP address lease time, in seconds
subnet 192.168.116.0 netmask 255.255.255.0 {// definition of network and subnet mask IP address
range 192.168.116.100 192.168.116.200; // address pool defines an IP address assigned to the maximum can not be 255
the Option Routers 192.168.116.1; // define the distribution gateway address
}
open service
systemctl Start dhcpd
systemctl status view // dhcpd service on state
Followed by a test with the test machine, test machine must be kept with the same host in a network mode that is V8net mode.
Ping www.baidu.com carried out in the terminal test machine
then looks at the IP address information obtained test machine, the network should pay attention to the V8 virtual machine settings before the test, to enable the DHCP service turned off .

Troubleshooting information
if a first configuration view file written in
a second look-in / var / log / messages // log captured four process
may be used to view the log dynamic @ tail -f / var / log / messages .
cat /var/lib/dhcp/dhcpd.leases // view the lease information file
=====================================================================================
 
Allow Linux clients to obtain an IP address
 
Also turn off the firewall and security mechanisms
need to be a Linux client network mode is set to the same mode DHCP server to obtain an IP address to test
first: Modify the following two things NIC Linux client configuration
BOOTPROTO = dhcp 
ONBOOT = yes
 Input vim / etc / sysconfig / network-scripts / ifcfg-ens32
input modified systemctl restart network // restart the network card, obtain IP
with ip a view to.
At the same time we can enter the DHCP server machine is equipped with tail -f / var / log / messages listening
and then we entered the Linux client ip a can view the IP address of the testing machine acquired
or may be in a testing machine enter
dhclient -r ens32 // release IP
dhclient -d ens32 // get IP, when there DHCPDISCOVER DHCPREQUEST DHCPOFFER DHCPACK four
time words to explain to the IP has obtained
input ip a view on it
===================================================================================
 
I.e., a fixed IP address assigned to solve for the host portion which can be bound to the MAC address fixed IP address assigned
as follows:
Modify vim /etc/dhcp/dhcpd.conf file, add the following based on the original
option domain-name "crushlinux. COM ";             // define the allocation of domain names
the Option domain-name-servers 202.106.0.20,8.8.8.8;    // definition is assigned to the DNS server information
default-Lease-time 21600;    // default ancestor about the time of assigning IP addresses, in seconds
max-lease time-43200;   // maximum lease time assigning IP addresses, in seconds
Subnet 192.168.116.0 Netmask 255.255.255.0 {        // definition of network and subnet mask IP address
range 192.168.116.100 192.168 .116.200; // can not define the maximum address range is assigned an IP address 255
Option Routers 192.168.116.1; // allocated gateway address defined
}
host name host win7 {// behind to bind with the host client
      hardware ethernet 00: 0c: 29: a9: 29: ec; // mac address can view the lease acquisition, can also go to the client ip a view
      fixed-address 192.168.116.101; // Specify the IP to bind the client just make sure the address in the address pool to
}
save and exit! ! !
Open service
systemctl start dhcpd
tested in wind client
input ipconfig / release // shows the release IP
input ipconfig / renew // represents the re-acquire IP
=================== ================================================== ===============
the DHCP relay test
Role: DHCP server to achieve different segments of clients assigned IP addresses
Experimental environment, two Linux machines, two tester win
win testing machine, 116 is a network segment, a segment 100 is
Linux1 as a DHCP server, a piece of card 192.168.116.66 IP
Linux2 as a DHCP server relay, two card, a (ens32) is v8net, one (ens34) V2 host mode is only
experimental procedure as
DHCP server is configured the same
DHCP relay server configured as below
1, first turn off the firewall security mechanisms
iptables -F
systemctl STOP firewalld
the setenforce 0
2 edit card settings
first modify ens32, modify and add the following
BOOTPROTO = dhcp 
ONBOOT = yes
 IPADDR = 192.168.116.68
NETMASK = 255.255.255.0
save and exit
network service restart
systemctl network restart
the ping 192.168.116.66 // detect what Linux2 host and host Linux1 whether the communication 
then modify the network card another piece of card Linux2 host of newly added NIC configuration file is not something,
but we can copy the contents of a file to ens34 ens32
input cp / etc / sysconfig / network-
scripts / ifcfg-ens32 / etc / sysconfig / network-scripts / ifcfg-ens34 then modify / etc / sysconfig / network-scripts / ifcfg-ens34 content profile
BOOTPROTO = static
NAME = ens34
the DEVICE ens34 =
IPADDR = 192.168.100.68
NETMASK = 255.255.255.0
save and exit
reboot the network card
systemctl restart network
due equipped with two network cards, Linux2 hosts may cause confusion, so we can win a test machine,
the network adapter ipv4 set about the IP address
i.e. 192.168.100.10 manually add subnet mask of 255.255.255.0
and then Linux2 DHCP relay server ping IP, network connectivity test
connectivity with input ping 192.168.116.66 // test server Linux1DHCP
input ping 192.168.100.10 // test win with connectivity testing machine (wait a minute may be slow connections) can all communicate
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~ ~ ~
! ! ! Then Linux1DHCP server to adjust! ! !
Linux2 linux1
the DHCP server ============= "" "DHCP relay server
192.168.116.66 card 1: 192.168.116.68 card 2: 192.168.100.68
       || ||
       || ||
       ^ ^
test test machine 1 machine 2
192.168.116.110                                                                                    192.168.100.90
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DHCP server configuration changes:
First modify NIC configuration, the DHCP Relay Gateway at network server with the IP address (the same net IP)
input   Vim / etc / sysconfig / Network-scripts / the ifcfg-ens32
the GATEWAY = 192.168.116.68 // server DHCP relay point IP network with the
save and exit
reboot the network card
systemctl restart Network
route -n // Check to see Gateway routing information is in effect
and then modify the dhcp configuration file and add the segment information, "host {}" can be removed, it is only used to bind with a fixed IP host.
Input vim /etc/dhcp/dhcpd.conf   
  added based on the original
Subnet 192.168.100.0 Netmask 255.255.255.0 {
  Range 192.168.100.50 192.168.100.200;
 Option Routers 192.168.100.1;
}
save and exit [:, $ s / 192.168. .116 / 192.168.100 / g] for the replace operation
systemctl the restart dhcpd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the DHCP relay server configuration changes :
First mount the CD, install the dhcp package
mkdir / Media / cdrom
Mount / dev / cdrom / Media / cdrom
RPM -ivh /media/cdrom/Packages/dhcp-4.2.5-36.e17.centos.x86_64.rpm
RPM - ql dhcp // query is generated when the package install something // focus is to generate / usr / sbin / dhcrelay this command
and then open the DHCP server relay route forwarding function
input   vim /etc/sysctl.conf     // modify this file add the following content
                      net.ipv4.ip_forward = 1
input sysctl -p        // entry into force of the contents of the file
to open DHCP relay service
input dhcrelay 192.168.116.66
enter netstat -lnup | grep: 67   // check the port information
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ · ~
client to test
the client's network adapter end of the IP address is changed to automatic mode to obtain
a client mode can be modified to obtain V8 net mode an IP network 116 to
a client mode modified to V2 only master mode, the network 100 can be acquired IP

Guess you like

Origin www.cnblogs.com/elin989898/p/11401933.html