DHCP 服务测试
Posted 遠離塵世の方舟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DHCP 服务测试相关的知识,希望对你有一定的参考价值。
DHCP三个端口:
服务端:UDP 67
客户端:UDP 68
DHCPv6 客户端:UDP 546,这是需要特别开启的 DHCP failover 服务,用来做双机热备的。
实验一、DHCP服务器基本配置
在RHEL1服务器上:
yum install dhcp
vim /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.30 192.168.100.60; option domain-name-servers 192.168.100.1; option domain-name "rusky.com"; option routers 192.168.100.1; option broadcast-address 192.168.100.255; default-lease-time 3600; max-lease-time 7200; } |
systemctl restart dhcpd
在linux客户端上
nmcli connection modify eno16777736 ipv4.method auto
nmcli connection down eno16777736
nmcli connection up eno16777736
ifconfig
实验二、根据MAC地址分配固定IP
vim /etc/dhcp/dhcpd.conf
host rhel1-eno16777736 {
hardware ethernet 00:0C:29:EB:BE:10;
fixed-address 192.168.100.88;
}
--有多台主机需要分配固定IP地址,则添加多段
systemctl restart dhcpd
systemctl restart dhcpd
systemctl enable dhcpd
在linux客户端上
nmcli connection modify eno16777736 ipv4.method auto
nmcli connection down eno16777736
nmcli connection up eno16777736
在windows客户端上
设置网卡自动获取IP地址和DNS
禁用网卡再启动网卡,查看IP
实验三、DHCP中继
对不同的网段分配不同的IP地址。
在rhel1上
添加虚拟网络vnet2,关闭DHCP服务
添加新网卡eno33554984,并将其插在vnet2网络上
nmcli connection add type ethernet con-name eno33554984 ifname eno33554984
nmcli connection modify eno33554984 ipv4.method manual ipv4.addresses "10.0.0.1/24 10.0.0.1" ipv4.dns 10.0.0.1 connection.autoconnect yes
nmcli connection up eno33554984
ifconfig
vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.30 192.168.100.60; option domain-name-servers 192.168.100.1; option domain-name "rusky.com"; option routers 192.168.100.1; option broadcast-address 192.168.100.255; default-lease-time 3600; max-lease-time 7200; } subnet 10.0.0.0 netmask 255.255.255.0 { range 10.0.0.30 10.0.0.60; option domain-name-servers 10.0.0.1; option domain-name "test.com"; option routers 10.0.0.1; option broadcast-address 10.0.0.255; default-lease-time 3600; max-lease-time 7200; } |
systemctl restart dhcpd
rhel2和rhel3分别将网卡连接到vnet1和vnet2网络上,获取到不同网段的IP
实验四、清除DHCP服务器的缓存
rm -f /var/lib/dhcpd/*
systemctl restart dhcpd
以上是关于DHCP 服务测试的主要内容,如果未能解决你的问题,请参考以下文章
Renix 如何配置DHCPv4 relay场景测试——网络测试仪实操