1.1 实验任务 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Catalyst 2950交换机、Catalyst 3550交换机和3940路由器上实现三层交换。

 

1.2 实验环境和网络拓扑

 

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

 

 

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 1020添加成功

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 10IP

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 20IP
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            //配置端口10IP地址

3550(config-if)#no shut
3550(config-if)#exit
3550(config)#ip route <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />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/0IP

R1(config-if)#no shut
%LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
R1(config-if)#interface f1/0                                                   //配置端口1/0IP

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
//pingVLAN 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
//pingVLAN 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的主机通信时,是通过三层交换机路由通信。