conf t
ip dhcp excluded-address 10.1.1.110.1.1.9#先预留地址后创建地址池
ip dhcp excluded-address 10.1.1.254#预留网关IP
ip dhcp pool v10 #创建一个地址池,并命名为v10,回车进入DHCP地址池配置模式
network 10.1.1.0255.255.255.0#定义地址池提供的IP及子网掩码
default-router 10.1.1.254#定义地址池提供的网关IP
dns-server 40.1.1.1#定义地址池提供的DNS服务器IP地址,在网络规划阶段就应该为各个服务器固定下IP
lease 11230#定义租期,输入3个正整数,分别对应天数、时、分,该命令在PT仿真平台不支持
exit
no ip dhcp pool v10 #删除地址池
no ip dhcp excluded-address 10.1.1.254#删除IP预留
dhcp server 根据dhcp client 提供的信息进行相应的配置,并通过dhcp relay 将配置信息发送给dhcp client,完成对dhcp client 的动态配置。
部署位置:部署于路由器的各子接口上。
最多能跨越2次VLAN。
相关命令。
int f0/0.1
ip helper-address 40.1.1.1#收到DHCP请求时,转给DHCP服务器IP地址
1.4 单臂路由的局限性
路由器接口容易成为网络通信功能的瓶颈。
所有子接口均依赖于总接口,容易单点发生故障,网络结构不够稳健。
不同VLAN之间通信的帧(大文件会有许多帧)都需要单独经过VLAN标签封装解封装、均需要单独路由。
2实验一:路由器上部署DHCP
2.1实验目的
如下网络拓补图搭配网络,注意接口号与网段规划;
构建VTP域;
路由器上部署DHCP服务器;
所有PC能自动获取IP地址并能相互ping通。
2.2部署步骤及命令
'''交换机配置命令''''''第一步:配置trunk接口模式''''''第二步:配置VTP域及创建VLAN类型''''''第三步:划分接口至对应VLAN'''# 配置第一台交换机接口模式
en
conf t
ho SW1
int f0/3
sw m t
# 配置第二台交换机接口模式
en
conf t
ho SW2
intrange f0/3-5
sw m t
# 配置第三台交换机接口模式
en
conf t
ho SW3
int f0/4
sw m t
# 配置第一台交换机为VTP server,第二三台应该同步学习配置了哪些vlan# 配置完成后利用show vlan brief查看各自配置结果
en
conf t
vtp domain qq
vlan 10
exit
vlan 20
exit
vlan 30
exit
vlan 40
exit
# 为第一台交换机划分接口至相应VLAN
en
conf t
int f0/1
sw ac vlan 10int f0/2
sw ac vlan 20# 为第二台交换机划分接口至相应VLAN
en
conf t
int f0/1
sw ac vlan 10int f0/2
sw ac vlan 30# 为第三台交换机划分接口至相应VLAN
en
conf t
int f0/1
sw ac vlan 20int f0/2
sw ac vlan 40'''路由器配置命令''''''第一步:配置子接口''''''第二步:创建DHCP地址池'''# 创建子接口并定义所属VLAN及IP,完成后使用show ip int b检查配置
en
conf t
ho R1
int f0/0
no shut
exit
int f0/0.1
no shut
encapsulation dot1q 10
ip add 10.1.1.254255.255.255.0
exit
int f0/0.2
no shut
encapsulation dot1q 20
ip add 20.1.1.254255.255.255.0
exit
int f0/0.3
no shut
encapsulation dot1q 30
ip add 30.1.1.254255.255.255.0
exit
int f0/0.4
no shut
encapsulation dot1q 40
ip add 40.1.1.254255.255.255.0
exit
# 对每个VLAN均需要单独配置,先预留IP,再创建地址池(含IP、子网掩码、网关、DNS地址)# 配置后使用do show run检查配置
en
conf t
ip dhcp excluded-address 10.1.1.110.1.1.9
ip dhcp excluded-address 10.1.1.254
ip dhcp pool v10
network 10.1.1.0255.255.255.0
default-router 10.1.1.254
dns-server 40.1.1.1
exit
ip dhcp excluded-address 20.1.1.120.1.1.9
ip dhcp excluded-address 20.1.1.254
ip dhcp pool v20
network 20.1.1.0255.255.255.0
default-router 20.1.1.254
dns-server 40.1.1.1
exit
ip dhcp excluded-address 30.1.1.130.1.1.9
ip dhcp excluded-address 30.1.1.254
ip dhcp pool v30
network 30.1.1.0255.255.255.0
default-router 30.1.1.254
dns-server 40.1.1.1
exit
'''PC端自动获取IP、DNS服务器手动配置IP'''
检查IP获取结果,检查能否ping通。
3实验二:路由器上部署DHCP中继
3.1实验目的
如下网络拓补图搭配网络,注意接口号与网段规划;
构建VTP域;
路由器上部署DHCP中继,在服务器上部署DHCP与DNS服务;
所有PC能自动获取IP地址并能相互ping通。
3.2部署步骤及命令
交换机部署命令与上实验一致。
路由器上无需配置地址池,仅需要对每个子接口设置网关IP、所属VLAN,并设置DHCP中继。
# 创建子接口并定义所属VLAN及IP,完成后使用show ip int b检查配置
en
conf t
ho R1
int f0/0
no shut
exit
int f0/0.1
no shut
encapsulation dot1q 10
ip add 10.1.1.254255.255.255.0
ip helper-address 40.1.1.1
exit
int f0/0.2
no shut
encapsulation dot1q 20
ip add 20.1.1.254255.255.255.0
ip helper-address 40.1.1.1
exit
int f0/0.3
no shut
encapsulation dot1q 30
ip add 30.1.1.254255.255.255.0
ip helper-address 40.1.1.1
exit
int f0/0.4
no shut
encapsulation dot1q 40
ip add 40.1.1.254255.255.255.0
exit