應用背景:Pvlan主要應用於電信級網絡和寫字樓網絡,智能小區,商務寫字樓,城域以太網
概念術語
Primary VLAN 主VLAN
Secondary VLAN 輔助VLAN
Isolated vlan 隔離VLAN
Community vlan 團體VLAN
Promiscuos port 混雜端口
解釋:
Primary VLAN:是一個全局VLAN的標識
Isolated VLAN:同屬一個隔離VLAN間的用戶是不能夠互相訪問的,但是可以跟主VLAN和混雜端口通信
Community VLAN:同屬同一個團體VLAN內的用戶,是能夠直接互相訪問的,且可以跟主VLAN和混雜端口通信
Promiscuous port:連接計費服務器、網關或路由器等,可以跟所有的其它端口通信
配置方法(參考):
//劃分主VLAN
Switch(config)# vtp mode transparent //VTP設爲透明模式
Switch(config)#vlan 800
Switch(config-vlan)#private-vlan primary
//劃分團體VLAN
Switch(config)#vlan 511
Switch(config-vlan)#private-vlan community
//劃分隔離VLAN
Switch(config)#vlan 522
Switch(config-vlan)#private-vlan isolated
//設定某一物理端口爲混雜端口 F0/5
Switch(config)#interface F0/5
Switch(config-if)# switchport mode private-vlan promiscuous
Switch(config-if)# switchport private-vlan mapping 800 add 511,522
//將團體VLAN和隔離VLAN與主VLAN關聯
Switch(config)#vlan 800
Switch(config-vlan)#private-vlan association 511,522
//將團體VLAN 511關聯到F0/10和F0/11接口上,並能夠與主VLAN 800進行通信
Switch(config)#interface rang F0/10 , f0/11
Switch(config-if-rang)#switchport mode private-vlan host
Switch(config-if-rang)#switchport private-vlan host-association 800 511
//將隔離VLAN 522關聯到F0/20和F0/21接口上,並能夠與主VLAN 800進行通信
Switch(config)#interface range F0/20 , f0/21
Switch(config-if-range)#switchport mode private-vlan host
Switch(config-if-range)#switchport private-vlan host-association 800 522
//將其它各個輔助VLAN映射到主VLAN中,以實現跟主VLAN進行直接通信
Switch(config)#interface vlan 800
Switch(config-if)#private-vlan mapping 511,522
pVLAN實驗的完整配置如下:(交換機配置)
SW(config)# vlan 10
SW(config-vlan)# private-vlan isolated
SW(config)# vlan 20
SW(config-vlan)# private-vlan community
SW(config)# vlan 800
SW(config-vlan)# private-vlan primary
SW(config-vlan)#private-vlan association 10,20
SW(config)# interface FastEthernet0/1
SW(config-if)# switchport private-vlan host-association 800 10
SW(config-if)# switchport mode private-vlan host
SW(config-if)# spanning-tree portfast
SW(config)# interface FastEthernet0/2
SW(config-if)# switchport private-vlan host-association 800 10
SW(config-if)# switchport mode private-vlan host
SW(config-if)# spanning-tree portfast
SW(config)# interface FastEthernet0/3
SW(config-if)# switchport private-vlan host-association 800 20
SW(config-if)# switchport mode private-vlan host
SW(config-if)# spanning-tree portfast
SW(config)# interface FastEthernet0/4
SW(config-if)# switchport private-vlan host-association 800 20
SW(config-if)# switchport mode private-vlan host
SW(config-if)# spanning-tree portfast
SW(config)# interface FastEthernet0/5
SW(config-if)# switchport private-vlan mapping 800 10,20
SW(config-if)# switchport mode private-vlan promiscuous
SW(config-if)# spanning-tree portfast
SW(config)# interface Vlan800
SW(config-if)# private-vlan mapping 10,20
SW(config-if)# end
測試結果:隔離VLAN 10之間不能夠通信,但可以跟SERVER端口通信
團體VLAN 20 不能跟隔離VLAN通信,可以跟自己VLAN內的用戶通信,同時也可以跟SERVER端口通信
混雜端口可以跟所有的用戶進行通信