多台三层交换VLAN间相互通信配置方法是什么

kuaidi.ping-jia.net  作者:佚名   更新日期:2024-09-10

  交换机的主要功能包括物理编址、网络拓扑结构、错误校验、帧序列以及流控。交换机还具备了一些新的功能,如对VLAN(虚拟局域网)的支持、对链路汇聚的支持,甚至有的还具有防火墙的功能。工作上需要两台PC之间相互通信,保证不同VLAN之间可以互相访问。 本实验将给您详细阐述实现方法,将用到诸多交换知识点

  本实验需求:

  通过在SW100 来创建VLAN 100 ,sw2 上创建VLAN 200,因为VLAN100和VLAN200因为业务上的关系,需要两台PC之间相互通信,保证不同VLAN之间可以互相访问。 本实验将给您详细阐述实现方法,将用到诸多交换知识点。

  实验拓扑:

  实验过程 第一步 SW100基础配置

  复制代码代码如下:

  SW100>

  SW100>enable

  SW100#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  SW100(config)#no ip do lo

  SW100(config)#line con 0

  SW100(config-line)#no exec-t

  SW100(config-line)#logg syn

  SW100(config-line)#exit

  SW100(config)#username admin privilege 15 password admin

  SW100(config)#line vty 0 15

  SW100(config-line)#login local

  SW100(config-line)#int f0/24

  //配置把二层接口更改为三层接口

  SW100(config-if)#no switchport

  SW100(config-if)#ip add 12.0.0.1 255.255.255.0

  00:02:57: %LINK-3-UPDOWN: Interface FastEthernet0/24, changed state to up

  00:02:58: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up

  SW100(config-if)#no sh

  [html]

  第二步 SW200 基础配置

  [code]

  Switch>enable

  Switch#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  Switch(config)#host SW200

  SW200(config)#no ip do lo

  SW200(config)#line con 0

  SW200(config-line)#no exec-t

  SW200(config-line)#logg syn

  SW200(config-line)#exit

  SW200(config)#username admin privilege 15 password admin

  SW200(config)#line vty 0 15

  SW200(config-line)#login local

  SW200(config-line)#int f0/24

  //把二层端口改变成三层接口

  SW200(config-if)#no switchport

  SW200(config-if)#ip add 12.0.0.2 255.2

  00:03:40: %LINK-3-UPDOWN: Interface FastEthernet0/24, changed state to up

  00:03:41: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up

  SW200(config-if)#ip add 12.0.0.2 255.255.255.0

  SW200(config-if)#no sh

  SW200(config-if)#exit

  第三步 完整SW1上VLAN配置

  复制代码代码如下:

  //创建VLAN 100

  SW100(config)#vlan 100

  //给VLAN命名为100

  SW100(config-vlan)#name 100

  //进入f0/13接口模式下,把f0/13接口划分到VLAN100

  SW100(config-vlan)#int f0/13

  SW100(config-if)#switchport mode access

  SW100(config-if)#switchport access vlan 100

  SW100(config-if)#exit

  SW100(config)#int f0/13

  //因为此接口连接的终端设备,故可以关闭生成树的选举,开启快速端口特性

  SW100(config-if)#spanning-tree portfast

  %Warning: portfast should only be enabled on ports connected to a single

  host. Connecting hubs, concentrators, switches, bridges, etc... to this

  interface when portfast is enabled, can cause temporary bridging loops.

  Use with CAUTION

  %Portfast has been configured on FastEthernet0/15 but will only

  have effect when the interface is in a non-trunking mode.

  SW100(config-if)#exit

  00:05:40: %SYS-5-CONFIG_I: Configured from console by console

  //查看VLAN信息

  SW100#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/14, Fa0/15, Fa0/16, Fa0/17

  Fa0/18, Fa0/23, Gi0/1, Gi0/2

  100 100 active Fa0/13

  1002 fddi-default act/unsup

  1003 token-ring-default act/unsup

  1004 fddinet-default act/unsup

  1005 trnet-default act/unsup

  第四步 完成SW200上VLAN配置

  复制代码代码如下:

  SW200(config)#vlan 200

  SW200(config-vlan)#name 200

  SW200(config-vlan)#int f0/15

  SW200(config-if)#switchport mode access

  SW200(config-if)#switchport access vlan 200

  SW200(config-if)#exit

  SW200(config)#int f0/15

  SW200(config-if)#spanning-tree portfast

  %Warning: portfast should only be enabled on ports connected to a single

  host. Connecting hubs, concentrators, switches, bridges, etc... to this

  interface when portfast is enabled, can cause temporary bridging loops.

  Use with CAUTION

  %Portfast has been configured on FastEthernet0/15 but will only

  have effect when the interface is in a non-trunking mode.

  SW100#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/14, Fa0/15, Fa0/16, Fa0/17

  Fa0/18, Fa0/23, Gi0/1, Gi0/2

  200 200 active Fa0/15

  1002 fddi-default act/unsup

  1003 token-ring-default act/unsup

  1004 fddinet-default act/unsup

  1005 trnet-default act/unsup

  第五步 在SW100上创建SVI(交换虚拟接口),并给SW100所连接PC配置IP地址为192.168.0.100,网关192.168.0.1(PC配置IP地址,网关,实验手册内容略过)

  复制代码代码如下:

  SW100#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  //进入VLAN 100

  SW100(config)#int vlan 100

  //配置VLAN100,IP地址,这里的IP地址,就是F0/13接口下PC所指的网关地址

  SW100(config-if)#ip add 192.168.0.1 255.255.255.0

  SW100(config-if)#no sh

  SW100(config-if)#end

  00:06:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up

  //从SW100上测试可以ping通本VLAN下PC

  SW100#ping 192.168.0.100

  Type escape sequence to abort.

  Sending 5, 100-byte ICMP Echos to 192.168.0.100, timeout is 2 seconds:

  !!!!!

  第六步 在SW200上创建SVI(交换机虚拟接口),并给SW200所连接PC配置IP地址为172.16.0.100,网关172.16.0.1(PC配置IP地址,实验手册内容略过) SW200(config-if)#exit

  SW200(config)#int vlan 200

  SW200(config-if)#ip add 172.16.0.1 255.255.255.0

  00:04:41: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up

  SW200(config-if)#no sh

  SW200(config-if)#end

  00:04:52: %SYS-5-CONFIG_I: Configured from console by console

  SW200#ping 172.16.0.200

  Type escape sequence to abort.

  Sending 5, 100-byte ICMP Echos to 172.16.0.200, timeout is 2 seconds:

  !!!!!

  第七步 在SW100 上开启路由功能,并运行动态路由协议

  复制代码代码如下:

  SW100#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  //开启三层交换路由功能,默认是关闭的

  SW100(config)#ip routing

  SW100(config)#router ospf 100

  SW100(config-router)#net 12.0.0.1 0.0.0.255 a 0

  SW100(config-router)#net 192.168.0.1 0.0.0.255 a 0

  SW100(config-router)#end

  SW100#

  00:08:11: %SYS-5-CONFIG_I: Configured from console by console

  第八步 在SW200 上开启路由功能,并运行动态路由协议

  复制代码代码如下:

  SW200#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  //注意:如果没有开启路由功能,直接运行路由协议,将提示如下的错误信息

  SW200(config)#router ospf 200

  IP routing not enabled

  SW200(config)#ip routing

  SW200(config)#router ospf 200

  SW200(config-router)#net 12.0.0.2 0.0.0.255 a 0

  SW200(config-router)#net 172.16.0.2 0.0.0.255 a 0

  SW200(config-router)#end

  00:05:27: %OSPF-5-ADJCHG: Process 200, Nbr 192.168.0.1 on FastEthernet0/24 from LOADING to FULL, Loading Done

  //查看路由表,观察通过OSPF学习到路由条目

  SW200#show ip ro

  00:05:33: %SYS-5-CONFIG_I: Configured from console by console

  SW200#show ip route

  Codes: C - connected, S - static, 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, su - IS-IS summary, 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

  172.16.0.0/24 is subnetted, 1 subnets

  C 172.16.0.0 is directly connected, Vlan200

  O 192.168.0.0/24 [110/2] via 12.0.0.1, 00:00:02, FastEthernet0/24

  12.0.0.0/24 is subnetted, 1 subnets

  C 12.0.0.0 is directly connected, FastEthernet0/24

  //测试IP连通性

  SW200#ping 12.0.0.1

  Type escape sequence to abort.

  Sending 5, 100-byte ICMP Echos to 12.0.0.1, timeout is 2 seconds:

  !!!!!

  Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

  SW200#ping 192.168.0.1

  Type escape sequence to abort.

  Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

  !!!!!

  Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

  SW200#ping 192.168.0.100

  Type escape sequence to abort.

  Sending 5, 100-byte ICMP Echos to 192.168.0.100, timeout is 2 seconds:

  !!!!!

  Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

  SW200#

  第九步 在PC2 用ping命令测试到PC1,测试vlan200是否可以和VLAN 100 PING通,测试结果全网ping 通,实验现象成功(因为PC2是windows 7 简体中文版本,故ping结果是中文方式显示的) 测试步骤:开始-运行-cmd C:\>ping 172.16.0.1

  正在 Ping 172.16.0.1 具有 32 字节的数据:

  来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255

  来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255

  来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255

  来自 172.16.0.1 的回复: 字节=32 时间=1ms TTL=255

  172.16.0.1 的 Ping 统计信息:

  数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),

  往返行程的估计时间(以毫秒为单位):

  最短 = 1ms,最长 = 1ms,平均 = 1ms

  Control-C

  ^C

  C:\>ping 12.0.0.2

  正在 Ping 12.0.0.2 具有 32 字节的数据:

  来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255

  来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255

  来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255

  来自 12.0.0.2 的回复: 字节=32 时间=2ms TTL=255

  12.0.0.2 的 Ping 统计信息:

  数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),

  往返行程的估计时间(以毫秒为单位):

  最短 = 2ms,最长 = 2ms,平均 = 2ms

  Control-C

  ^C

  C:\>ping 12.0.0.1

  正在 Ping 12.0.0.1 具有 32 字节的数据:

  来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 12.0.0.1 的回复: 字节=32 时间=1ms TTL=254

  12.0.0.1 的 Ping 统计信息:

  数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),

  往返行程的估计时间(以毫秒为单位):

  最短 = 1ms,最长 = 1ms,平均 = 1ms

  Control-C

  ^C

  C:\>ping 192.168.0.1

  正在 Ping 192.168.0.1 具有 32 字节的数据:

  来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254

  来自 192.168.0.1 的回复: 字节=32 时间=1ms TTL=254

  192.168.0.1 的 Ping 统计信息:

  数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),

  往返行程的估计时间(以毫秒为单位):

  最短 = 1ms,最长 = 1ms,平均 = 1ms

  Control-C

  ^C

  C:\>ping 192.168.0.200

  正在 Ping 192.168.0.200 具有 32 字节的数据:

  Control-C

  ^C

  C:\>ping 192.168.0.100

  正在 Ping 192.168.0.100 具有 32 字节的数据:

  来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62

  来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62

  来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62

  来自 192.168.0.100 的回复: 字节=32 时间=1ms TTL=62

  192.168.0.100 的 Ping 统计信息:

  数据包: 已发送 = 4,已接收 =4,丢失 = 0 (0% 丢失),

  往返行程的估计时间(以毫秒为单位):

  最短 = 1ms,最长 = 1ms,平均 = 1ms

  Control-C

  ^C

  补充:交换机常见故障解决

  通过观察初步定为故障,一般如果设备正常,而且线路连接也正常,则交换机指示灯会亮绿色并且一闪一闪的。如果发现交换机指示灯不亮则首先检查线路连接,如果一直亮着不闪,则检查交换机等设备!

  通过电脑直接连接交换机查看是否能够自动获取IP地址和网关,如下面示意图连接电脑之后,将电脑TCP/IP协议设置为DHCP动态获取模式,然后运行命令行输入ipconfig查看电脑是否能够获取到交换机分配的ip地址和网关。

  如果交换机未配置,则需通过终端配置交换机,使用配置电缆的 DB-9 孔式插头接到要对交换机进行配置的 PC 或终端的串口上,将配置电缆的 RJ-45 一端连到交换机的配置口(Console)上。

  在 Console 口与本地电脑连接之后,在PC短通过终端与交换机建立连接,连接过程中要求,波特率为 9600,数据位为 8,奇偶校验为无,停止位为 1,流量控制为无,选择终端仿真为 VT100。

  通过超级终端登陆交换机之后,检查端口是否被shutdown,并通过display interface brief 命令,查看端口显示信息的速率与双工是否与对端一致。若不一致,请通过 speed 命令和 duplex 命令配置端口的速率和双工模式。

  (4)确认网线质量或光口的光模块类型及其波长是否匹配

  更换网线插入端口,查看端口是否 UP,端口物理连接是否畅通,端口是否被shutdown,检查端口连接,undo shutdown端口,检查网线是否正常。

  相关阅读:交换机的基本功能:

  1. 像集线器一样,交换机提供了大量可供线缆连接的端口,这样可以采用星型拓扑布线。

  2. 像中继器、集线器和网桥那样,当它转发帧时,交换机会重新产生一个不失真的方形电信号。

  3. 像网桥那样,交换机在每个端口上都使用相同的转发或过滤逻辑。

  4. 像网桥那样,交换机将局域网分为多个冲突域,每个冲突域都是有独立的宽带,因此大大提高了局域网的带宽。



  • 如何使用三层交换实现不同VLAN互相访问ENSP实验实测通过
    答:首先在SW1、SW2创建VLAN,并将相应的端口加入到VLAN中,配置好Trunk口。SW1交换机配置 system-view [Huawei]sysname sw1 [sw1]undo info-center enable [sw1]interface GigabitEthernet 0/0/1 [sw1-GigabitEthernet0/0/10]port link-type access [sw1-GigabitEthernet0/0/10]port default vlan 1...
  • 同一台交换机上有多个VLAN之间的通讯配置
    答:[sw1-Vlanif20]ip address 192.168.20.254 255.255.255.0;作为VLAN20 的网关 [sw1-Vlanif20]quit 再次测试PC1与PC2之间的互通; 现在再增加1台PC3机,配置如下:  这时需要将交换机端口加入到VLAN 20后,三台PC之间才能通;system-view [sw1]interface GigabitEthernet 0/...
  • 三层交换机完成vlan之间的通信
    答:在三层交换机的接口f0/1上创建虚拟接口vlan10和vlan 20。并且配置三层交换机的配置vlan10和vlan20虚拟接口的ip地址。在三层交换机与二层交换机相连的接口f0/1上配置成trunk模式。在pc0上通过cmd去ping pc1和pc2都能连通。
  • 如何在交换机上配置VLAN之间的通信?
    答:对于跨三层交换机实现VLAN间通信,可以在两台交换机之间配置单臂路由或三层交换机来实现。其中,单臂路由是通过一个物理接口连接两个VLAN,并在这两个VLAN之间进行路由;而三层交换机则可以在原有二层交换机的基础上增加路由功能,数据包不需要经过物理线路进行路由。测试连通性。完成上述配置后,可以通过测...
  • 多台三层交换VLAN间相互通信配置方法是什么
    答:通过在SW100 来创建VLAN 100 ,sw2 上创建VLAN 200,因为VLAN100和VLAN200因为业务上的关系,需要两台PC之间相互通信,保证不同VLAN之间可以互相访问。 本实验将给您详细阐述实现方法,将用到诸多交换知识点。 实验拓扑: 实验过程 第一步 SW100基础配置 复制代码代码如下: SW100> SW100>enable SW100#conf t Enter...
  • 请问一下不同vlan之间如何通信
    答:不同的vlan想要进行通信必须要用到三层设备才能实现vlan间的互访,比如路由器或三层交换机。路由器就做vlan间路由,三层交换机中只需要在不同的vlan上配置了网关。如果是二层交换机,可以另外借助一台路由器,做单臂路由;如果是三层交换机,直接开启三层交换功能,思科的话需要全局配置模式下手动开ip...
  • 三层交换机分三个VLAN之后,怎么连接路由器?连接口怎么设置?
    答:1、交换机配置:(1)在交换机上分别划分三个VLAN,如vlan 10,vlan 20,vlan 30。(2)进入交换机的上联口,如interface GigabitEthernet 0/0/1,设置成trunk模式。(3)上联口加入vlan 10,vlan 20,vlan 30。2、路由器配置:(1)进入路由器连接交换机的端口的子接口,如interface GigabitEthernet...
  • 多个三层交换机之间不同vlan相互通信
    答:按照图中的配置左侧的Sw2中的vlan10 计算机指网关为192.168.1.2,vlan20计算机指网关为192.168.2.2以后两台计算机就能ping通了。右侧的vlan10 计算机也能和左侧的vlan10 计算机ping通。你的问题关键在右侧的交换机。解决方法:方案一、右侧的计算机指网关:192.168.1.2,然后ping vlan 20的计算机...
  • 如何在三层交换机上ping通不同VLAN的主机?
    答:要实现不同VLAN之间相互通信,就要用到三层VLANIF接口方案。这是一种通过计算机网络体系结构中第三层(网络层)来实现VLAN间通信的解决方案。每个VLAN都可以配置一个三层VLANIF逻辑接口,而这些VLANIF接口就作为对应VLAN内部用户主机的缺省网关,通过三层交换机内部的IP路由功能可以实现同一交换机上不同VLAN的...
  • 不同vlan间的通信如何简单配置 ?
    答:PC0的配置: ip 192.168.10.10 netmask 255.255.255.0 gateway 192.168.10.1 PC1的配置: ip 192.168.20.20 netmask 255.255.255.0 gateway 192.168.20.1 2.使用SVI实现VLAN间的通信(图) 环境:一台三层交换机,两台pc机 三层交换机的配置:Switchenable Switch#configure terminal Enter configuration commands, one per ...