CentOS 7 下搭建 DHCP
来源:互联网 发布:黑客技术软件 编辑:程序博客网 时间:2024/06/05 23:22
声明下啊:第一次发帖,菜鸟一枚,忘大牛多指点一二啊!
1.1. 安装篇
# mkdir /mnt/cdrom/
# mount /dev/cdrom /mnt/cdrom
# cd/mnt /cdrom/Packages/
# ls dhcp*
dhcp-4.2.5-27.el7.centos.x86_64.rpm
dhcp-common-4.2.5-27.el7.centos.x86_64.rpm
dhcp-libs-4.2.5-27.el7.centos.x86_64.rpm
# rpm -Uvhdhcp-4.2.5-27.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:dhcp-12:4.2.5-27.el7.centos ################################# [100%]
Tips:如果你是高手或者电脑能联网,建议用yum安装,特别方便啊!
# yum -y install dhcpd
1.2. 配置
# rpm -qc dhcp //查询和DHCP相关的配置文件
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/var/lib/dhcpd/dhcpd.leases
/var/lib/dhcpd/dhcpd6.leases
# cd /etc/dhcp/
# cp dhcpd.conf dhcpd.conf.origin //更改之前新备份,以备不测,
# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
查看示例文件 //我们可以根据这个example 快速的生成一个配置文件,而且不容易有错
# more /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
根据例子文件我们可以生成一个配置文件,可以配置两个网段的,一个网段就是一个subnet
# vi/etc/dhcp/dhcpd.conf
option domain-name "lee.local";
option domain-name-servers 192.168.188.11, 192.168.188.12;
default-lease-time 691200;
max-lease-time 691200;
subnet 192.168.188.0 netmask 255.255.255.0 {
range 192.168.188.100 192.168.188.159;
range 192.168.188.170 192.168.188.253;
default-lease-time 259200;
max-lease-time 259200;
option routers 192.168.188.2;
}
subnet 192.168.189.0 netmask 255.255.255.0 {
range 192.168.189.100 192.168.189.253;
option routers 192.168.189.2;
}
host printer1 {
hardware ethernet 00:12:34:56:78:90;
fixed-address 192.168.188.111;
}
Tips :default-lease-timetime;
Time should be the length in seconds thatwill be assigned to a lease if the client requesting the leasedoes not ask fora specific expiration time. This is used for both DHCPv4 and DHCPv6leases (it is also known as the "valid lifetime" in DHCPv6). The default is 43200 seconds.
max-lease-timetime;
Time should be the maximum length in seconds that will beassigned to a lease. If not defined,thedefault maximum lease time is 86400. Theonly exception to this is that Dynamic BOOTP lease lengths,which are notspecified by the client, are not limited by this maximum.# systemctl start dhcpd.service //启动服务,和以前的service dhcpd start的效果等同,
查看日志文件
Internet Systems Consortium DHCP Server 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
Listening on LPF/eno16777728/00:0c:29:a4:2e:39/192.168.188.0/24
Sending on LPF/eno16777728/00:0c:29:a4:2e:39/192.168.188.0/24
Sending on Socket/fallback/fallback-net
配置DHCPD为自动启动, 这在CentOS 7上的新的变化 了
#systemctl enable dhcpd.service // 原来的是 chkconfig dhcpd on# systemctlis-enabled dhcpd
enabled //出现这个单词,证明已经设置为开机启动了。
1.3. 测试
在一台Windows客户机上进行测试
Tips:这个dns是我先前设置的,方便上网。
# tail /var/lib/dhcpd/dhcpd.leases //当客户机租用IP地址时,会在日志中看到
DHCPINFORM from 192.168.188.100 via eno16777728: not authoritative for subnet 192.168.188.0
DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728
1.4. 总结
- CentOS 7 下搭建 DHCP
- centos 下dhcp服务搭建教程
- CentOS搭建DHCP服务
- centos dhcp服务器搭建
- centos 6.5 搭建dhcp服务器
- CentOs 6.8 DHCP 服务搭建
- Linux下搭建DHCP server
- RHEL6下搭建DHCP服务器
- Linux(centos 6.8)搭建DHCP服务器
- Centos 7下搭建SS
- Linux系统下搭建DHCP服务器
- CentOS6.6下DHCP环境搭建
- Linux环境下DHCP服务器的搭建
- linux下的dhcp服务器的搭建
- redhat Linux6下搭建DHCP服务器
- Fedora搭建服务器,DHCP+TFTP+FTP+PXE启动安装CentOS
- DHCP搭建
- Linux centos 7下搭建mosquitto
- 利用LruCache加载网络图片实现图片瀑布流效果(基础版)
- 即时通讯软件openfire+spark+smack
- 自己动手写CPU之第六阶段(3)——移动操作指令的实现
- 拿来主义!最火的iOS开源项目(一)
- Android NDK开发轻松入门
- CentOS 7 下搭建 DHCP
- Azkaban博客
- mysql中的 skip-name-resolve 问题
- easyui 分页
- WebPartManager与SQL
- SQL Server雨情处理自动补数据
- 拿来主义!最火的iOS开源项目(二)
- 从java网络编程学起(4)
- Xcode 模拟器黑屏或闪退解决方法