DHCP-----Dynamic Host Configuration Protocol Protocol
Application Layer Protocol
Role: assigning IP information to clients
Principle:
1. Client sends DHCP discovery to explore DHCP server
2. DHCP server sends DHCP offer (IP/NETMASK/GATEWAY/DNS)
3. Client sends DHCP Request
4. DHCP server sends DHCP ACK
5, the client sends Gratuation ARP to detect whether the IP address conflicts
Software: DHCP
Configuration file:/etc/dhcp/dhcpd.conf
Service: DHCPD
Port: 67/UDP (DHCP server-side port), 68/UDP (DHCP client port)
Example: Configuring a DHCP server
Environment Description:
Isolated Network: Lan1 Network segment: 192.168.87.0/24
DHCP server: 192.168.87.101, dhcpserver.linux.com
Client:
Linux
Windows XP
1) Configure host name, IP address
[Email protected] ~]# Hostnamectl set-hostname server.linux.com
[Email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by Dracut INITRD
Device=eth0
Name=eth0
Onboot=yes
Bootproto=none
Type=ethernet
Ipaddr=192.168.87.101
netmask=255.255.255.0
[Email protected] ~]# systemctl Restart Network
[Email protected] ~]# systemctl restart NetworkManager
[[Email protected] ~]# IP addr Show eth0
2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 52:54:00:71:3b:1c BRD FF:FF:FF:FF:FF:FF
inet 192.168.87.101/24 BRD 192.168.87.255 Scope Global eth0
Valid_lft Forever Preferred_lft Forever
Inet6 FE80::5054:FF:FE71:3B1C/64 Scope link
Valid_lft Forever Preferred_lft Forever
2) Configure the Yum source to install the DHCP software
[Email protected] ~]# Mkdir/etc/yum.repos.d/default
[Email protected] ~]# mv/etc/yum.repos.d/centos-*/etc/yum.repos.d/default
[Email protected] ~]# Vim/etc/yum.repos.d/local.repo
[Local]
Name=localsrc
Baseurl=file:///mnt
Enabled=1
Gpgcheck=0
[Email protected] ~]# mount/dev/cdrom/mnt/
[email protected] ~]# Yum Clean all
Loaded plugins: Fastestmirror, LangPacks
Cleaning up software Source: Local
Cleaning up everything
[[email protected] ~]# yum makecache generate meta data
[Email protected] ~]#
[[email protected] ~]# Yum install-y DHCP
3) Edit the configuration file
[Email protected] ~]# vim/etc/dhcp/dhcpd.conf
Subnet 192.168.87.0 netmask 255.255.255.0 {
Range 192.168.87.10 192.168.87.100;
Option routers 192.168.87.1;
Option Domain-name-servers 114.114.114.114, 8.8.8.8;
}
[Email protected] ~]# systemctl start DHCPD
[[email protected] ~]# systemctl enable DHCPD >>> set up service boot automatically
Created symlink From/etc/systemd/system/multi-user.target.wants/dhcpd.service to/usr/lib/systemd/system/ Dhcpd.service.
[Email protected] ~]# Ss-anup | grep:67
Unconn 0 0 *:67 *:* Users: (("DHCPD", pid=1822,fd=7))
Unconn 0 0 *%virbr0:67 *:* Users: (("DNSMASQ", pid=1506,fd=3))
4) Testing
DHCP Debug:
LOG:/var/log/messages
# tail-f/var/log/messages
This article is from the "lyw666" blog, make sure to keep this source http://lyw666.blog.51cto.com/12823216/1957476
Linux Services DHCP detailed