Dhcp服务
动态主机设置协议(Dynamic Host Configuration Protocol, DHCP)是一个局域网的网络协议,使用UDP协议工作,主要有两个用途:给内部网络或网络服务供应商自动分配IP地址给用户给内部网络管理员作为对所有计算机作中央管理的手段。
给局域网内自动分配地址
1、查看Dhcp服务其配置
[root@localhost ~]# yum install dhcp -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
–> Running transaction check
—> Package dhcp.x86_64 12:4.2.5-58.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
**Package Arch Version Repository Size
=========================================================================================**
Installing:
dhcp x86_64 12:4.2.5-58.el7 base 513 k
**Transaction Summary
=========================================================================================**
Install 1 Package
Total download size: 513 k
Installed size: 1.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 12:dhcp-4.2.5-58.el7.x86_64 1/1
Verifying : 12:dhcp-4.2.5-58.el7.x86_64 1/1
Installed:
dhcp.x86_64 12:4.2.5-58.el7
Complete!
2、查看配置文件
[root@localhost ~]# rpm -ql dhcp
/etc/NetworkManager
/etc/NetworkManager/dispatcher.d
/etc/NetworkManager/dispatcher.d/12-dhcpd
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/dhcp/scripts
/etc/dhcp/scripts/README.scripts
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/usr/bin/omshell
/usr/lib/systemd/system/dhcpd.service
/usr/lib/systemd/system/dhcpd6.service
/usr/lib/systemd/system/dhcrelay.service
/usr/sbin/dhcpd
/usr/sbin/dhcrelay
/usr/share/doc/dhcp-4.2.5
/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
/usr/share/doc/dhcp-4.2.5/dhcpd6.conf.example
/usr/share/doc/dhcp-4.2.5/ldap
/usr/share/doc/dhcp-4.2.5/ldap/README.ldap
/usr/share/doc/dhcp-4.2.5/ldap/dhcp.schema
/usr/share/doc/dhcp-4.2.5/ldap/dhcpd-conf-to-ldap
/usr/share/man/man1/omshell.1.gz
/usr/share/man/man5/dhcpd.conf.5.gz
/usr/share/man/man5/dhcpd.leases.5.gz
/usr/share/man/man8/dhcpd.8.gz
/usr/share/man/man8/dhcrelay.8.gz
/usr/share/systemtap/tapset/dhcpd.stp
/var/lib/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
3、单网段配置:
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
ddns-update-style interim; ###定义所支持的DNS动态更新类型,表示DNS互动更新模式
ignore client-updates; #####忽略客户机的DNS更新记录
subnet 172.16.50.0 netmask 255.255.255.0 {
option routers 172.16.50.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 114.114.114.114;
range dynamic-bootp 172.16.50.100 172.16.50.254;
default-lease-time 60;
max-lease-time 60;
}
结果如图: