一,PVLAN類型
主VLAN
主VLAN可以由多個輔助私用VLAN組成,而這些輔VLAN與主VLAN屬于同一子網。
輔助VLAN?
①? 團體VLAN:如果某個端口屬于團體VLAN,那么它就不僅能夠與相同團體VLAN中的其他端口進行通信,而且還能夠與PVLAN的混合端口進行通信。
②? 隔離VLAN:如果某個端口屬于隔離VLAN,那么它就只能與混合端口進行通信。同一個隔離VLAN中的端口間不能通信,而只能與混合端口進行通信。每個PVLAN中只能有一個隔離VLAN。
二,實驗目的
利用PVLAN技術實現
①vlan20內PC能互通,且都能訪問網關
②vlan30內PC不互通,但都能訪問網關
③vlan20內PC,不能與vlan30內PC互通
四,配置命令
Router
Router>enable
Router#configure terminal
Router(config)#int e0/0? ? ? ? ? ? ? ?????????主接口對應native vlanRouter(config-if)#ip address 192.168.1.11 255.255.255.0? ? ? ? 配置網關
Router(config-if)#no shutdown? ? ?????????打開主接口
PC1?
VPCS> ip 192.168.1.1 24????????配置PC1的IP地址
VPCS> ping 192.168.1.11? ? ? ? 測試能ping通網關
PC2?
VPCS> ip 192.168.1.2 24????????配置PC2的IP地址
VPCS> ping 192.168.1.11????????測試能ping通網關
PC3
VPCS> ip 192.168.1.3 24????????配置PC3的IP地址
VPCS> ping 192.168.1.11????????測試能ping通網關
PC4?
VPCS> ip 192.168.1.4 24? ? ? ? 配置PC4的IP地址
VPCS> ping 192.168.1.11????????測試能ping通網關
Switch
Switch>enable
Switch#configure terminal
Switch(config)#vtp mode off? ? ? ? ? ? ? ? ? ? ? ? ? ?關閉vtp-
Switch(config)#vlan 10? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Switch(config-vlan)#private-vlan primary????????創建主vlan10
Switch(config-vlan)#exit-
Switch(config)#vlan 20
Switch(config-vlan)#private-vlan community? ? 創建團體vlan
Switch(config-vlan)#exit-
Switch(config)#vlan 30
Switch(config-vlan)#private-vlan isolated? ? ? ? ? 創建隔離vlan
Switch(config-vlan)#exit-
Switch(config)#vlan 10Switch(config-vlan)#private-vlan association add 20,30? ? ? ? ? ?主與輔助vlan映射
Switch(config-vlan)#exit-
Switch(config)#int range e0/1-2
Switch(config-if-range)#switchport mode private-vlan host? ? ? ? ? ? ? ? ? ? ? ?配置主機端口
Switch(config-if-range)#switchport private-vlan host-association 10 20? ? 綁定vlan
Switch(config-if-range)#exit-
Switch(config)#int range e1/1-2
Switch(config-if-range)#switchport mode private-vlan host? ? ? ? ? ? ? ? ? ? ? ?? 配置主機端口
Switch(config-if-range)#switchport private-vlan host-association 10 30??????綁定vlan
Switch(config-if-range)#exit-
Switch(config)#int e0/0
Switch(config-if)#switchport mode private-vlan promiscuous?????????????????配置混雜端口
Switch(config-if)#switchport private-vlan mapping 10 add 20,30? ? ? ? ? ??配置混雜端口所在的主vlan以及關聯的輔助vlan-
Switch(config-if)#end
Switch#show running-config? ? ? 查看運行配置
六,實驗測試
PC1測試
ping 192.168.1.11? ? ? ?可以與網關互通
ping 192.168.1.2? ? ? ? ?團體vlan內部能互訪
ping 192.168.1.3? ? ? ? ?團體vlan與隔離vlan不能互訪
PC4測試
ping 192.168.1.11? ? ? ? 可以與網關互通
ping 192.168.1.3? ? ? ? ? 隔離vlan內部不能互訪
ping 192.168.1.1? ? ? ? ? 團體vlan與隔離vlan不能互訪