且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

私有vlan

更新时间:2022-08-19 21:38:47

一 拓扑图

私有vlan

二 配置私有vlan(pvlan)

只有VTP模式为透明模式,才能配置pvlan

(1)配置pc1-4及s2(给测试用)

pc1-4按照拓扑图上的说明配置

s2(config)#interface fastEthernet 0/1

s2(config-if)#switchport mode access 

s2(config)#interface vlan 200

s2(config-if)#ip address 172.16.1.100 255.255.255.0

s2(config)#ip default-network 172.16.1.254

(2)配置pvlan

s1(config)#vtp mode transparent (只有VTP模式为透明模式,才能配置pvlan)

s1(config)#vlan 101

s1(config-vlan)#private-vlan community (创建辅助vlan101,该vlan是团体vlan)

s1(config)#vlan 102

s1(config-vlan)#private-vlan isolated   (创建辅助vlan102,该vlan是隔离vlan)

s1(config)#vlan 100

s1(config-vlan)#private-vlan primary

s1(config-vlan)#private-vlan association 101-102 (创建主vlan100,把它和辅助vlan101和vlan102关联)

s1(config)#vlan 200

s1(config)#interface fastEthernet 0/1

s1(config-if)#switchport private-vlan  host-association 100 101

s1(config-if)#switchport mode private-vlan  host (把fa0/1接口配置为团体接口,它在vlan101中)

s1(config)#interface fastEthernet 0/2

s1(config-if)#switchport private-vlan  host-association 100 101

s1(config-if)#switchport mode private-vlan  host (把fa0/2接口配置为团体接口,它在vlan101中)

s1(config)#interface fastEthernet 0/3

s1(config-if)#switchport private-vlan  host-association 100 102

s1(config-if)#switchport mode private-vlan  host (把fa0/3接口配置为团体接口,它在vlan102中)

s1(config)#interface fastEthernet 0/4

s1(config-if)#switchport private-vlan  host-association 100 102

s1(config-if)#switchport mode private-vlan  host (把fa0/4接口配置为团体接口,它在vlan102中)

s1(config)#interface fastEthernet 0/6

s1(config-if)#switchport mode private-vlan promiscuous

s1(config-if)#switchport mode private-vlan mapping 100 101,102 (把fa0/6配置为混杂接口,该接口可以和      


               vlan101和vlan102计算机通信。该命令配置primary vlan和secondary vlan间的映射关系)

s1(config)#interface fastEthernet 0/5

s1(config-if)#switchport access vlan 200

s1(config-if)#switchport mode access (把fa0/5划分到vlan200中,用于把s2接入)

s1(config)#ip routing

s1(config)#interface vlan 200

s1(config-if)#no shutdown

s1(config-if)#ip address 172.16.1.254 255.255.255.0

s1(config)#interface vlan 100

s1(config-if)#no shutdown

s1(config-if)#ip address 172.16.0.254 255.255.255.0

s1(config-if)#private-vlan mapping 101-102  (将辅助vlan映射到三层接口,允许pvlan入口流量的三层交换)

s1#show interfaces fa0/1 switchport

(3)实验测试

团体vlan内的计算机连通性测试(在pc1上ping pc2  相通)

隔离vlan内的计算机连通性测试(在pc3上ping pc4 不相通)

和混杂接口的计算机连通性测试(在分别pc1和pc3上ping server0  相通)

团体vlan和隔离vlan内的计算机连通性测试(在pc1上ping pc3 不相通)

和其他普通vlan内的计算机连通性测试(在分别pc1和pc3上ping s2 都相通)


*******************************************************************************************

私有VLAN的解析

PVLAN(private VLAN)私有VLAN

作用:能够为VLAN内不同端口之间提供隔离的VLAN,能够在一个VLAN之中实现端口之间的隔离。
 
注意:配置时,VTP必须为透明模式
 
组成:
每个PVLAN包括两种VLAN:
1、主VLAN,即普通VLAN,其中可以包括多个辅助VLAN
2、辅助VLAN  又分为两种:隔离VLAN、联盟VLAN
 
辅助VLAN是属于主VLAN的,一个主VLAN可以包含多个辅助VLAN。
在一个主VLAN中只能有一个隔离VLAN,可以有多个联盟VLAN
 
辅助VLAN有两种类型【
CCNA培训
联盟VLAN:VLAN内的PC可以通信,能与混杂端口通信,但不能与其它VLAN通信,特性如同普通VLAN
隔离VLAN:VLAN内的PC不可以通信,只能与混杂端口通信。
 
三种端口类型:
host隔离端口---属于隔离VLAN
host联盟端口---属于联盟VLAN
promiscuous混杂端口---可以和其它端口通信,不属于任何一个子VLAN,通常是连接网关的端口或是连接服务器的端口。
 
pVLAN中的两种接口类型:处在pVLAN中的交换机物理端口,有两种接口类型。
①混杂端口(Promiscuous Port)
②主机端口(Host Port)
其中“混杂端口”是隶属于“Primary VLAN”的;“主机端口”是隶属于“Secondary VLAN”的。因为“Secondary VLAN”是具有两种属性的,那么,处于“Secondary VLAN”当中的“主机端口”依“Secondary VLAN”属性的不同而不同,也就是说“主机端口”会继承“Secondary VLAN”的属性。那么由此可知,“主机端口”也分为两类——“isolated端口”和“community端口”。
 
规则:
在一个主VLAN中只能有一个隔离VLAN,可以有多个联盟VLAN【
CCNA考试
隔离VLAN中的主机相互间不能访问,也不能和其它子VLAN访问,也不能和外部VLAN访问,只能与混杂端口访问
联盟VLAN中的主机可以相互访问,可以和混杂端口访问,但不能和其它子VLAN访问,也不能和外部VLAN访问
 

私有vlan


 
1、设置主VLAN
SW1(config)#vlan 200
  private-vlan primary 
 
2、设置二级子VLAN
SW1(config)#vlan 201
  private-vlan isolated    设置为隔离VLAN
 
SW1(config)#vlan 202
  private-vlan community   设置为联盟VLAN
 
3、将子VLAN划入主VLAN中,建立一个联系
SW1(config)#vlan 200
  private-vlan association 201-202
 
SW1(config)#vlan 200
  private-vlan association add 203   加入一个子VLAN
  private-vlan association remove 203  移除一个子VLAN
 
4、将端口设定一个模式,并划入相应的VLAN中
 
int e0
  switchport mode private-vlan host  设置端口的模式,根据子VLAN的类型成为相应的端口
  switchport private-vlan host-association 200 201-----将端口划入VLAN200中的子VLAN201
 
以上将E0定义为辅助VLAN201的主机端口,即成为一个隔离端口,但意义何在?为了让接入其上的主机隔离吗?
 
int e0
  switchport mode private-vlan promiscuous   设置混杂端口
 
  switchport private-vlan mapping 200 201-202    设定混杂端口所能管理的子VLAN
  switchport private-vlan mapping 200 add/remove 203    增加或移除一个可管理的子VLAN
 
 
showvlan private-vlan
 
 
 
5、将辅助VLAN映射到主VLAN的第3层SVI接口,从而允许PVALN入口流量的第3层交换。
int vlan 200
  private-vlan mapping 201-202    设置给予哪几个子VLAN特权,允许这几个子VLAN下的端口访问外部的网段。
 
show interfaces private-vlan mapping

*******************************************************************************************


















本文转自shangshanyang51CTO博客,原文链接:http://blog.51cto.com/qqran/1632419 ,如需转载请自行联系原作者