DHCP服务部署流程
Posted liming-linux-python
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DHCP服务部署流程相关的知识,希望对你有一定的参考价值。
为某一局域网部署DHCP
[[email protected] ~]# yum install -y dhcp
[[email protected] ~]# rpm -ql dhcp
/usr/sbin/dhcpd:dhcp服务进程
/usr/lib/systemd/system/dhcpd.service → /etc/dhcp/dhcpd.conf → /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example(配置模板)
/usr/lib/systemd/system/dhcpd6.service → /etc/dhcp/dhcpd6.conf → /usr/share/doc/dhcp-4.2.5/dhcpd6.conf.example(配置模板)
/usr/sbin/dhcrelay:dhcp中继进程
/usr/lib/systemd/system/dhcrelay.service → /etc/dhcp/dhcpd.conf、/etc/dhcp/dhcpd6.conf
/etc/sysconfig/dhcpd
# 注意:同时只能运行一个dhcp进程
[[email protected] ~]# cat /etc/dhcp/dhcpd.conf
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
[[email protected] ~]# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example > /etc/dhcp/dhcpd.conf
[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
log-facility local7;
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.10 192.168.30.50;
option domain-name-servers 8.8.8.8;
default-lease-time 86400;
max-lease-time 86400;
}
[[email protected] ~]# dhcpd # 语法检测
Listening on LPF/eth0/00:0c:29:b2:e4:ec/192.168.30.0/24
Sending on LPF/eth0/00:0c:29:b2:e4:ec/192.168.30.0/24
Sending on Socket/fallback/fallback-net
[[email protected] ~]# systemctl start dhcpd.service
[[email protected] ~]# systemctl enable dhcpd.service
[[email protected] ~]# systemctl status dhcpd.service
Jul 04 02:26:32 dhcp.example.com systemd[1]: Started DHCPv4 Server Daemon.
[[email protected] ~]# netstat -lntup|grep dhcpd
略
[[email protected] ~]# ps -ef|grep dhcpd
略
测试
[[email protected] ~]# ip addr
127.0.0.1/8
192.168.30.137/24
[[email protected] ~]# dhclient -d -s 192.168.30.129 # -d:前台运行,-s:指定DHCP服务器
bound to 192.168.30.10 -- renewal in 41153 seconds.
[[email protected] ~]# ip addr
127.0.0.1/8
192.168.30.137/24
192.168.30.10/24
[[email protected] ~]# cat /var/lib/dhcpd/dhcpd.leases # 查看租约文件
lease 192.168.30.10 {
starts 2 2018/07/03 18:36:28;
ends 3 2018/07/04 18:36:28;
cltt 2 2018/07/03 18:36:28;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:a4:f4:35;
}
以上是关于DHCP服务部署流程的主要内容,如果未能解决你的问题,请参考以下文章