打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
三层交换机实现不同VALN之间的通信


VLAN(Virtual Local Area Network, 虚拟局域网)是指在一个物理网段内,进行逻辑的划分,划分成若干个虚拟局域网。VLAN的最大特性是不受物理位置的限制,可以进行灵活的划分。VLAN具备了一个物理网段所具备的特性。相同VLAN内的主机可以互相直接访问,不同VLAN间的主机之间互相访问必须经由路由设备进行转发。广播数据包只可以在本VLAN内进行传播,不能传输到其他VLAN中。

如果VLAN间需要通信,则需要通过三层交换机或路由器实现其路由功能。其主要目的是使在同一VLAN里的计算机系统能跨交换机进行相互通信,而在不同VLAN里的计算机系统也能进行相互通信。

二层交换机VLAN配置地址,称之为 远程管理IP。一个二层交换,只能有一个处于up状态的VLAN管理IP。三层交换机VLAN配置地址,称之为三层SVI虚接口地址,用于不同VLAN之间互相访问,实现路由功能。

方法:三层交换起用SVI虚接口,配置IP地址,作为VLAN内PC的网关地址,实现VLAN互访,这是启用三层交换的路由功能。

设备端口IP网关
PC0-1FastEthernet0192.168.3.1/24192.168.3.254
PC1-1FastEthernet0192.168.2.1/24192.168.2.254
PC2-1FastEthernet0192.168.3.2/24192.168.3.254
PC3-1FastEthernet0192.168.2.2/24192.168.2.254
设备端口IP网关
PC0FastEthernet0192.168.3.1/24192.168.3.254
PC1FastEthernet0192.168.2.1/24192.168.2.254
PC2FastEthernet0192.168.3.2/24192.168.3.254
PC3FastEthernet0192.168.2.2/24192.168.2.254
两台交换机分别连接三层
#二层交换机配置
Switch0>en
Switch0#hostname sw0
sw0#conf t
sw0(config)#vlan 10
sw0(config-vlan)#ex
sw0(config)#vlan 20
sw0(config-vlan)#ex
sw0(config)#int fa0/1
sw0(config-if)#sw mo ac
sw0(config-if)#sw ac vlan 10
sw0(config-if)#no sh
sw0(config-if)#ex
sw0(config)#int fa0/2
sw0(config-if)#sw mo ac
sw0(config-if)#sw ac vlan 20
sw0(config-if)#no sh
sw0(config-if)#ex
#连接三层交换机的口改为 trunk
sw0(config)#int g0/1
sw0(config-if)#sw mo tr
sw0(config-if)#no sh
sw0(config-if)#
#另一台交换机或者其它交换机按照以上配置再来一次即可,配置之前改下名称
Switch#hostname sw1

#
三层交换机配置
Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname msw0
msw0(config)#vlan 10
msw0(config-vlan)#vlan 20
msw0(config-vlan)#ex
msw0(config)#int vlan 10
msw0(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
msw0(config-if)#ip add 192.168.3.254 255.255.255.0
msw0(config-if)#no sh
msw0(config-if)#ex
msw0(config)#int vlan 20
msw0(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
msw0(config-if)#ip add 192.168.2.254 255.255.255.0
msw0(config-if)#no sh
msw0(config-if)#ex
#开启三层交换机路由功能
msw0(config)#ip routing
msw0(config)#ex
msw0#

#
一般情况下,switchport trunk encapsulation dot1q命令可不做,因为默认为dot1q封装,简写 sw tr e d
#msw0(config)#int g1/0/1
#msw0(config-if)#switchport trunk encapsulation dot1q 
#msw0(config-if)#exit
#msw0(config)#int g1/0/2
#msw0(config-if)#sw tr e d
#msw0(config-if)#exit

两台交换机通过一台三层连接
#二次交换机配置
Switch0>en
Switch0#hostname sw0-1
sw0-1#conf t
sw0-1(config)#vlan 10
sw0-1(config-vlan)#ex
sw0-1(config)#vlan 20
sw0-1(config-vlan)#ex
sw0-1(config)#int fa0/1
sw0-1(config-if)#sw mo ac
sw0-1(config-if)#sw ac vlan 10
sw0-1(config-if)#no sh
sw0-1(config-if)#ex
sw0-1(config)#int fa0/2
sw0-1(config-if)#sw mo ac
sw0-1(config-if)#sw ac vlan 20
sw0-1(config-if)#no sh
sw0-1(config-if)#ex
#另一台交换机或者其它交换机按照以上配置再来一次即可,配置之前改下名称
Switch#hostname sw1-1

#
连接三层交换机的口改为 trunk
sw0-1(config)#int g0/2
sw0-1(config-if)#sw mo tr
sw0-1(config-if)#no sh
sw0-1(config-if)#
sw0-1#

#
其中两台交换机之间的连接口做如下配置
Switch(config)#int g0/1
#配置端口为trunk,简写sw mo tr
Switch(config-if)#switchport mode trunk
#允许所有vlan通过
Switch(config-if)#switchport trunk allowed vlan all
Switch(config-if)#no sh
Switch(config-if)#ex

#
三层交换机配置
Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname msw0
msw0(config)#vlan 10
msw0(config-vlan)#vlan 20
msw0(config-vlan)#ex
msw0(config)#int vlan 10
msw0(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
msw0(config-if)#ip add 192.168.3.254 255.255.255.0
msw0(config-if)#no sh
msw0(config-if)#ex
msw0(config)#int vlan 20
msw0(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
msw0(config-if)#ip add 192.168.2.254 255.255.255.0
msw0(config-if)#no sh
msw0(config-if)#ex
#开启三层交换机路由功能
msw0(config)#ip routing
msw0(config)#ex
msw0#

#
一般情况下,switchport trunk encapsulation dot1q命令可不做,因为默认为dot1q封装,简写 sw tr e d
#msw0(config)#int g1/0/1
#msw0(config-if)#switchport trunk encapsulation dot1q 
#msw0(config-if)#exit
#msw0(config)#int g1/0/2
#msw0(config-if)#sw tr e d
#msw0(config-if)#exit





本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
CISCO SWITCH &ROUTER基本配置命令
使用Cisco Packer Trace之三层交换机+路由器共享上网
《网络互联技术》实践教学
CCNA.VLAN专题.part2 - Aaron的日志 - 网易博客
认识虚拟局域网
锐捷实战系类 DHCP (转载收藏)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服