一、三层交换机综合实验
拓扑图
网段规划如图所示
实验目的:第一台PC PING通最后一台PC
1、配置trunk
core-1
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho core-1
core-1(config)#int range f0/1 - 3
core-1(config-if-range)#switchport trunk encapsulation dot1q
core-1(config-if-range)#switchport mode trunk
core-1(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
core-2
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho core-2
core-2(config)#int range f0/1 - 3
core-2(config-if-range)#switchport trunk encapsulation dot1q
core-2(config-if-range)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
sw1
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho sw
Switch(config)#ho sw1
sw1(config)#int range f0/3 - 4
sw1(config-if-range)#switchport mode trunk
sw2
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho sw2
sw2(config)#int range f0/3 - 4
sw2(config-if-range)#switchport mode trunk
2、创建VTP
选择core-1创建VTP并创建vlan,其他交换机会自动学习到。
core-1(config)#vtp domain admin
Changing VTP domain name from NULL to admin
core-1(config)#vlan 10
core-1(config-vlan)#exit
core-1(config)#vlan 20
core-1(config-vlan)#exit
core-1(config)#vlan 30
core-1(config-vlan)#exit
core-1(config)#vlan 40
core-1(config-vlan)#exit
core-1(config)#
检查sw1是否学习到
3、在二层交换机上将端口加入VLAN
sw1
sw1(config)#int f0/1
sw1(config-if)#switchport access vlan 10
sw1(config-if)#exit
sw1(config)#int f0/2
sw1(config-if)#switchport access vlan 20
sw2
sw2(config)#int f0/1
sw2(config-if)#switchport access vlan 30
sw2(config-if)#exit
sw2(config)#int f0/2
sw2(config-if)#switchport access vlan 40
sw2(config-if)#exit
4、起三层配网关
core-1:
ip routing 开启三层路由功能
int vlan 10
ip add 10.1.1.252 255.255.255.0
no shut
exit
int vlan 20
ip add 20.1.1.252 255.255.255.0
no shut
exit
int vlan 30
ip add 30.1.1.252 255.255.255.0
no shut
exit
int vlan 40
ip add 40.1.1.252 255.255.255.0
no shut
exit
core-1(config)#do show ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/1 unassigned YES unset up up
FastEthernet0/2 unassigned YES unset up up
FastEthernet0/3 unassigned YES unset up up
FastEthernet0/4 unassigned YES unset down down
FastEthernet0/5 unassigned YES unset down down
FastEthernet0/6 unassigned YES unset down down
FastEthernet0/7 unassigned YES unset down down
FastEthernet0/8 unassigned YES unset down down
FastEthernet0/9 unassigned YES unset down down
FastEthernet0/10 unassigned YES unset down down
FastEthernet0/11 unassigned YES unset down down
FastEthernet0/12 unassigned YES unset down down
FastEthernet0/13 unassigned YES unset down down
FastEthernet0/14 unassigned YES unset down down
FastEthernet0/15 unassigned YES unset down down
FastEthernet0/16 unassigned YES unset down down
FastEthernet0/17 unassigned YES unset down down
FastEthernet0/18 unassigned YES unset down down
FastEthernet0/19 unassigned YES unset down down
FastEthernet0/20 unassigned YES unset down down
FastEthernet0/21 unassigned YES unset down down
FastEthernet0/22 unassigned YES unset down down
FastEthernet0/23 unassigned YES unset down down
FastEthernet0/24 unassigned YES unset down down
GigabitEthernet0/1 unassigned YES unset down down
GigabitEthernet0/2 unassigned YES unset down down
Vlan1 unassigned YES unset administratively down down
Vlan10 10.1.1.252 YES manual up up
Vlan20 20.1.1.252 YES manual up up
Vlan30 30.1.1.252 YES manual up up
Vlan40 40.1.1.252 YES manual up up
core-2:
ip routing
int vlan 10
ip add 10.1.1.253 255.255.255.0
no shut
exit
int vlan 20
ip add 20.1.1.253 255.255.255.0
no shut
exit
int vlan 30
ip add 30.1.1.253 255.255.255.0
no shut
exit
int vlan 40
ip add 40.1.1.253 255.255.255.0
no shut
exit
core-2(config)#do show ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/1 unassigned YES unset up up
FastEthernet0/2 unassigned YES unset up up
FastEthernet0/3 unassigned YES unset up up
FastEthernet0/4 unassigned YES unset down down
FastEthernet0/5 unassigned YES unset down down
FastEthernet0/6 unassigned YES unset down down
FastEthernet0/7 unassigned YES unset down down
FastEthernet0/8 unassigned YES unset down down
FastEthernet0/9 unassigned YES unset down down
FastEthernet0/10 unassigned YES unset down down
FastEthernet0/11 unassigned YES unset down down
FastEthernet0/12 unassigned YES unset down down
FastEthernet0/13 unassigned YES unset down down
FastEthernet0/14 unassigned YES unset down down
FastEthernet0/15 unassigned YES unset down down
FastEthernet0/16 unassigned YES unset down down
FastEthernet0/17 unassigned YES unset down down
FastEthernet0/18 unassigned YES unset down down
FastEthernet0/19 unassigned YES unset down down
FastEthernet0/20 unassigned YES unset down down
FastEthernet0/21 unassigned YES unset down down
FastEthernet0/22 unassigned YES unset down down
FastEthernet0/23 unassigned YES unset down down
FastEthernet0/24 unassigned YES unset down down
GigabitEthernet0/1 unassigned YES unset down down
GigabitEthernet0/2 unassigned YES unset down down
Vlan1 unassigned YES unset administratively down down
Vlan10 10.1.1.253 YES manual up up
Vlan20 20.1.1.253 YES manual up up
Vlan30 30.1.1.253 YES manual up up
Vlan40 40.1.1.253 YES manual up up
PC配置IP
5、热备份
虚拟网关
core1:
int vlan 10
stan 10 ip 10.1.1.254 创建组号10 设置IP
stan 10 prior 200 设置优先级
stan 10 preempt 配置占先权
stan 10 track f0/4 跟踪端口
exit
int vlan 20
stan 20 ip 20.1.1.254
stan 20 prior 200
stan 20 preempt
stan 20 track f0/4
exit
int vlan 30
stan 30 ip 30.1.1.254
stan 30 prior 195
stan 30 preempt
exit
int vlan 40
stan 40 ip 40.1.1.254
stan 40 prior 195
stan 40 preempt
exit
core2:
int vlan 10
stan 10 ip 10.1.1.254
stan 10 prior 195
stan 10 preempt
exit
int vlan 20
stan 20 ip 20.1.1.254
stan 20 prior 195
stan 20 preempt
exit
int vlan 30
stan 30 ip 30.1.1.254
stan 30 prior 200
stan 30 preempt
stan 30 track f0/4
exit
int vlan 40
stan 40 ip 40.1.1.254
stan 40 prior 200
stan 40 preempt
stan 40 track f0/4
exit
6、路由部分配置IP
core-1
core-1>en
core-1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
core-1(config)#int f0/4
core-1(config-if)#ip add 50.1.1.2 255.255.255.0
core-1(config-if)#no shut
core-2
core-2>en
core-2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
core-2(config)#int f0/4
core-2(config-if)#ip add 60.1.1.2 255.255.255.0
core-2(config-if)#no shut
core-2(config-if)#exit
zong-GW
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho zong-GW
zong-GW(config)#int f0/0
zong-GW(config-if)#ip add 50.1.1.1 255.255.255.0
zong-GW(config-if)#no shut
zong-GW(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
zong-GW(config-if)#exit
zong-GW(config)#int f0/1
zong-GW(config-if)#ip add 60.1.1.1 255.255.255.0
zong-GW(config-if)#no shut
zong-GW(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
zong-GW(config-if)#
zong-GW(config-if)#exit
zong-GW(config)#int f1/0
zong-GW(config-if)#ip add 70.1.1.1 255.255.255.0
zong-GW(config-if)#no shut
zong-GW(config-if)#
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
zong-GW(config-if)#exit
liantong-R1
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho liantong-R1
liantong-R1(config)#
liantong-R1(config)#int f0/0
liantong-R1(config-if)#ip add 70.1.1.2 255.255.255.0
liantong-R1(config-if)#no shut
liantong-R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
liantong-R1(config-if)#
liantong-R1(config-if)#exit
liantong-R1(config)#int f0/1
liantong-R1(config-if)#ip add 80.1.1.1 255.255.255.0
liantong-R1(config-if)#no shut
liantong-R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
liantong-R1(config-if)#
liantong-R1(config-if)#
liantong-R1(config-if)#exit
liantong-R2
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho liantong-R2
liantong-R2(config)#int f0/0
liantong-R2(config-if)#ip add 80.1.1.2 255.255.255.0
liantong-R2(config-if)#no shut
liantong-R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
liantong-R2(config-if)#
liantong-R2(config-if)#exit
liantong-R2(config)#int f0/1
liantong-R2(config-if)#ip add 90.1.1.254 255.255.255.0
liantong-R2(config-if)#no shut
liantong-R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
liantong-R2(config-if)#exit
liantong-R2(config)#
最后一套PC配置IP
7、配置路由条目
core-1
core-1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
core-1(config)#ip route 0.0.0.0 0.0.0.0 50.1.1.1
core-1(config)#do sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 50.1.1.1 to network 0.0.0.0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Vlan10
20.0.0.0/24 is subnetted, 1 subnets
C 20.1.1.0 is directly connected, Vlan20
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, Vlan30
40.0.0.0/24 is subnetted, 1 subnets
C 40.1.1.0 is directly connected, Vlan40
50.0.0.0/24 is subnetted, 1 subnets
C 50.1.1.0 is directly connected, FastEthernet0/4
S* 0.0.0.0/0 [1/0] via 50.1.1.1
core-2
core-2>en
core-2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
core-2(config)#ip route 0.0.0.0 0.0.0.0 60.1.1.1
core-2(config)#do sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 60.1.1.1 to network 0.0.0.0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Vlan10
20.0.0.0/24 is subnetted, 1 subnets
C 20.1.1.0 is directly connected, Vlan20
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, Vlan30
40.0.0.0/24 is subnetted, 1 subnets
C 40.1.1.0 is directly connected, Vlan40
60.0.0.0/24 is subnetted, 1 subnets
C 60.1.1.0 is directly connected, FastEthernet0/4
S* 0.0.0.0/0 [1/0] via 60.1.1.1
liantong-R2
liantong-R2(config)#ip route 0.0.0.0 0.0.0.0 80.1.1.1
liantong-R2(config)#
liantong-R1
往左走配默认路由
liantong-R1(config)#ip route 90.1.1.0 255.255.255.0 80.1.1.2
liantong-R1(config)#ip route 0.0.0.0 0.0.0.0 70.1.1.1
zong-GW
zong-GW>en
zong-GW#conf t
Enter configuration commands, one per line. End with CNTL/Z.
zong-GW(config)#ip route 80.1.1.0 255.255.255.0 70.1.1.2
zong-GW(config)#ip route 90.1.1.0 255.255.255.0 70.1.1.2
zong-GW(config)#ip route 10.1.1.0 255.255.255.0 50.1.1.2
zong-GW(config)#ip route 20.1.1.0 255.255.255.0 50.1.1.2
zong-GW(config)#ip route 10.1.1.0 255.255.255.0 60.1.1.2 2
zong-GW(config)#ip route 20.1.1.0 255.255.255.0 60.1.1.2 2
zong-GW(config)#ip route 30.1.1.0 255.255.255.0 60.1.1.2
zong-GW(config)#ip route 30.1.1.0 255.255.255.0 50.1.1.2 2
zong-GW(config)#ip route 40.1.1.0 255.255.255.0 60.1.1.2
zong-GW(config)#ip route 40.1.1.0 255.255.255.0 50.1.1.2 2
zong-GW(config)#do sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
S 10.1.1.0 [1/0] via 50.1.1.2
20.0.0.0/24 is subnetted, 1 subnets
S 20.1.1.0 [1/0] via 50.1.1.2
30.0.0.0/24 is subnetted, 1 subnets
S 30.1.1.0 [1/0] via 60.1.1.2
40.0.0.0/24 is subnetted, 1 subnets
S 40.1.1.0 [1/0] via 60.1.1.2
50.0.0.0/24 is subnetted, 1 subnets
C 50.1.1.0 is directly connected, FastEthernet0/0
60.0.0.0/24 is subnetted, 1 subnets
C 60.1.1.0 is directly connected, FastEthernet0/1
70.0.0.0/24 is subnetted, 1 subnets
C 70.1.1.0 is directly connected, FastEthernet1/0
80.0.0.0/24 is subnetted, 1 subnets
S 80.1.1.0 [1/0] via 70.1.1.2
90.0.0.0/24 is subnetted, 1 subnets
S 90.1.1.0 [1/0] via 70.1.1.2
PING测试
第一台PC PING最后一台PC