在之前的第一篇的博文中,我已经写过三层交换实验,本篇将在前文的基础是进行更进一步扩展,在三层交换机上配DHCP中继,路由器上配置DHCP服务。

实验环境:DynamipsGUI_2.8_CN和vpcs_0.16c
 
实验拓扑:
实验配置
 
一、路由器与交换机基本配置
 
1、配置主机名
R(config)#hostname ×××
 
2、配置使能加密密码
R(config)#enable secret ×××
 
3、禁用DNS
R(config)#no ip domain-lookup
 
4、配置超时与显示同步
R(config)#line console 0
R(config-line)#exec-timeout 0 0
R(config-line)#logging synchronous
 
二、实验要求配置
 
SW-2L
 
1、划分VLAN,并将相应的端口加入到VLAN
SW-2L#vlan database
SW-2L(vlan)#vlan 2
SW-2L(vlan)#vlan 3
 
SW-2L(config)#interface f0/2
SW-2L(config-if)#switchport access vlan 2
 
SW-2L(config)#interface f0/3
SW-2L(config-if)#switchport access vlan 3
 
2、配置Trunk链路
SW-2L(config)#interface f0/14
SW-2L(config-if)#switchport mode trunk
 
SW-3L
 
1、划分VLAN
SW-3L#vlan database
SW-3L(vlan)#vlan 2
SW-3L(vlan)#vlan 3
 
2、配置各VLAN的IP地址
SW-3L(config)#interface vlan 1
SW-3L(config-if)#ip address 192.168.1.254 255.255.255.0
SW-3L(config-if)#ip helper-address 10.1.1.2
sW-3L(config-if)#no shutdown
 
SW-3L(config)#interface vlan 2
SW-3L(config-if)#ip address 192.168.2.254 255.255.255.0
SW-3L(config-if)#ip helper-address 10.1.1.2
SW-3L(config-if)#no shutdown
 
SW-3L(config)#interface vlan 3
SW-3L(config-if)#ip address 192.168.3.254 255.255.255.0
SW-3L(config-if)#ip helper-address 10.1.1.2
SW-3L(config-if)#no shutdown
 
3、配置Trunk链路
SW-3L(config)#interface f0/14
SW-3L(config-if)#switchport mode trunk
 
4、开启路由功能
SW-3L(config)#ip routing
 
5、配置端口f0/15为路由端口
SW-3L(config)#interface f0/15
SW-3L(config-if)#no switchport
SW-3L(config-if)#ip address 10.1.1.1 255.0.0.0
SW-3L(config-if)#no shutdown
 
6、配置默认路由
SW-3L(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
 
R
 
***路由器实验要求常规配置***
 
1、配置接口IP地址
R(config)#interface f0/0
R(config-if)#ip address 10.1.1.2 255.0.0.0
R(config-if)#no shutdown
 
2、配置静态路由
R(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.1
R(config)#ip route 192.168.2.0 255.255.255.0 10.1.1.1
R(config)#ip route 192.168.3.0 255.255.255.0 10.1.1.1
 
***路由器DHCP服务配置***
 
1、开启DHCP服务
R(config)#service dhcp
 
2、配置不分配给客户端的IP地址
R(config)#ip dhcp excluded-address 192.168.1.254
R(config)#ip dhcp excluded-address 192.168.2.254
R(config)#ip dhcp excluded-address 192.168.3.254
 
3、配置VLAN1的DHCP地址池
R(config)#ip dhcp pool vlan1
R(dhcp-config)#network 192.168.1.0 255.255.255.0
R(dhcp-config)#default-router 192.168.1.254
R(dhcp-config)#dns-server 202.103.24.68 202.103.0.117
R(dhcp-config)#lease 7
 
4、配置VLAN2的DHCP地址池
R(config)#ip dhcp pool vlan2
R(dhcp-config)#network 192.168.2.0 255.255.255.0
R(dhcp-config)#default-router 192.168.2.254
R(dhcp-config)#dns-server 202.103.24.68 202.103.0.117
R(dhcp-config)#lease 7
 
5、配置VLAN3的DHCP地址池
R(config)#ip dhcp pool vlan3
R(dhcp-config)#network 192.168.3.0 255.255.255.0
R(dhcp-config)#default-router 192.168.3.254
R(dhcp-config)#dns-server 202.103.24.68 202.103.0.117
R(dhcp-config)#lease 7
 
三、实验相关查看命令
 
1、查看FIB表
SW-3L(config)#show ip cef
 
2、查看邻接关系表
SW-3L(config)#show adjacency detail
 
实验验证:
 
1、如下图所示各pc都获得了相应的IP地址
 
 
2、如下图所示,各PC都能Ping通路由器
 
 

实验的配置文档已经上传,需要的朋友可以下载!