配置PVLAN的步骤包括:配置Primary VLAN、配置Secondary VLAN、设置Primary VLAN和Secondary VLAN间的映射关系,以上任务都是必选的,一旦启用PVLAN就必须配置。具体配置命令参考下面的建议。
(1)设置VTP的transparent(透明)模式
COS交换机
set vtp mode transparent
IOS交换机
(privileged) vlan database
(vlan_database) vtp transparent
在创建一个私用VLAN之前,您必须配置VTP为transparent(透明)模式。私用VLAN必须在单台交换机上配置,不能有其他交换机上VLAN的成员端口。私用VLAN也能带所有其他类型的Cisco交换机不知道的TLV。
(2)创建主(primary)私用VLAN
COS交换机
set vlan primary_number pvlan-type primary
IOS交换机
(global) vlan primary_number
(vlan-config) private-vlan primary
你必须首先创建主(primary)私用VLAN。后面的步骤要用主VLAN号(primary_number)来绑定次(secondary)VLAN和映射混杂(promiscuous)端口。
(3)创建isolated(被隔离)VLAN和community(群体)VLAN
COS交换机
set vlan secondary_number pvlan-type [isolated | community |twoway-community]
IOS交换机
(global) vlan secondary_number
(vlan-config) private-vlan [isolated | community]
配置isolated(被隔离)或community(群体)次VLAN来划分端口和控制流量。每一个这样的VLAN的(primary_number)都必须彼此不同和唯一,和主VLAN的number也要不同。Isolated(被隔离)VLAN的成员只能和在第6步中映射的混杂(promiscuous)端口进行通信。双向(two-way)的群体就像一个普通的群体一样,但是有更多功能:能用访问控制列表检查进出(双向)VLAN的流量,而且在私用VLAN内提供了更强的安全性。
(4)把isolated(被隔离)VLAN和community(群体)VLAN绑定到主VLAN上
COS交换机
set pvlan primary_number secondary_number
IOS交换机
(global) vlan primary_number
(vlan-config) private-vlan association secondary_number_list [addsecondary_number_list]
这条命令把次VLAN关联或者说绑定到主VLAN上。对于IOS命令来说,add选项允许以后关联其他VLAN。
(5)将端口加入isolated(被隔离)VLAN和community(群体)VLAN
COS交换机
set pvlan primary_number secondary_number mod/port [sc0]
IOS交换机
(global) interface type mod/port
(interface) switchport
(interface) switchport mode private-vlan host
(interface) switchport mode private-vlan host-association primary_number secondary_number
在已经创建和关联好了主次VLAN之后,必须把端口划给VLAN。对于COS交换机来说,可以把sc0接口加到私用VLAN中。
(6)给isolated(被隔离)VLAN和community(群体)VLAN映射混杂(promiscuous)端口
COS交换机
set pvlan mapping primary_number secondary_number mod/port
IOS交换机
(global) interface type mod/port
(interface) switchport
(interface) switchport mode private-vlan promiscuous
(interface) switchport mode private-vlan mapping primary_number secondary_number
在把端口划给次VLAN之后,为了能访问到isolated(被隔离)VLAN或者community(群体)VLAN之外,必须将VLAN映射到一个混杂(promiscuous)端口。
(7)给isolated(被隔离)VLAN和community(群体)VLAN映射MSFC接口(可选)
COS交换机 COS set pvlan mapping primary_number secondary_number 15/1 session 15
(privileged)config t
(global)interface vlan primary_number
(interface)ip address address mask
IOS交换机 (global) interface primary_number
(interface) ip address address mask
(interface) private-vlan mapping primary_number secondary_number
如果您的交换机有一块MSFC,那么可以将私用VLAN映射到MSFC。对于运行COS的交换机来说,要把VLAN映射到端口15/1(对于在于2槽的MSFC来说是16/1),然后将VLAN接口上的IP地址配置为主VLAN的number。对于IOS交换机来说,要找到primary_number的VLAN接口,然后把主次VLAN是映射到那个端口。
提示:你可以配置私用边缘VLAN。3500XL交换机使用受保护端口(protected port)的概念来控制交换机上的流量。3500XL上受保护端口不会向同一交换机上的另一个受保护端口转发流量。这样做和isolated(被隔离)VLAN类似,因为受保护的端口彼此不能通信。使用下面的命令配置受保护的端口。要配置一个私用边缘VLAN,可以选定接口,键入命令port protected。为了核实该端口已经处于受保护的模式,可以使用命令show port protected。
(8)核实PVLAN的运行
在配置私用VLAN之后,可以使用下面的命令来核实它的运行:
COS交换机
show pvlan number
show pvlan mapping
show pvlan capability mod/port
IOS交换机
show vlan private-vlan [type]
show interface private-vlan mapping
show interface type mod/port switchport
解决:PVLAN配置案例
这是一所外国语大学的网络拓扑图,由于考虑到安全的原因,我们只分隔出本案例中需要说明的部分,参见下图。
在这个案例中,需要交换机Sw-access1的端口1和2配置成了受保护的端口,它们都在VLAN 10里,Sw-core1上的VLAN 10服务器(VLAN10 Server)也在VLAN 10里。这就让PC只能连接到这台服务器,而不会连接到其它服务器。在汇集交换机上还创建了私用VLAN 90,它包括一次community VLAN 901和一个isolated VLAN 900,端口3/46的服务器2和端口3/48服务器3都在community VLAN 901内,而连接到端口3/1和3/2的服务器在isolated VLAN 900内。使10.10.90.5和10.10.90.6之间不能通讯,10.10.90.7和10.10.90.8能够互相通讯,但这四台主机都可以和10.10.90.2通讯。所有这些设备都被映射到连接在端口1/2上的路由器。
1.核心交换机Sw-core1的设置清单
Sw-core1#vlan database
Sw-core1(vlan)#vtp transparent
Sw-core1(vlan)#exit
Sw-core1#conf t
Sw-core1(config)#vlan 90
Sw-core1(config-vlan)#private-vlan primary
Sw-core1(config-vlan)#vlan 900
Sw-core1(config-vlan)#private-vlan isolated
Sw-core1(config-vlan)#vlan 901
Sw-core1(config-vlan)#private-vlan community
Sw-core1(config-vlan)#vlan 90
Sw-core1(config-vlan)#private-vlan association 900,901
Sw-core1(config-vlan)#interface range fastethernet 3/1 – 2
Sw-core1(config-if)#switchport mode private-vlan host
Sw-core1(config-if)#switchport mode private-vlan host-association 90 900
Sw-core1(config-if)#no shut
Sw-core1(config-if)#interface range fastethernet 3/46 , 3/48
Sw-core1(config-if)#switchport
Sw-core1(config-if)#switchport mode private-vlan host
Sw-core1(config-if)#switchport mode private-vlan host-association 90 901
Sw-core1(config-if)#no shut
Sw-core1(config-if)#interface gigabitethernet 1/2
Sw-core1(config-if)#switchport
Sw-core1(config-if)#switchport mode private-vlan promiscuous
Sw-core1(config-if)#switchport mode private-vlan mapping 90 900,901
Sw-core1(config-if)#no shut
Sw-core1(config-if)#interface vlan 90
Sw-core1(config-if)#ip address 10.10.90.1 255.255.255.0
Sw-core1(config-if)#private-vlan mapping 90 900,901
Sw-core1(config-if)#no shut
Sw-core1(config-if)#end
Sw-core1#copy running-config startup-config
(2)负责宿舍里面接入的交换机配置清单
Sw-access1# configure terminal
Sw-access1(config)#interface fastethernet 0/1
Sw-access1(config-if)#switchport access vlan 10
Sw-access1(config-if)#port protected
Sw-access1(config-if)#interface fastethernet 0/1
Sw-access1(config-if)#switchport access vlan 10
Sw-access1(config-if)#port protected
Sw-access1(config-if)#interface gigabitethernet 0/1
Sw-access1(config-if)#switchport mode trunk
Sw-access1(config-if)#switchport trunk encapsulation dot1q
Sw-access1(config-if)#end
Sw-access1# copy running-config startup-config下载本文