1.1
实验任务
在
Catalyst 2950
交换机、
Catalyst 3550
交换机和
3940
路由器上实现三层交换。
1.2
实验环境和网络拓扑
1.3
完成标准
实现三层交换,使得
VLAN
之间的主机能够通信。
2
.详细操作步骤
Step 1:
指定端口
Trunk
,配置
VLAN
(1)
在
2950
交换机上指定端口
Trunk
,配置
VLAN
交换机
2950
配置如下:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho 2950
2950(config)#interface f0/1
2950(config-if)#switchport mode trunk //
配置端口
1
为中继模式
2950(config-if)#exit
2950(config)#exit
2950#vlan d
2950(vlan)#vtp domain 2t57 //
配置
VTP
域为
2t57
Changing VTP domain from NULL to 2t57
2950(vlan)#vtp server //VTP
模式为服务器模式
2950(vlan)#vlan 10 //
添加
VLAN 10
VLAN 10 added:
Name:VLAN0010
2950(vlan)#vlan 20 //
添加
VLAN 20
VLAN 20 added:
Name:VLAN0020
2950(vlan)#exit
APPLY completed.
Exiting....
2950#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
10 VLAN0010 active
20 VLAN0020 active //VLAN 10
、
20
添加成功
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
2950#conf t
Enter configuration commands, one per line. End with CNTL/Z.
2950(config)#interface f0/11
2950(config-if)#switchport access vlan 10 //
将端口
11
加入到
VLAN 10
中
2950(config-if)#interface f0/12
2950(config-if)#switchport access vlan 20 //
将端口
11
加入到
VLAN 10
中
2950(config-if)#exit
2950(config)#exit
2950#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10
10 VLAN0010 active Fa0/11
20 VLAN0020 active Fa0/12 //
端口添加成功
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
(2)
在交换机
3550
上指定
Trunk
,同步
VLAN
信息
交换机
3550
配置如下:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ho 3550
3550(config)#interface f0/1 //
配置端口
1
为中继模式
3550(config-if)#switchport mode trunk
3550(config-if)#exit
3550(config)#exit
3550#vlan d
3550(vlan)#vtp domain 2t57 //
配置
VTP
域名为
2t57
VTP domain 2t57 modified
3550(vlan)#vtp client //
配置
VTP
工作模式为客户机
3550(vlan)#exit
APPLY completed.
Exiting....
3550#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14
10 VLAN0010 active
20 VLAN0020 active //VLAN
同步成功
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
Step 2
:在
3550
上配置启动路由
交换机
3550
配置如下:
3550#conf t
Enter configuration commands, one per line. End with CNTL/Z.
3550(config)#ip routing
3550(config)#interface vlan 10
3550(config-if)#ip address 192.168.10.1 255.255.255.0 //
配置
VLAN 10
的
IP
3550(config-if)#no shut
3550(config-if)#interface vlan 20
3550(config-if)#ip address 192.168.20.1 255.255.255.0 //
配置
VLAN 20
的
IP
3550(config-if)#no shut
3550(config-if)#exit
3550(config)#exit
3550(config)#interface f0/10
3550(config-if)#no switchport //
配置端口
10
为路由接口
3550(config-if)#ip address 192.168.30.1 255.255.255.0 //
配置端口
10
的
IP
地址
3550(config-if)#no shut
3550(config-if)#exit
3550(config)#ip route 0.0.0 .0 0.0.0.0 192.168.30.2 //
配置静态路由
3550(config)#exit
3550#show 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
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, * - candidate default
U - per-user static route
Gateway of last resort is to network 0.0.0 .0
C 192.168.30.0 is directly connected, FastEthernet0/10 //30
网段直连端口
0
S* 0.0.0 .0 [1/0] via 192.168.30.2 //
静态路由下一跳地址
Step 4
:在
3640
路由器上配置路有
路由器
R1
配置如下:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho R1
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.30.2 255.255.255.0 //
配置端口
0/0
的
IP
R1(config-if)#no shut
%LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
R1(config-if)#interface f1/0 //
配置端口
1/0
的
IP
R1(config-if)#ip address 192.168.40.1 255.255.255.0
R1(config-if)#no shut
%LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
R1(config-if)#exit
%LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to down
//
端口
1/0
未连接任何设备,端口状态
down
R1(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.1 //
配置到
VLAN 10
的路由
R1(config)#ip route 192.168.20.0 255.255.255.0 192.168.30.1 //
配置到
VLAN 20
的路由
R1(config)#exit
R1#show 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
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, * - candidate default
U - per-user static route
Gateway of last resort is not set
C 192.168.30.0 is directly connected, FastEthernet0/0 //30
网段直连端口
0/0
S 192.168.10.0 [1/0] via 192.168.30.1 //
路由道
10
网段的下一跳地址
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface loopback 0 //
端口回环
0
R1(config-if)#ip address 192.168.40.1 255.255.255.0 //IP
地址
192.168.40.0 overlaps with FastEthernet1/0 //40
网段加载在端口
1/0
上
R1(config-if)#exit
R1(config)#exit
Step 4
:验证
P1
连通状态如下:
Boson BOSS 5.0 IP Configuration
Ethernet adapter Local Area Connection:
IP Address. . . . . . . . . . . . : 192.168.10.11 //P1 IP
地址
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.10.1 //
网关为
VLAN 10 IP
地址
You can also use winipcfg to configure the IP Address
C:>ping 192.168.10.11
Pinging 192.168.10.11 with 32 bytes of data:
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.10.11: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通自己
IP
,端口状态正确
C:>ping 192.168.10.1
Pinging 192.168.10.1 with 32 bytes of data:
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.10.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通网关,即
VLAN 10 IP
地址
C:>ping 192.168.20.1
Pinging 192.168.20.1 with 32 bytes of data:
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.20.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通
VLAN 20 IP
地址
C:>ping 192.168.20.22
Pinging 192.168.20.22 with 32 bytes of data:
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.20.22: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通在
VLAN 20
上的主机
P2
P2
连通状态如下:
Boson BOSS 5.0 IP Configuration
Ethernet adapter Local Area Connection:
IP Address. . . . . . . . . . . . : 192.168.20.22
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.20.1 //
网关为
VLAN 20 IP
地址
You can also use winipcfg to configure the IP Address
C:>ping 192.168.20.22
Pinging 192.168.20.22 with 32 bytes of data:
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Reply from 192.168.20.22: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.20.22: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通自己
IP
C:>ping 192.168.20.1
Pinging 192.168.20.1 with 32 bytes of data:
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Reply from 192.168.20.1: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.20.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通网关
C:>ping 192.168.10.1
Pinging 192.168.10.1 with 32 bytes of data:
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Reply from 192.168.10.1: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.10.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通
VLAN 10
网段
C:>ping 192.168.10.11
Pinging 192.168.10.11 with 32 bytes of data:
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Reply from 192.168.10.11: bytes=32 time=60ms TTL=241
Ping
statistics for 192.168.10.11: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
//ping
通在
VLAN 10
上的
P1
3
.实验总结
l
三层交换机的接口在默认情况下属于
VLAN1
,如果需要让三层交换机与路由器实现点到点的连接,需要将交换机的某个接口配置为路由接口,才能为这个接口配置
IP
地址。
l
三层交换机上配置静态或动态路由的方法与在路由器上配置路由的方法相同。
l
在实际应用中,三层交换机上一般不会直接连接用户终端,三层交换机的接口用来连接接入交换机的
Trunk
链路或服务器。
l
当二层交换机与三层交换机上相同
VLAN
中的主机通信时,是通过二层交换机的
Trunk
通信;不同的
VLAN
的主机通信时,是通过三层交换机路由通信。