不同之间Vlan通信

Vlan间路由

vlan:相当于把交换机变成一共虚拟路由器

vlan间路由概述

vlan间路由:通过三层设备路由,使得不同vlan间可以互相通信。
仅仅允许单播通信
vlan间路由方式:1、 SVI(交换虚接口)(三层交换机) 或 2、vlanif口 单臂路由(路由器)

vlan间路由:SVI :switch virtual interface
不同之间Vlan通信_第1张图片
sw1:
vlan batch 10 20
int g0/0/1
port link-type access
port default vlan 10
int g0/0/2
port link-type access
port default vlan 20

int vlanif 10 创建交换机虚拟接口vlanif 10 (SVI)
ip add 192.168.10.1 24 配置ip地址作为vlan10网关
int vlanif 20
ip add 192.168.20.1 24
注意:可以将三层交换机抽象成一台路由器,vlanif接口就是路由器的接口
核心层交换机查看路由表转换标签值。

两层架构 SVI配置:
不同之间Vlan通信_第2张图片

sw2: 
vlan batch 10 30 
interface Ethernet0/0/1 
port link-type trunk 
port trunk allow-pass vlan 2 to 4094 
#
interface Ethernet0/0/2 
port link-type access 
port default vlan 10 
#
interface Ethernet0/0/3 
port link-type access 
port default vlan 30 
sw3:vlan 20 
interface Ethernet0/0/1 
port link-type trunk 
port trunk allow-pass vlan 2 to 4094 
#
interface Ethernet0/0/2 
port link-type access 
port default vlan 20 
sw1: 
vlan batch 10 20 30 
interface Vlanif10 
ip address 192.168.10.1 255.255.255.0 
#
interface Vlanif20 
ip address 192.168.20.1 255.255.255.0 
#
interface Vlanif30 
ip address 192.168.30.1 255.255.255.0 
#
interface GigabitEthernet0/0/1 
port link-type trunkport trunk allow-pass vlan all 
#
interface GigabitEthernet0/0/2 
port link-type trunk 
port trunk allow-pass vlan all 


接入层:接pc口划分成access口,接核心交换划分成trunk口
                 vlan batch 10 20                 int  g/0/0/2
                  int g/0/0/1                          port link-type
                  port link-type  access         port  trunk  allow-passed vlan all
                  port default vlan 10
                   
核心层:vlan  batch  10 20
                 int  vlan 10
                 ip add 1.1.1.1 24

查看配置:dis  ip interface  brief
        dis  ip  routing-table(核心交换机上)

vlan件路由:单臂路由(一根线和交换机相连)
不同之间Vlan通信_第3张图片

交换机:划分vlan g/0/0/2,配置trunkg/0/0/1
vlan batch  10 20          
int g0/0/2
port link-type  access
port  default  vlan 10
interface Ethernet0/0/3
port link-type access
port default vlan 20 

int  g0/0/1
port link-type trunk
port  trunk  allow-pass  vlan all

路由器:
int g0/0/0.10    进入逻辑子接口
dotlq   termination  vid  10   报文封装采用802.1Q封装,同时给报文打上tag
ip add  192.168.10.1 24
arp broadcast enable    开启arp广播

interface Ethernet0/0/0.20 
dot1q termination vid 20 
ip address 192.168.20.1 255.255.255.0 
arp broadcast enable

注释:arp broadcast enable命令用来使能子接口的ARP广播功能。缺省情况下,子接口没有使能ARP广播功能。子接口不能转发广播报文,在收到广播报文后它们直接把该报文丢弃。为了允许子接口
能转发广播报文,可以通过在子接口上执行此命令
工作原理:当数据包进入路由器时,路由器首先根据目标地址结合自己的路由表将标签转换,然后从相应的子接口发出。
注意:从子接口发出报文会给报文嵌入相应标签!
不同之间Vlan通信_第4张图片

sw2: 
vlan 30 
int e0/0/1 
port link-ty access 
port defau vlan 30 
int e0/0/2 
port link-ty access 
port defau vlan 30 
R2: 
ip route-static 192.168.10.0 255.255.255.0 12.1.1.1 
ip route-static 192.168.20.0 255.255.255.0 12.1.1.1 
#
R1: 
ip route-s 192.168.30.0 24 12.1.1.2 
缺点:对于部分网络,vlan间数据传输的效率过低。

你可能感兴趣的:(HCIE---datacom,网络,运维,华为)