实验目的:
- 掌握中小型园区网络的基本部署
- 熟悉中小型园区网络的部署流程、排错思路
实验拓扑:
实验要求:
一、设备管理
- 依据图中拓扑,为不同设备定义主机名。
//更改路由器名
IOU1(config)#hostname R1
R1(config)#
IOU2(config)#hostname Internet
Internet(config)#
//更改交换机名
IOU3(config)#hostname sw1
sw1(config)#
IOU4(config)#hostname sw2
sw2(config)#
IOU5(config)#hostname sw3
sw3(config)#
//更改计算机名
IOU6(config)#hostname pc1
pc1(config)#
IOU7(config)#hostname pc2
pc2(config)#
- 全局关闭域名解析
R1(config)#no ip domain lookup
sw1(config)#no ip domain lookup
sw2(config)#no ip domain lookup
sw3(config)#no ip domain lookup
PC1(config)#no ip domain lookup
PC2(config)#no ip domain lookup
Internet(config)#no ip domain lookup
- Console和vty线路下关闭线路超时并开启输出同步。
//sw1配置
sw1(config)#line console 0
sw1(config-line)#logging synchronous
sw1(config-line)#exec-timeout 0 0
sw1(config)#line vty 0 4
sw1(config-line)#logging synchronous
sw1(config-line)#exec-timeout 0 0
//sw2
sw2(config)#line console 0
sw2(config-line)#logging synchronous
sw2(config-line)#exec-timeout 0 0
sw2(config)#line vty 0 4
sw2(config-line)#logging synchronous
sw2(config-line)#exec-timeout 0 0
//sw3
sw3(config)#line console 0
sw3(config-line)#logging synchronous
sw3(config-line)#exec-timeout 0 0
sw3(config)#line vty 0 4
sw3(config-line)#logging synchronous
sw3(config-line)#exec-timeout 0 0
//R1
R1(config)#line console 0
R1(config-line)#logging synchronous
R1(config-line)#exec-timeout 0 0
R1(config)#line vty 0 4
R1(config-line)#logging synchronous
R1(config-line)#exec-timeout 0 0
- 为实现安全登陆,要求创建本地用户名bdqn,密码benet,并将其调用到console和vty线路下;要求设置特权密码benet,并要求加密存储。
//R1配置
R1(config)#username bdqn privilege 15 password benet
R1(config)#line console 0
R1(config-line)#login local
R1(config-line)#exit
R1(config)#line vty 0 4
R1(config-line)#login local
R1(config-line)#exit
R1(config)#enable secret benet
//sw1配置
sw1(config)#username bdqn privilege 15 password benet
sw1(config)#enable secret benet
sw1(config)#line console 0
sw1(config-line)#login local
sw1(config-line)#exit
sw1(config)#line vty 0 4
sw1(config-line)#login local
sw1(config-line)#exit
//sw2配置
sw2(config)#username bdqn privilege 15 password benet
sw2(config)#enable secret benet
sw2(config)#line console 0
sw2(config-line)#login local
sw2(config-line)#exit
sw2(config)#line vty 0 4
sw2(config-line)#login local
sw2(config-line)#exit
//sw3配置
sw3(config)#username bdqn privilege 15 password benet
sw3(config)#enable secret benet
sw3(config)#line console 0
sw3(config-line)#login local
sw3(config-line)#exit
sw3(config)#line vty 0 4
sw3(config-line)#login local
sw3(config-line)#exit
- 所有交换机管理vlan为vlan1,所在网段为192.168.1.0/24,其中sw1的管理IP为192.168.1.1/24,sw2为192.168.1.2/24,sw3为192.168.1.3/24,要求能够实现远程管理。
//sw1配置
sw1(config)#int vlan 1
sw1(config-if)#ip address 192.168.1.1 255.255.255.0
sw1(config-if)#no shutdown
//sw2配置
sw2(config)#int vlan 1
sw2(config-if)#ip address 192.168.1.2 255.255.255.0
sw2(config-if)#no shutdown
//sw3配置
sw3(config)#int vlan 1
sw3(config-if)#ip address 192.168.1.3 255.255.255.0
sw3(config-if)#no shutdown
二、交换技术
1、Trunk技术
所有交换机之间强制启用Trunk,并采用802.1Q进行封装。
//sw1配置
sw1(config)#int range e0/1-3
sw1(config-if-range)#switchport trunk encapsulation dot1q
sw1(config-if-range)#switchport mode trunk
sw1(config-if-range)#ex
//sw2配置
sw2(config)#int range e0/1-3
sw2(config-if-range)#switchport trunk encapsulation dot1q
sw2(config-if-range)#switchport mode trunk
sw2(config-if-range)#ex
//sw3配置
sw3(config)#int range e0/0-1
sw3(config-if-range)#switchport trunk encapsulation dot1q
sw3(config-if-range)#switchport mode trunk
sw3(config-if-range)#ex
全局native vlan定义为vlan10。
要求Trunk上只允许vlan1、10、20的数据通过。
//SW1配置
SW1(config)#interface range e0/1-3
SW1(config-if-range)#switchport trunk native vlan 10
SW1(config-if-range)#switchport trunk allowed vlan 1,10,20
SW1(config-if-range)#end
//Sw2配置
SW2(config)#interface range e0/1-3
SW2(config-if-range)#switchport trunk native vlan 10
SW2(config-if-range)#switchport trunk allowed vlan 1,10,20
SW2(config-if-range)#end
//sw3配置
SW2(config)#interface range e0/0-1
SW2(config-if-range)#switchport trunk native vlan 10
SW2(config-if-range)#switchport trunk allowed vlan 1,10,20
SW2(config-if-range)#end
2、VTY技术
sw1为Server,其他交换机为client。
//sw1配置
sw1(config)#vtp mode server
//sw2配置
sw2(config)#vtp mode client
//sw3配置
sw3(config)#vtp mode client
vty管理域为dbqn,密码为benet
//sw1
sw1(config)#vtp domain bdqn
sw1(config)#vtp password benet
//sw2
sw2(config)#vtp domain bdqn
sw2(config)#vtp password benet
//sw3
sw3(config)#vtp domain bdqn
sw3(config)#vtp password benet
全局开启vtp修剪
//sw1,2,3
sw1(config)#vtp pruning
sw2(config)#vtp pruning
sw2(config)#vtp pruning
在sw1上创建vlan10、20,并要求同步
//在vtp服务端
sw1(config)# vlan 10,20
sw1(config-vlan)#ex
将不同用户接口放入相应vlan中。
//在接入层设备配置
sw3(config)#int e0/2
sw3(config-if)#switchport mode access
sw3(config-if)#switchport access vlan 10
sw3(config-if)#no shutdown
sw3(config-if)#ex
sw3(config)#int e0/3
sw3(config-if)#switchport mode access
sw3(config-if)#switchport access vlan 20
sw3(config-if)#no shutdown
3、STP技术
部署PVST,要求SW1为vlan10的root,vlan20的secondary,sw2为vlan20的root,vlan10的secondary,实现负载均衡。
//sw1配置
sw1(config)#spanning-tree mode pvst
sw1(config)#spanning-tree vlan 10 root primary
sw1(config)#spanning-tree vlan 20 root secondary
//sw2配置
sw2(config)#spanning-tree mode pvst
sw2(config)#spanning-tree vlan 10 root secondary
sw2(config)#spanning-tree vlan 20 root primary
开启Portfast,加速用户接入网络接口。
//在接入层设备的access接口配置
sw3(config)#int range e0/2-3
sw3(config-if-range)#spanning-tree portfast
开启Uplinkfast,加速直连链路收敛
//在接入层设备配置
sw3(config)#spanning-tree uplinkfast
开启Backbonefast,加速骨干链路收敛
//sw1配置
sw1(config)#spanning-tree backbonefast
//sw2配置
sw2(config)#spanning-tree backbonefast
//sw3配置
sw3(config)#spanning-tree backbonefast
4、L3Switching技术
sw1作为vlan10的主网关,vlan20的备网关,其中vlan10地址为192.168.10.252/24,vlan20地址为192.168.20.252/24;sw2作为vlan20的主网关,vlan10的备网关,其中vlan10网关为192.168.10.253/24,vlan20网关为192.168.20.253/24.
//SW1配置
sw1(config)#int vlan 10
sw1(config-if)#ip address 192.168.10.254 255.255.255.0
sw1(config-if)#standby 10 priority 110
sw1(config-if)#standby 10 ip 192.168.10.254
sw1(config-if)#standby 10 preempt
sw1(config)#int vlan 20
sw1(config-if)#ip address 192.168.20.252 255.255.255.0
sw1(config-if)#standby 20 ip 192.168.20.254
sw1(config-if)#standby 20 priority 90
sw1(config-if)#standby 20 preempt
//sw2配置
sw2(config)# int vlan 10
sw2(config-if)#ip address 192.168.10.253 255.255.255.0
sw2(config-if)#standby 10 ip 192.168.10.254
sw2(config-if)#standby 10 priority 90
sw2(config-if)#standby 10 preempt
sw2(config)#int vlan 20
sw2(config-if)#ip address 192.168.20.253 255.255.255.0
sw2(config-if)#standby 20 ip 192.168.20.254
sw2(config-if)#standby 20 priority 110
sw2(config-if)#standby 20 preempt
在sw1和sw2上部署HSRP,vlan10的网关为192.168.10.254,vlan20的网关为192.168.20.254
//SW1配置
sw1(config-if)#standby 10 ip 192.168.10.254
sw1(config-if)#standby 20 ip 192.168.20.254
//sw2配置
sw2(config-if)#standby 10 ip 192.168.10.254
sw2(config-if)#standby 20 ip 192.168.20.254
在sw1部署DHCP服务,方便不同vlan的主机接入网络,其中主DNS为202.96.128.86,备用dns为119.29.29.29
sw1(config)#ip dhcp pool 10
sw1(dhcp-config)#network 192.168.10.0
sw1(dhcp-config)#default-router 192.168.10.254
sw1(dhcp-config)#dns-server 202.96.128.86 119.29.29.29
sw1(config)#ip dhcp pool 20
sw1(dhcp-config)#network 192.168.20.0
sw1(dhcp-config)#default-router 192.168.20.254
sw1(dhcp-config)#dns-server 202.96.128.86 119.29.29.29
在三层交换机上开启三层路由功能,并要求vlan间主机能够互相通信
sw1(config)#ip routing
5、Ethernetchannel激素
为实现链路冗余并提供网络宽带,要求在汇聚层交换机之间部署L2ethernetchannel技术
//sw1
sw1(config)#int range e0/1-2
sw1(config-if-range)#channel-group 1 mode on
//sw2
sw2(config)#int range e0/1-2
sw2(config-if-range)#channel-group 1 mode on
6、Port-Security技术
为实现用户接入安全,要求所有用户接入接口启用端口安全技术
sw3(config)#int e0/2
sw3(config-if)#switchport port-security mac-address sticky
sw3(config-if)#switchport port-security violation shutdown
sw3(config-if)#ex
sw3(config)#errdisable recovery cause all
sw3(config)#errdisable recovery interval 30
sw3(config)#int e0/3
sw3(config-if)#switchport port-security mac-address sticky
sw3(config-if)#switchport port-security violation shutdown
sw3(config-if)#ex
sw3(config)#errdisable recovery cause all
sw3(config)#errdisable recovery interval 30
开启地址学习,并定义最大MAC数为1
//在接入层access端口配置
sw3(config-if)#switchport port-security maximum 1
定义用户违反规则为shutdown模式,并要求在30s后自动恢复
//在接入层全局配置
sw3(config)#errdisable recovery cause all
sw3(config)#errdisable recovery interval 30
三、路由技术
在三层交换机sw1、sw2和R1上部署动态路由协议OSPF,并通告到骨干区域中
//R1
R1(config)#router ospf 1
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.2.0 0.0.0.255 area 0
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#ex
//SW1
sw1(config)#router ospf 1
sw1(config-router)#network 172.16.1.0 0.0.0.255 area 0
sw1(config-router)#redistribute connected subnets
//SW2
sw2(config)#router ospf 1
sw2(config-router)#network 172.16.2.0 0.0.0.255 area 0
sw2(config-router)#redistribute connected subnets
在边缘路由器R1上部署默认路由,用于访问互联网
//R1配置
R1(config)#ip route 0.0.0.0 0.0.0.0 100.1.1.2
R1(config-router)#default-information originate always
四、安全策略
要求只允许管理员地址192.168.10.1/24能够远程访问边缘路由器R1
//配置标准ACL
R1(config)#access-list 1 permit host 192.168.10.1
//将标准ACL应用与vty
R1(config-line)#access-class 1 in
为实现内网主机访问互联网,要求部署PAT技术
R1(config)#access-list 2 permit 192.168.10.0 0.0.0.255
R1(config)#access-list 2 permit 192.168.20.0 0.0.0.255
R1(config)#ip nat inside source list 2 interface e0/0 overload
R1(config)#int e0/0
R1(config-if)#ip nat outside
R1(config)#int e0/1
R1(config-if)#ip nat inside
R1(config-if)#int e0/2
R1(config-if)#ip nat inside
测试