Approximate experimental topological diagram
Configuration of the DHCP server side
1. Install DHCP
Yum Install DHCP
2. Copy the configuration file
CP /usr/share/doc/dhcp-4.1. 1
3. Edit the configuration file
# vim /etc/dhcp/dhcpd.conf
(1) Default lease time
#指定默认的租约时间的长度, units: seconds Default-lease-time 3600;
(2) Maximum lease time
(3) How to log records
#日志记录的方式log-facility local7; #意味着服务启动后可在/var/log/message,/var/log/boot.log see the log of the DHCP service # because local7* 's log way path is specified in/etc/rsyslog.conf: # cat/etc/ rsyslog.conf# Save boot messages also to Boot.log local7.*/var/log/boot.log
(4) Dhcp-dns Interactive Update mode
#配置DHCP-dns for interactive update mode ddns-update-style none; #因为DHCP客户端取得的IP通常是一直变动的, so the host name of a host with the IP of the corresponding relationship is difficult to process # Setting this option means that DHCP can update the host name and IP by DDNS. Set to none if not required.
(5) Ignore the DNS update feature of the client
Ignore client-updates;
(6) Domain name settings
Option Domain-name "Centos.vbird"; #当你要查找主机名时, the DNS system will automatically help you to find the host name after adding this domain suffix # This setting will modify the client's/etc/resolv.conf file, we will see two lines of content: Search Centos.vbirddomain Centos.vbird
(7) Assigning DNS to clients
#最多写3个option domain-name-servers 8.8.8.8,202.103.96.112; #这个设置可以修改客户端的/etc/resolv.conf file, which is also one of the network parameters that the server can assign to clients, we will see: nameserver 8.8.8.8 nameserver 202.103.96.112
(8) Subnet network address netmask subnet mask {...}
#IP分配设置 (address pool) Subnet 172.16.10.0 netmask 255.255.255.0 { range 172.16.10.2 172.16.10.100; #设置一个可以分配给客户端的IP地址范围 range 172.16.10.200 172.16.10.250; #range可以有多段 option routers 172.16.10.1; #给客户端分配的网关 default-lease-time 7200; #注意如果这些配置参数写到subnet {}, the local variable is the quasi- max-lease-time 15400;} subnet 172.16.20.0 netmask 255.255.255.0 { # Here is the range 172.16.20.2 172.16.20.100 set for another network segment ; Range 172.16.20.200 172.16.20.250;
(9) host hostname {...}
#在需要的情况下给某一客户端固定分配一IPhost sxkj #这个主机名可以自己设 { hardware Ethernet 00:0c:29:b6:df:5e; #客户端的MAC fixed-address 172.16.10.10; #给予的固定IP}
(10) More setup parameters can be viewed by man
# man 5 dhcpd.conf
4. write the name of the NIC that provides the DHCP service to the/ETC/SYSCONFIG/DHCPD file (when there are more than two cards)
cat /etc/sysconfig/dhcpd Dhcpdargs="eth0"
5. Turn on the DHCP service
6. monitoring and viewing of logs, ports, etc.
Cat /var/log/message tail - f/var/log/ boot.loggrep dhcpd #查看监听端口udp 0 0 0.0. 0.0: 0.0. 0.0:* 3211/DHCPD
Configuration of the DHCP relay side (Relay server)
1. turn on the Routing and forwarding function of the relay server
# vim/etc/sysctl.conf 1 -P #重新加载/etc/sysctl.conf make settings effective
2. Set relay Options
# vim/etc/sysconfig/dhcrelay INTERFACES="eth0 eth1" Dhcpservers="172.16.10.1" #写出真正要找的DHCP服务器
3. Start the DHCP Relay service
# service Dhcrelay Start
DHCP Client Authentication
1. Using DHCP to obtain IP
# dhclient-r eth0: Release IP address
# dhclient eth0: Obtain IP, require the network card configuration file to use the DHCP method to obtain IP
# Bootproto=dhcp: In the NIC configuration file
2. What are the client file changes after a successful configuration?
#/etc/resolv.conf: Domain name inside and DNS server will and Configuration "domain_name", "Domain_name_server"
# Route-n: Can see the changes to the route
# NETSTAT-TLUNP | grep DHCP
#/var/lib/dhclient/dhclient-eth0.leases: The client also has a lease file that records the DHCP information that the NIC has requested
3. The client is Windows
# ipconfig/release: Release IP
# ipconfig/renew: Get IP
[DHCP service]--a verified DHCP principle experiment (VMware)