利用GUN3+VMware 搭建 多网段DHCP服务 (DHCP服务 环境Centos7 )
利用GUN3+VMware 搭建 多网段DHCP服务 (DHCP服务 环境Centos7 )
一.开始准备
1.Centos 7 DHCPServer 不懂可以借鉴这个文章:https://www.cnblogs.com/guns/p/13576140.html
2.Gns3
3.模拟网络环境
4.
5.
二.搭建网络环境
1.编辑ESW1 交换机
A.创建vlan (vlan100/vlan200/vlan210/vlan220/vlan230)
vlan database //进入vlan模式
vlan 100 name Server //创建vlan 100 标注 Server
参考图:
B.配置各个vlan网络配置
ip addess xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx //配置IP/掩码
ip helper-address xxx.xxx.xxx.xxx //配置DHCP服务器地址
C.配置DHCP服务器地址
ip dhcp-server 192.168.0.69
D.配置trunk链路 (端口: F1/1 - 5)
switchport trunk encapsulation dot1q
switchport mode trunk
F.
2.编辑20F-SW1/21F-SW1/22F-SW1/23F-SW1/Server-SW1 (只做一台交换机的配置其他可以复制修改部分参数即可)
A.关闭路由
no ip routing
B.创建VLAN 240
vlan database
vlan 240 name 24F
C.vlan网络配置
ip addess xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
D.配置access模式 (接电PC端的所有端口需要配置access模式)
switchport mode access
switchport access vlan 240.
E.配置trunk链路 (F0/15)
switchport trunk encapsulation dot1q
switchport mode trunk
F.
G.
3.
4.
5
三.配置DHCP_Server(本段主要说明DHCP的配置文件)
1.编辑DHCP配置文件(注意配置文件的分号和括号)
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
subnet 10.8.100.0 netmask 255.255.255.0 {
range 10.8.100.30 10.8.100.220;
option routers 10.8.100.7;
}
2.
3.
4.
5.
四.调试
1.清楚DHCP缓存
修改了dhcp的default-lease-time && max-lease-time
清除缓存:
rm /var/lib/dhcpd/dhcpd.leases
echo "" > /var/lib/dhcpd/dhcpd.leases
2.重启DHCP / 启动DHCP / 查看DHCP
systemctl restart dhcpd
systemctl start dhcpd 或 service dhcpd start
systemctl status dhcpd
3.查询DHCP配置文件conf 路径 /查看配置文件内容 /编辑配置文件
rpm -qc dhcp
cat /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
4.DHCP端口监听查询
netstat -anpu | grep dhcp
5.查看网关
route -n
6.查看DHCP缓存文件
cat /var/lib/dhcpd/dhcpd.leases
7.开机自启
systemctl start dhcpd
systemctl enable dhcpd
systemctl status dhcpd
8.
五.测试
1.
2.
3.
4.
5.