三层交换机动态路由
本篇文章给大家谈谈三层交换机动态路由,以及三层交换机动态路由实验总结对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、cisco Switching-三层交换配置路由
- 2、cisco Switching-三层交换配置RIP动态路由
- 3、怎么利用三层交换机来实现VLAN间路由
- 4、三层交换机怎么实现VLAN间路由
- 5、华为三层交换机如何开启路由器功能?
- 6、如何在路由器与三层交换机之间采用OSPF动态路由?不使用vlan
cisco Switching-三层交换配置路由
三层交换机实现了VLAN间互通后,还要与其他网络进行通信,这样就需要有相关的路由机制。
交换接口配置为三层接口实现路由间通信
三层交换机既然具有三层功能,也就可以实现与路由器相似的配置。既可以把交换接口配置为三层接口,也可以在其上配置静态、动态路由。通过对三层交换机的路由配置,实现VLAN与其他网络的互通。
Switchenable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#vlan 3
Switch(config-vlan)#vlan 4
Switch(config-vlan)#vlan 5
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 2
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 3
Switch(config-if)#ip address 192.168.3.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 4
Switch(config-if)#ip address 192.168.4.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 5
Switch(config-if)#ip address 192.168.5.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#ip routing //开启路由功能
Switch(config)#interface range f0/23-24
Switch (config-if-range)#switchport trunk encapsulation dot1q
Switch (config-if-range)#switchport mode trunk
Sw1(config)#vlan 2
Sw1(config)#vlan 2
Sw1(config-vlan)#vlan 3
Sw1(config)#interface fastEthernet 0/2
Sw1(config-if)#switchport access vlan 2
Sw1(config)#interface fastEthernet 0/3
Sw1(config-if)#switchport access vlan 3
Sw1(config)#interface fastEthernet 0/5
Sw1(config-if)#switchport mode trunk //连接三层交换机的接口配置为trunk模式
Sw2(config)#vlan 4
Sw2(config-vlan)#vlan 5
Sw2(config)#interface fastEthernet 0/1
Sw2(config-if)#switchport access vlan 4
Sw2(config)#interface f0/2
Sw2(config-if)#switchport access vlan 5
三层交换机的物理端口默认是二层端口,只具有二层特性,不能配置IP地址。把二层端口配置为三层端口后,该端口就具备路由功能了,可以配置IP地址,但同时也就关闭了其二层特性,比如不能把三层端口加入VLAN。
二层端口(交换机上的端口默认都是二层端口)默认是激活状态,那些没有使用到的端口为了安全应该手工将其禁用(shutdown);而三层端口(路由器上的端口或是三层交换机上被配置成路由端口的端口)默认是禁用状态,在使用之前务必要将其激活(no shutdown)。
Switch(config)#interface f0/6
Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.6.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface f0/0
Switch(config-if)#ip address 192.168.6.2 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#interface f0/1
Switch(config-if)#ip address 192.168.7.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#iproute 192.168.7.0 255.255.255.0 192.168.6.2 //格式 ip route 下一跳
Switch(config)#exit
Switch#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
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.4.0/24 is directly connected, Vlan4
C 192.168.5.0/24 is directly connected, Vlan5
C 192.168.6.0/24 is directly connected, FastEthernet0/6
S 192.168.7.0/24 [1/0] via 192.168.6.2
tarena-rouer(config)#ip route 192.168.1.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.2.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.3.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.4.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.5.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#exit
tarena-rouer#show ip rout
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.6.1
S 192.168.2.0/24 [1/0] via 192.168.6.1
S 192.168.3.0/24 [1/0] via 192.168.6.1
S 192.168.4.0/24 [1/0] via 192.168.6.1
S 192.168.5.0/24 [1/0] via 192.168.6.1
C 192.168.6.0/24 is directly connected, FastEthernet0/0
C 192.168.7.0/24 is directly connected, FastEthernet0/1
PCipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:8FFF:FE14:BB43
IP Address......................: 192.168.7.1
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.7.254
SERVERping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=1ms TTL=126
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
SERVERping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
SERVERping 192.168.3.1
Pinging 192.168.3.1 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
cisco Switching-三层交换配置RIP动态路由
在三层交换机上配置RIP路由协议,以三层交换机代替路由器。
通过RIP实现路由间通信
动态路由协议配置灵活,路由器会发送自身的路由信息给其他路由器,同时也会接收其他路由器发来的路由信息建立自己的路由表。这样在路由器上就不必像静态路由那样为每个目标地址都配置路由,因为路由器可以通过协议学习这些路由。网络拓扑改变,路由信息也会自动更新,无需管理员干预。
Switch(config)#interface f0/6
Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.6.1 255.255.255.0
Switch(config-if)#no shutdown
RIP路由协议在配置network时,只需要配置该路由器所直连的主类网络,不与该路由器直连的网络不需要包含在network中。
RIP默认工作在第一版本下,但是RIP-V1是有类路由协议,而且通过广播的方式进行路由更新,无论是功能上还是效率上都有一些缺陷,这些缺陷RIP-V2可以弥补。在使用时建议采用RIP-V2而不是RIP-V1。
tarenasw-3L(config)#router rip
tarenasw-3L(config-router)#version 2
tarenasw-3L(config-router)#no auto-summary
tarenasw-3L(config-router)#network 192.168.1.0
tarenasw-3L(config-router)#network 192.168.2.0
tarenasw-3L(config-router)#network 192.168.3.0
tarenasw-3L(config-router)#network 192.168.4.0
tarenasw-3L(config-router)#network 192.168.5.0
tarenasw-3L(config-router)#network 192.168.6.0
tarena-router(config)#router rip
tarena-router(config-router)#version 2
tarenasw-3L(config-router)#no auto-summary
tarena-router(config-router)#network 192.168.6.0
tarena-router(config-router)#network 192.168.7.0
注意以R开头的路由,这些路由表示通过RIP协议从其他运行RIP的路由器学习过来的路由。每条路由都写明了目标网络、下一跳IP地址以及从自己哪个端口发出去。
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 not set
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.4.0/24 is directly connected, Vlan4
C 192.168.5.0/24 is directly connected, Vlan5
C 192.168.6.0/24 is directly connected, FastEthernet0/6
R 192.168.7.0/24 [120/1] via 192.168.6.2, 00:00:12, FastEthernet0/6 0
Router#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
R 192.168.1.0/24 [120/1] via 192.168.6.1, 00:00:25, FastEthernet0/0
R 192.168.2.0/24 [120/1] via 192.168.6.1, 00:00:25, FastEthernet0/0
R 192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:25, FastEthernet0/0
R 192.168.4.0/24 [120/1] via 192.168.6.1, 00:00:25, FastEthernet0/0
R 192.168.5.0/24 [120/1] via 192.168.6.1, 00:00:25, FastEthernet0/0
C 192.168.6.0/24 is directly connected, FastEthernet0/0
C 192.168.7.0/24 is directly connected, FastEthernet0/1
5.在PC上测试到五个VLAN中主机的通信
PCipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:8FFF:FE14:BB43
IP Address......................: 192.168.7.1
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.7.254
SERVERping 192.168.1.10
Pinging 192.168.1.10 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=1ms TTL=126
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
PC ping 192.168.2.1
Pinging 192.168.2.10 with 32 bytes of data:
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
PC ping 192.168.3.1
Pinging 192.168.3.10 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
PC
31% /misc/nfsdir SERVER
SERVERping 192.168.3.10
Pinging 192.168.3.10 with 32 bytes of data:
Reply from 192.168.4.1: bytes=32 time=1ms TTL=126
Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.4.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
31% /misc/nfsdir
SERVERping 192.168.5.1
Pinging 192.168.5.1 with 32 bytes of data:
Reply from 192.168.5.1: bytes=32 time=1ms TTL=126
Reply from 192.168.5.1: bytes=32 time=0ms TTL=126
Reply from 192.168.5.1: bytes=32 time=0ms TTL=126
Reply from 192.168.5.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.5.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
31% /misc/nfsdir
怎么利用三层交换机来实现VLAN间路由
有两种方式。
1、给每个vlan接口配置IP地址在不同网段。这样路由表就会出现直连路由,各vlan之间就可以通信了。
2、将物理端口有bridge模式改成route模式,直接给接口配置IP地址,也可以出现直连路由。
通过以上两种方式后在从三层交换机上配置静态路由或使用动态路由协议都可以。
方法/步骤
首先打开思科模拟器软件,找出一台三层交换机和两台PC,如下图所示:
将三层交换机和两台PC用直通线连接起来,如下图所示:
在三层交换机上划分VLAN,命令是:Switch#conf tEnter configuration commands, one per line. End with CNTL/Z.Switch(config)#vlan 2Switch(config-vlan)#exitSwitch(config)#int f0/5Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 1Switch(config-if)#int f0/6Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 2
如下图所示:
开启三层交换机的三层交换路由功能,命令是:ip routing,如下图所示:
给PC配置IP地址和网关,如下图所示:
进入三层交换机里面配置VLAN,命令是:
Switch(config)#int vlan 1Switch(config-if)#no shutSwitch(config-if)#ip add 172.16.10.1 255.255.255.0Switch(config-if)#int vlan 2 Switch(config-if)#no shutSwitch(config-if)#ip add 172.16.20.1 255.255.255.0
如下图所示:
利用ping命令对PC之间进行通信测试,可以ping通的结果如下图所示:
三层交换机怎么实现VLAN间路由
三层交换机怎么实现VLAN间路由
要想三层交换机实现VLAN间路由 有两种实现方式,三层交换启用路由功能或直接使用路由器。我这里主要说明如何使用三层交换机实现vlan间的路由。
一、几个在学习过程中比较困惑的概念:
1、 本地vlan和普通vlan:本地vlan也称管理vlan
每台交换机都有一个默认的vlan 1,也就是交换机的本地vlan,交换机默认所有的端口都划分在vlan 1内。普通vlan是自己创建的vlan。普通vlan下转发的帧在通过trunk口之前会被打一个标记(tag:如dot1q),然后在vlan间传输信息;本地vlan下的帧在进入trunk前是不打tag的在进入trunk口时会被打一个native vlan的tag(即nvtag),在出trunk时会去掉该tag。我们可以用命令改变交换机的管理vlan。
2、 交换机的虚拟接口SVI:我们可以为交换机的'vlan
创建一个虚拟接口,命令:#interfance vlan vlan-id 。我们可以为这个虚拟接口配置IP。管理vlan的ip我们可以在远程登录交换机时使用。对于二层交换机我们仅给交换机的管理vlan配置其SVI的IP地址,如果给普通vlan配置其IP地址没具体作用。对于三层交换机我们给管理vlan配置其IP地址,用于远程登录使用;给普通vlan配置其SVI的IP地址作为不同vlan下主机的网关。
3、 三层交换机的路由功能:想要使用三层交换机的路由
功能,首先要启用三层交换机的路由功能,命令:#ip routing。三层交换机的路由选择可以利用SVI让交换机选择路由;可以启用三层交换机物理接口的三层功能,然后为物理接口配置IP地址。三层交换机的路由选择功能可以使用静态路由,也可以启动动态路由协议。
二、接下来我做一个具体的例子,网络拓扑如下:
拓扑中有两个普通的VLAN,VLAN 10和VLAN 20,PC7和PC8属于VLAN10,PC5和PC6属于VLAN20。
三层交换机的配置:
1)、VLAN的创建和划分:
3SW(config)#vlan 10
3SW(config-vlan)#exit
3SW(config)#vlan 20
3SW(config-vlan)#exit
2)、创建SVI并为其分配IP地址(vlan1的配置可选)
3SW(config)#interface vlan 1 管理vlan
3SW(config-if)#ip add 172.16.1.254 255.255.255.0
3SW(config)#interface vlan 10
3SW(config-if)#ip add 192.168.10.254 255.255.255.0
3SW(config-if)#no shutdown
3SW(config-if)#exit
3SW(config)#interface vlan 20
;
华为三层交换机如何开启路由器功能?
华为的三层交换机默认是打开路由功能的,需要做的是把VLAN和地址规划了
划分VLAN,并描述
vlan 1
description local-S3600 vlan 2
description link-to-wenquan
vlan 3
description link-to-ruzhou
vlan 4
description link-to-xiaotun
vlan 5
description link-to-baofeng
vlan 6
description link-to-pingxi
vlan 7
description link-to-pingnan
vlan 8
description Uplink-to-Putian
vlan 9
description link-to-pingxicentre
给VLAN 划网关 interface Vlan-interface2
description link to wenquan ip address 10.41.77.41 255.255.255.192 interface Vlan-interface3
description link to ruzhou ip address 10.41.77.105 255.255.255.192 interface Vlan-interface4
description link to xiaotun ip address 10.41.77.169 255.255.255.192 interface Vlan-interface5
description link to baofeng ip address 10.41.77.233 255.255.255.192 interface Vlan-interface6
description link to pingxi ip address 10.41.78.41 255.255.255.192 interface Vlan-interface7
description link to pingnan ip address 10.41.78.105 255.255.255.192 interface Vlan-interface8
description uplink to putian ip address 10.41.244.102 255.255.255.252 interface Vlan-interface9
description link to pingxicentre ip address 10.41.80.233 255.255.255.192
给VLAN 指定端口
interface Ethernet1/0/2
description link to wenquan port access vlan 2
interface Ethernet1/0/3
description link to ruzhou port access vlan 3
interface Ethernet1/0/4
description link to xiaotun port access vlan 4
interface Ethernet1/0/5
description link to baofeng port access vlan 5
interface Ethernet1/0/6
description link to pingxi port access vlan 6 interface Ethernet1/0/7
description link to pingnan port access vlan 7
interface Ethernet1/0/8
description uplink to putian port access vlan 8
interface Ethernet1/0/9 to Ethernet1/0/24
description link to pingxicentre port access vlan 9
配置路由协议 //
(1)用RIP配动态路由 rip
network 10.41.77.41
network 10.41.77.105
network 10.41.77.169
network 10.41.77.233
network 10.41.78.41
network 10.41.78.105
network 10.41.80.233
network 10.41.244.102
如何在路由器与三层交换机之间采用OSPF动态路由?不使用vlan
首先你的核心和路由器之间需要有互联地址,我假设交换机上的互联地址为:192.168.10.1/24,路由器上的互联地址为192.168.10.2/24,那么
交换机配置:
int fa 0/2
no switchport
ip address 192.168.10.1 255.255.255.0
router ospf 1
network 192.168.0.0 0.0.0.255 area 0
network 192.168.10.0 0.0.0.255 area 0
路由器配置:
int fa0/0
ip add 192.168.10.2 255.255.255.0
router ospf 1
network 192.168.2.0 0.0.0.255 area 0
network 192.168.10.0 0.0.0.255 area 0
三层交换机动态路由的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于三层交换机动态路由实验总结、三层交换机动态路由的信息别忘了在本站进行查找喔。