linux(RHEL7)--配置DHCP服务器

linux 8个月前 散逸
浏览:552 0

环境: Red Hat Enterprise Linux 7(红帽RHEL7)
两台虚拟机,一台做DHCP服务器,一台测试


DHCP服务器

1.修改网卡配置文件

vi /etc/sysconfig/network-scripts/ifcfg-ens33

systemctl restart network

ip a

配置:
BOOTPROTO="static"
ONBOOT="yes"

IPADDR=192.168.26.3
NETMASK=255.255.255.0
GATEWAY=192.168.26.2
DNS1=114.114.114.114

VMnet8网卡配置:
ip:192.168.26.1
掩码:255.255.255.0
网关:192.168.26.2
DNS:114.114.114.114

网络模式修改为NAT,将 使用本地DHCP服务 取消 ,下面子网ip对应。

2.用yum命令安装DHCP

rpm -qa | grep dhcp

①挂载ISO安装镜像

mkdir /iso
mount /dev/cdrom /iso
vim /etc/yum.repos.d/dvd.repo

dvd.repo文件内容:
[dvd]
name=dvd
baseurl=file:///iso
gpgcheck=0
enabled=1

yum clean all
yum info dhcp
yum install dhcp -y
rpm -qa | grep dhcp

vi /etc/dhcp/dhcpd.conf
cd /etc/dhcp
cp /usr/share/doc/dhcp*/dhcpd.conf.example dhcpd.conf
vi /etc/dhcp/dhcpd.conf

配置:
48 subnet 192.168.26.0 netmask 255.255.255.0 {
49 range 192.168.26.10 192.168.26.20;
50 option domain-name-servers ns1.internal.example.org;
51 option domain-name "internal.example.org";
52 option routers 192.168.26.2;
53 option broadcast-address 192.168.26.255;
54 default-lease-time 600;
55 max-lease-time 7200;
56 }

systemctl restart dhcpd
systemctl enable dhcpd

克隆一台

BOOTPROTO="dhcp"
systemctl restart network
ip a

将ip mask dns gateway 全部删除
重启网卡
查看获取到的ip

如果不行,设置防火墙 selinux

版权声明:散逸 发表于 2019-11-18 19:39:23。
转载请注明:linux(RHEL7)--配置DHCP服务器 | 散逸-博客-导航

暂无评论

暂无评论...