VLAN技术

一、VLAN简介

VLAN的标准是IEEE 802.1Q协议,802.1Q协议定义了基于端口的VLAN模型。

二、VLAN基本概念

VLAN 技术的出现,使得交换网络中存在了带VLAN 的以太网帧和不带VLAN 的以太网帧。因此,相应地也对链路做了区分,分为接入链路和干道链路。

(1)接入链路(Access Link)。连接用户主机和交换机的链路为接入链路。接入链路上通过的帧为不带Tag 的以太网帧。

(2)干道链路(Trunk Link)。连接交换机和交换机的链路称为干道链路。干道链路上通过的帧一般为带Tag 的VLAN 帧,也允许通过不带Tag 的以太网帧。

三、端口模式

(1)接入端口(Access Port)。Access 端口是交换机上用来连接用户主机的端口,它只能连接接入链路。接入端口只允许一个VLAN 的帧通过,该VLAN 即为接入端口的默认VLAN。

(2)干道端口(Trunk Port)。干道端口是交换机上用来和其他交换机连接的端口。干道端口允许多个VLAN 的帧(带Tag 标记)通过。干道端口允许多个VLAN 通过,可以指定其中一个VLAN 作为默认VLAN,如果接收到了不带VLAN 的数据帧,则给数据帧加上默认VLAN 标签。在往外送时,如果VLAN ID 和默认VLAN ID 相同,则剥离标签。

(3)混合端口(Hybrid Port)。混合端口是交换机上既可以连接用户主机,又可以连接其他交换机的端口。混合端口也允许多个VLAN 通过,指定其中一个VLAN 作为默认VLAN,在接收到不带VLAN 的数据帧时,给数据帧加上默认VLAN 标签。对外发送时,根据端口的Untag/Tag 方式进行判断处理。

四、VLAN内的通信,ACESS端口、trunk端口配置

 

配置PC的IP并测试连通性(交换机不做任何配置)
PC3:
PC>ping 10.1.41.4

Ping 10.1.41.4: 32 data bytes, Press Ctrl_C to break
From 10.1.41.4: bytes=32 seq=1 ttl=128 time=46 ms
From 10.1.41.4: bytes=32 seq=2 ttl=128 time=47 ms
From 10.1.41.4: bytes=32 seq=3 ttl=128 time=47 ms
From 10.1.41.4: bytes=32 seq=4 ttl=128 time=47 ms
From 10.1.41.4: bytes=32 seq=5 ttl=128 time=31 ms

PC>ping 10.1.41.1

Ping 10.1.41.1: 32 data bytes, Press Ctrl_C to break
From 10.1.41.1: bytes=32 seq=1 ttl=128 time=63 ms
From 10.1.41.1: bytes=32 seq=2 ttl=128 time=78 ms
From 10.1.41.1: bytes=32 seq=3 ttl=128 time=32 ms
From 10.1.41.1: bytes=32 seq=4 ttl=128 time=62 ms
From 10.1.41.1: bytes=32 seq=5 ttl=128 time=63 ms
创建Vlan:41 and 42,使其不能通信
LSW1:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWA
[SWA]vlan batch 41 42
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(U)     Eth0/0/4(D)     
                Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(D)      GE0/0/2(D)      

41   common  
42   common  


LSW2:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWB
[SWB]vlan batch 41 42
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/2(U)     Eth0/0/3(U)     Eth0/0/4(U)     
                Eth0/0/5(U)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     
                Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    
                Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    
                Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    
                Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(D)      GE0/0/2(D)      

41   common  
42   common  
配置端口为access,并划分vlan,PC156为41,PC234为42
[SWA]interface Ethernet0/0/2
[SWA-Ethernet0/0/2]port link-type access
[SWA-Ethernet0/0/2]port default vlan 41
[SWA-Ethernet0/0/2]int Ethernet0/0/3
[SWA-Ethernet0/0/3]port link-type access
[SWA-Ethernet0/0/3]port default vlan 42
[SWA-Ethernet0/0/3]quit
[SWA]display vlan


[SWB]interface Ethernet0/0/2
[SWB-Ethernet0/0/2]port link-type access
[SWB-Ethernet0/0/2]port default vlan 42
[SWA-Ethernet0/0/2]int Ethernet0/0/3
[SWA-Ethernet0/0/3]port link-type access
[SWA-Ethernet0/0/3]port default vlan 42
[SWA-Ethernet0/0/3]int Ethernet0/0/4
[SWA-Ethernet0/0/4]port link-type access
[SWA-Ethernet0/0/4]port default vlan 41
[SWA-Ethernet0/0/4]int Ethernet0/0/5
[SWA-Ethernet0/0/5]port link-type access
[SWA-Ethernet0/0/5]port default vlan 41
[SWA-Ethernet0/0/5]quit
[SWB]display vlan
vlan测试:
PC3:---不同vlan间无法通信
PC>ping 10.1.41.6

Ping 10.1.41.1: 32 data bytes, Press Ctrl_C to break
From 10.1.41.3: Destination host unreachable
From 10.1.41.3: Destination host unreachable
From 10.1.41.3: Destination host unreachable
From 10.1.41.3: Destination host unreachable
From 10.1.41.3: Destination host unreachable

---同一vlan可以通信
PC>ping 10.1.41.4

Ping 10.1.41.4: 32 data bytes, Press Ctrl_C to break
From 10.1.41.4: bytes=32 seq=1 ttl=128 time=31 ms
From 10.1.41.4: bytes=32 seq=2 ttl=128 time=47 ms
From 10.1.41.4: bytes=32 seq=3 ttl=128 time=31 ms
From 10.1.41.4: bytes=32 seq=4 ttl=128 time=47 ms
From 10.1.41.4: bytes=32 seq=5 ttl=128 time=47 ms

两台交换机未设置为trunk,则PC1应ping不通PC6
PC>ping 10.1.41.6

Ping 10.1.41.6: 32 data bytes, Press Ctrl_C to break
From 10.1.41.1: Destination host unreachable
From 10.1.41.1: Destination host unreachable
From 10.1.41.1: Destination host unreachable
From 10.1.41.1: Destination host unreachable
From 10.1.41.1: Destination host unreachable

配置trunk端口
[SWA]int Ethernet0/0/1
[SWA-Ethernet0/0/1]port link-type trunk
[SWA-Ethernet0/0/1]port trunk allow-pass vlan 41 42
[SWA-Ethernet0/0/1]q

SWB也一样配置

PC1可以pingPC6了
PC>ping 10.1.41.6

Ping 10.1.41.6: 32 data bytes, Press Ctrl_C to break
From 10.1.41.6: bytes=32 seq=1 ttl=128 time=63 ms
From 10.1.41.6: bytes=32 seq=2 ttl=128 time=62 ms
From 10.1.41.6: bytes=32 seq=3 ttl=128 time=63 ms
From 10.1.41.6: bytes=32 seq=4 ttl=128 time=78 ms
From 10.1.41.6: bytes=32 seq=5 ttl=128 time=62 ms

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值