'''SW1配置trunk接口模式'''
en
conf t
host SW1
intrange f0/1-4
switchport trunk encapsulation dot1q
sw m t
exit
'''SW2配置trunk接口模式'''
en
conf t
host SW2
intrange f0/1-4
switchport trunk encapsulation dot1q
sw m t
exit
'''SW3配置trunk接口模式'''
en
conf t
ho SW3
intrange f0/3-4
sw m t
exit
'''SW4配置trunk接口模式'''
en
conf t
ho SW4
int f0/3
sw m t
exit
int f0/4
sw m t
exit
'''SW5配置trunk接口模式'''
en
conf t
ho SW5
int f0/3
sw m t
exit
int f0/4
sw m t
exit
'''查看配置结果'''
do show vlan #如果接口成功配置为trunk,则不会在vlan表中显示。
第1.2步 配置VTP域及创建VLAN类型
配置VTP可以在2个核心交换机或3个二层交换机中配置。
创建VLAN需要一个个创建。
'''SW1配置VTP域及创建VLAN类型'''
en
conf t
vtp domain qq
vlan 10
exit
vlan 20
exit
vlan 30
exit
vlan 40
exit
vlan 50
exit
'''查看配置结果'''
do show vlan #检查各个交换机是否成功根据VTP生成所需VLAN
第1.3步 划分接口至对应VLAN
对于二层交换机,需要将每个接口按VLAN分类设置。
'''为SW3划分接口至相应VLAN'''
en
conf t
int f0/1
sw ac vlan 10int f0/2
sw ac vlan 20
exit
'''为SW4划分接口至相应VLAN'''
en
conf t
int f0/1
sw ac vlan 30int f0/2
sw ac vlan 40
exit
'''为SW5划分接口至相应VLAN'''
en
conf t
int f0/1
sw ac vlan 50int f0/2
sw ac vlan 50
exit
'''查看配置结果'''
do show vlan #检查各个交换机是否成功根据VTP生成所需VLAN
'''为SW1创建虚拟接口配置IP并设置DHCP中继'''
en
conf t
ip routing
int vlan 10
no shut
ip add 192.168.1.252255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 20
no shut
ip add 192.168.2.252255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 30
no shut
ip add 192.168.3.252255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 40
no shut
ip add 192.168.4.252255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 50
no shut
ip add 192.168.5.252255.255.255.0
ip helper-address 192.168.5.1
exit
'''为SW1升级接口为三级接口并配置IP'''
en
conf t
int f0/5
no switchport
no shut
ip add 192.168.100.1255.255.255.0
exit
int f0/6
no switchport
no shut
ip add 192.168.102.1255.255.255.0
exit
int f0/7
no switchport
no shut
ip add 192.168.106.1255.255.255.0
exit
'''为SW2创建虚拟接口配置IP并设置DHCP中继'''
en
conf t
ip routing
int vlan 10
no shut
ip add 192.168.1.253255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 20
no shut
ip add 192.168.2.253255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 30
no shut
ip add 192.168.3.253255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 40
no shut
ip add 192.168.4.253255.255.255.0
ip helper-address 192.168.5.1
exit
int vlan 50
no shut
ip add 192.168.5.253255.255.255.0
ip helper-address 192.168.5.1
exit
'''为SW2升级接口为三级接口并配置IP'''
en
conf t
int f0/5
no switchport
no shut
ip add 192.168.101.1255.255.255.0
exit
int f0/6
no switchport
no shut
ip add 192.168.103.1255.255.255.0
exit
int f0/7
no switchport
no shut
ip add 192.168.107.1255.255.255.0
exit
'''查看配置结果'''
show ip int b #检查各个vlan及实体接口IP
'''为SW1创建HSRP热备份'''
en
conf t
int vlan 10
stan 10 ip 192.168.1.254
stan 10 prior 200
stan 10 preempt
stan 10 track f0/5
stan 10 track f0/6
exit
int vlan 20
stan 20 ip 192.168.2.254
stan 20 prior 200
stan 20 preempt
stan 20 track f0/5
stan 20 track f0/6
exit
int vlan 30
stan 30 ip 192.168.3.254
stan 30 prior 200
stan 30 preempt
stan 30 track f0/5
stan 30 track f0/6
exit
int vlan 40
stan 40 ip 192.168.4.254
stan 40 prior 200
stan 40 preempt
stan 40 track f0/5
stan 40 track f0/6
exit
int vlan 50
stan 50 ip 192.168.5.254
stan 50 prior 195
stan 50 preempt
stan 50 track f0/5
stan 50 track f0/6
exit
'''为SW2创建HSRP热备份'''
en
conf t
int vlan 10
stan 10 ip 192.168.1.254
stan 10 prior 195
stan 10 preempt
stan 10 track f0/5
stan 10 track f0/6
exit
int vlan 20
stan 20 ip 192.168.2.254
stan 20 prior 195
stan 20 preempt
stan 20 track f0/5
stan 20 track f0/6
exit
int vlan 30
stan 30 ip 192.168.3.254
stan 30 prior 195
stan 30 preempt
stan 30 track f0/5
stan 30 track f0/6
exit
int vlan 40
stan 40 ip 192.168.4.254
stan 40 prior 195
stan 40 preempt
stan 40 track f0/5
stan 40 track f0/6
exit
int vlan 50
stan 50 ip 192.168.5.254
stan 50 prior 200
stan 50 preempt
stan 50 track f0/5
stan 50 track f0/6
exit
'''查看配置结果'''
show standby breif #查看HSRP配置结果,断线测试优先级需要在后续路由器配置后'''ping测试'''
手动为PC1与PC2配置IP,测试两个VLAN间能否正常通信。
在PT6.0版本此处ping不通,因为仿真平台存在bug,在8.0版本可以ping通。
第1.6步 路由器配置IP
根据网络规划,对路由器每个接口配置IP。
'''为R1接口配置IP'''
en
conf t
ho R1
int f0/0
no shut
ip add 192.168.100.2255.255.255.0
exit
int f0/1
no shut
ip add 192.168.101.2255.255.255.0
exit
int f1/0
no shut
ip add 100.1.1.1255.255.255.0
exit
'''为R2接口配置IP'''
en
conf t
ho R2
int f0/0
no shut
ip add 192.168.102.2255.255.255.0
exit
int f0/1
no shut
ip add 192.168.103.2255.255.255.0
exit
int f1/0
no shut
ip add 101.1.1.1255.255.255.0
exit
'''为R3接口配置IP'''
en
conf t
ho R3
int f0/0
no shut
ip add 192.168.104.2255.255.255.0
exit
int f0/1
no shut
ip add 192.168.105.2255.255.255.0
exit
int f1/0
no shut
ip add 192.168.106.2255.255.255.0
exit
int f1/1
no shut
ip add 192.168.107.2255.255.255.0
exit
'''为R4接口配置IP'''
en
conf t
ho R4
int f0/0
no shut
ip add 192.168.6.254255.255.255.0
exit
int f0/1
no shut
ip add 192.168.104.1255.255.255.0
exit
'''为R5接口配置IP'''
en
conf t
ho R5
int f0/0
no shut
ip add 192.168.7.254255.255.255.0
exit
int f0/1
no shut
ip add 192.168.105.1255.255.255.0
exit
'''为R6接口配置IP'''
en
conf t
ho R6
int f0/0
no shut
ip add 100.1.1.2255.255.255.0
exit
int f0/1
no shut
ip add 101.1.1.2255.255.255.0
exit
int f1/0
no shut
ip add 102.1.1.254255.255.255.0
exit
int f1/1
no shut
ip add 103.1.1.2255.255.255.0
exit
'''为R7接口配置IP'''
en
conf t
ho R7
int f0/0
no shut
ip add 103.1.1.1255.255.255.0
exit
int f0/1
no shut
ip add 10.1.1.254255.255.255.0
exit
'''查看配置结果'''
show standby breif #断线测试优先级需要在后续路由器配置后
第1.7步 路由器配置路由表
由于为采用RIP动态路由配置时,容易形成优先级相同的路径,本实验采用静态路由表配置的方式进行。
对于路由表条目优先级,静态路由>动态路由>默认路由。
建议先使用show ip router 查看直连路由表有哪些,在进行配置。
'''为SW1配置静态路由表'''
en
conf t
ip route 192.168.6.0255.255.255.0192.168.106.2
ip route 192.168.7.0255.255.255.0192.168.106.2
ip route 192.168.104.0255.255.255.0192.168.106.2
ip route 192.168.105.0255.255.255.0192.168.106.2
ip route 0.0.0.00.0.0.0192.168.100.2
ip route 0.0.0.00.0.0.0192.168.102.22'''为SW2配置静态路由表'''
en
conf t
ip route 192.168.6.0255.255.255.0192.168.107.2
ip route 192.168.7.0255.255.255.0192.168.107.2
ip route 192.168.104.0255.255.255.0192.168.107.2
ip route 192.168.105.0255.255.255.0192.168.107.2
ip route 0.0.0.00.0.0.0192.168.101.2
ip route 0.0.0.00.0.0.0192.168.103.22'''为R3配置RIP静态路由表'''
en
conf t
ip route 192.168.6.0255.255.255.0192.168.104.1
ip route 192.168.7.0255.255.255.0192.168.105.1
ip route 0.0.0.00.0.0.0192.168.106.1
ip route 0.0.0.00.0.0.0192.168.107.12'''为R4配置默认路由表'''
en
conf t
ip route 0.0.0.00.0.0.0192.168.104.2'''为R5配置静态路由表'''
en
conf t
ip route 0.0.0.00.0.0.0192.168.105.2'''查看配置结果'''
show ip router #查看路由表是否收敛'''ping测试'''
手动为PC1与PC6配置IP,测试总部与分部间能否正常通信。
'''为R1配置静态路由表'''
en
conf t
ip route 0.0.0.00.0.0.0100.1.1.2
ip route 192.168.1.0255.255.255.0192.168.100.1
ip route 192.168.2.0255.255.255.0192.168.100.1
ip route 192.168.3.0255.255.255.0192.168.100.1
ip route 192.168.4.0255.255.255.0192.168.100.1
ip route 192.168.5.0255.255.255.0192.168.100.1
ip route 192.168.6.0255.255.255.0192.168.100.1
ip route 192.168.7.0255.255.255.0192.168.100.1
ip route 192.168.104.0255.255.255.0192.168.100.1
ip route 192.168.105.0255.255.255.0192.168.100.1
ip route 192.168.106.0255.255.255.0192.168.100.1
ip route 192.168.107.0255.255.255.0192.168.100.1
ip route 192.168.1.0255.255.255.0192.168.101.12
ip route 192.168.2.0255.255.255.0192.168.101.12
ip route 192.168.3.0255.255.255.0192.168.101.12
ip route 192.168.4.0255.255.255.0192.168.101.12
ip route 192.168.5.0255.255.255.0192.168.101.12
ip route 192.168.6.0255.255.255.0192.168.101.12
ip route 192.168.7.0255.255.255.0192.168.101.12
ip route 192.168.104.0255.255.255.0192.168.101.12
ip route 192.168.105.0255.255.255.0192.168.101.12
ip route 192.168.106.0255.255.255.0192.168.101.12
ip route 192.168.107.0255.255.255.0192.168.101.12'''为R2配置静态路由表'''
en
conf t
ip route 0.0.0.00.0.0.0101.1.1.2
ip route 192.168.1.0255.255.255.0192.168.103.1
ip route 192.168.2.0255.255.255.0192.168.103.1
ip route 192.168.3.0255.255.255.0192.168.103.1
ip route 192.168.4.0255.255.255.0192.168.103.1
ip route 192.168.5.0255.255.255.0192.168.103.1
ip route 192.168.6.0255.255.255.0192.168.103.1
ip route 192.168.7.0255.255.255.0192.168.103.1
ip route 192.168.104.0255.255.255.0192.168.103.1
ip route 192.168.105.0255.255.255.0192.168.103.1
ip route 192.168.106.0255.255.255.0192.168.103.1
ip route 192.168.107.0255.255.255.0192.168.103.1
ip route 192.168.1.0255.255.255.0192.168.102.12
ip route 192.168.2.0255.255.255.0192.168.102.12
ip route 192.168.3.0255.255.255.0192.168.102.12
ip route 192.168.4.0255.255.255.0192.168.102.12
ip route 192.168.5.0255.255.255.0192.168.102.12
ip route 192.168.6.0255.255.255.0192.168.102.12
ip route 192.168.7.0255.255.255.0192.168.102.12
ip route 192.168.104.0255.255.255.0192.168.102.12
ip route 192.168.105.0255.255.255.0192.168.102.12
ip route 192.168.106.0255.255.255.0192.168.102.12
ip route 192.168.107.0255.255.255.0192.168.102.12'''为R6配置静态路由表'''
en
conf t
ip route 0.0.0.00.0.0.0103.1.1.1'''为R7配置静态路由表'''
en
conf t
ip route 0.0.0.00.0.0.0103.1.1.2'''查看配置结果'''
show ip router #查看路由表是否收敛'''ping测试'''
测试PC1是否能ping通R1、R2接口上的IP。
测试PC8是否能ping通R1、R2外接口上的IP。
第2.2步 为总路由接口设置NAT转换表
根据路由器R1、R2上接口的内外网方向进行定义,f0/0、f0/1是内网接口,f1/0是外网接口。
'''为R1配置NAT转换表,设置内网网段规则并应用于外网接口上'''
en
conf t
int f0/0
ip nat inside
exit
int f0/1
ip nat inside
exit
int f1/0
ip nat outside
exit
acc 1 permit 192.168.0.00.0.255.255
ip nat inside source list1int f1/0 overload
'''为R2配置NAT转换表,设置内网网段规则并应用于外网接口上'''
en
conf t
int f0/0
ip nat inside
exit
int f0/1
ip nat inside
exit
int f1/0
ip nat outside
exit
acc 1 permit 192.168.0.00.0.255.255
ip nat inside source list1int f1/0 overload
'''ping测试'''
测试PC1是否能ping通PC8接口上的IP。
'''为R1配置ACL'''
en
conf t
ip access-list extended deny-to-internet
deny ip 192.168.6.00.255.255.255any
deny ip 192.168.7.00.255.255.255any
petmit ip anyany
exit
int f1/0
ip access-group deny-to-internet out
exit
'''为R2配置NAT转换表,设置内网网段规则并应用于外网接口上'''
en
conf t
ip access-list extended deny-to-internet
deny ip 192.168.6.00.255.255.255any
deny ip 192.168.7.00.255.255.255any
petmit ip anyany
exit
int f1/0
ip access-group deny-to-internet out
exit
'''ping测试'''
成功阻止分部上网。