三层交换配置路由

三层交换配置路由

问题

三层交换机实现了VLAN间互通后,还要与其他网络进行通信,这样就需要有相关的路由机制。
1)交换接口配置为三层接口实现路由间通信

方案

三层交换机既然具有三层功能,也就可以实现与路由器相似的配置。既可以把交换接口配置为三层接口,也可以在其上配置静态、动态路由。通过对三层交换机的路由配置,实现VLAN与其他网络的互通。
网络的拓扑结构如图所示:
三层交换配置路由_第1张图片

步骤

实现此案例需要按照如下步骤进行。

步骤一:VLAN等配置与上面2 三层交换vlan间通信通完全一致,不再赘述

步骤二:将三层交换的Fa0/23口配置为三层路由端口,并配置IP地址

三层交换机的物理端口默认是二层端口,只具有二层特性,不能配置IP地址。把二层端口配置为三层端口后,该端口就具备路由功能了,可以配置IP地址,但同时也就关闭了其二层特性,比如不能把三层端口加入VLAN。
二层端口(交换机上的端口默认都是二层端口)默认是激活状态,那些没有使用到的端口为了安全应该手工将其禁用(shutdown);而三层端口(路由器上的端口或是三层交换机上被配置成路由端口的端口)默认是禁用状态,在使用之前务必要将其激活(no shutdown)。

tarenasw-3L(config)#interface f0/23
tarenasw-3L(config-if)#no switchport 
tarenasw-3L(config-if)#ip address 192.168.10.2 255.255.255.0
tarenasw-3L(config-if)#no shutdown

步骤三:配置路由器的端口IP地址

tarena-rouer(config)#interface f0/0
tarena-rouer(config-if)#ip address 192.168.10.1 255.255.255.0
tarena-rouer(config-if)#no shutdown
tarena-rouer(config-if)#interface f0/1
tarena-rouer(config-if)#ip address 200.1.1.1 255.255.255.0
tarena-rouer(config-if)#no shutdown

步骤四:在三层交换机上配置默认路由,以便VLAN内主机可以与外界网络互联

tarenasw-3L(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.1
tarenasw-3L(config)#exit
tarenasw-3L#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
       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 192.168.10.1 to network 0.0.0.0
C    192.168.1.0/24 is directly connected, Vlan1
C    192.168.2.0/24 is directly connected, Vlan2
C    192.168.3.0/24 is directly connected, Vlan3
C    192.168.10.0/24 is directly connected, FastEthernet0/23
S*   0.0.0.0/0 [1/0] via 192.168.10.1

步骤五:在路由器上配置到达三个VLAN网络的静路由

tarena-rouer(config)#ip route 192.168.1.0 255.255.255.0 192.168.10.2
tarena-rouer(config)#ip route 192.168.2.0 255.255.255.0 192.168.10.2
tarena-rouer(config)#ip route 192.168.3.0 255.255.255.0 192.168.10.2
tarena-rouer(config)#exit
tarena-rouer#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
       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
S    192.168.1.0/24 [1/0] via 192.168.10.2
S    192.168.2.0/24 [1/0] via 192.168.10.2
S    192.168.3.0/24 [1/0] via 192.168.10.2
C    192.168.10.0/24 is directly connected, FastEthernet0/0
C    200.1.1.0/24 is directly connected, FastEthernet0/1
tarena-rouer#

步骤六:在Server上测试与三个VLAN的连通性

SERVER>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:8FFF:FE14:BB43
IP Address......................: 200.1.1.10
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 200.1.1.1
SERVER>ping 192.168.1.10
Pinging 192.168.1.10 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.10: bytes=32 time=0ms TTL=126
Reply from 192.168.1.10: bytes=32 time=0ms TTL=126
Reply from 192.168.1.10: bytes=32 time=1ms TTL=126
Ping statistics for 192.168.1.10:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
SERVER>ping 192.168.2.10
Pinging 192.168.2.10 with 32 bytes of data:
Reply from 192.168.2.10: bytes=32 time=0ms TTL=126
Reply from 192.168.2.10: bytes=32 time=0ms TTL=126
Reply from 192.168.2.10: bytes=32 time=0ms TTL=126
Reply from 192.168.2.10: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.2.10:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
SERVER>ping 192.168.3.10
Pinging 192.168.3.10 with 32 bytes of data:
Reply from 192.168.3.10: bytes=32 time=1ms TTL=126
Reply from 192.168.3.10: bytes=32 time=0ms TTL=126
Reply from 192.168.3.10: bytes=32 time=0ms TTL=126
Reply from 192.168.3.10: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.3.10:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
SERVER>

你可能感兴趣的:(三层交换配置路由)