公司要求将闲置的一台Linux主机配置为DHCP服务器,以便为局域网内员工的办公用机提供自动分配IP地址服务,提高网络管理和维护的效率。
需求描述
给局域网内各主机自动分配的IP地址范围为192.168.10.20~192.168.10.30
局域网内各主机使用的默认网关地址为192.168.10.2
局域网内各主机使用的DNS服务器地址分别为202.96.128.86,202.96.128.1,DNS服务器的主机名为ns1.bdqn.com
网络打印机设备(可在网络内另找一台Windows主机,执行“ipconfig / all”命令查知其MAC地址)的主机名称为prtsvr,要求自动分配固定IP地址为192.168.10.100。
下载dhcp服务器
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# rpm -q dhcp
未安装软件包 dhcp
[root@localhost ~]# rpm -ivh /mnt/Packages/dhcp-4.2.5-68.el7.centos.1.x86_64.rpm
警告:/mnt/Packages/dhcp-4.2.5-68.el7.centos.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:dhcp-12:4.2.5-68.el7.centos.1 ################################# [100%]
[root@localhost ~]#
[root@localhost ~]# cd /etc/dhcp/
[root@localhost dhcp]# ls
dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts
[root@localhost dhcp]# cat dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
[root@localhost dhcp]#
/usr/share/doc/dhcp*/dhcpd.conf.example
[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
#
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.20 192.168.10.30;
option domain-name-servers 202.96.128.86,202.96.128.1;
option domain-name "ns1.bdqn.com";
option routers 192.168.10.2;
option broadcast-address 192.168.10.255;
default-lease-time 600;
max-lease-time 7200;
}
host prtsvr {
hardware ethernet 00:0C:29:4F:EB:9C;
fixed-address "192.168.10.100";
}
打印机获取IP地址
客户端获取IP地址
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/12171