龙空技术网

在思科交换机上配置隔离的专用VLAN

朗联科技 415

前言:

当前你们对“思科ipsubnetvlan”大体比较关注,小伙伴们都想要了解一些“思科ipsubnetvlan”的相关知识。那么小编同时在网摘上搜集了一些有关“思科ipsubnetvlan””的相关资讯,希望兄弟们能喜欢,姐妹们一起来学习一下吧!

在某些情况下,如果没有将设备放置在不同的 IP 子网上,则需要阻止思科交换机上终端设备之间的第 2 层 (L2) 连接。此设置可避免浪费 IP 地址。使用专用 VLAN (PVLAN) 可以对同一 IP 子网内的第 2 层设备进行隔离。可以对交换机上的某些端口进行限制,使其只能到达连接了默认网关、备份服务器或 Cisco LocalDirector 的特定端口。

先决条件

假设拥有现成的网络并能够在不同端口之间建立连接,作为 PVLAN 的补充。如果有多台交换机,请确保交换机之间的中继正常运行,并允许中继上的 PVLAN。并非所有交换机和软件版本都支持 PVLAN。开始配置之前,请参阅专用 VLAN Catalyst 交换机支持表,以确定您的平台和软件版本是否支持 PVLAN。

本文档使用以下网络设置:

在这种情况下,隔离 VLAN(“101”)中的设备在第 2 层上的彼此通信受到限制。但设备能够连接到 Internet。此外,4006 上的端口“Gig 3/26”具有混合标识。使用此可选配置可将 GigabitEthernet 3/26 中的设备连接到隔离 VLAN 中的所有设备。例如,使用此配置还可以将所有 PVLAN 主机设备上的数据备份到管理工作站。混合端口的其他用途包括与外部路由器、LocalDirector、网络管理设备及其他设备进行连接。

配置主 VLAN 和隔离 VLAN

执行以下步骤可创建主 VLAN 和辅助 VLAN,并将各种端口绑定到这些 VLAN。这些步骤包括 CatOS 和 Cisco IOS 软件的示例。发出为 OS 安装设置的相应命令。

创建主 PVLAN。CatOS

 Switch_CatOS> (enable) set vlan primary_vlan_id pvlan-type primary name primary_vlan !--- Note: Thise command should be on one line.VTP advertisements transmitting temporarily stopped,and will resume after the command finishes.Vlan 100 configuration successful
Cisco IOS 软件
Switch_IOS(config)#vlan primary_vlan_idSwitch_IOS(config-vlan)#private-vlan primarySwitch_IOS(config-vlan)#name primary-vlanSwitch_IOS(config-vlan)#exit
创建一个或多个隔离 VLAN。CatOS
Switch_CatOS> (enable) set vlan secondary_vlan_id pvlan-type isolated name isolated_pvlan !--- Note: This command should be on one line.VTP advertisements transmitting temporarily stopped,and will resume after the command finishes.Vlan 101 configuration successful 
Cisco IOS 软件
Switch_IOS(config)#vlan secondary_vlan_idSwitch_IOS(config-vlan)#private-vlan isolatedSwitch_IOS(config-vlan)#name isolated_pvlanSwitch_IOS(config-vlan)#exit 
将一个或多个隔离 VLAN 绑定到主 VLAN。CatOS
Switch_CatOS> (enable) set pvlan primary_vlan_id secondary_vlan_idVlan 101 configuration successfulSuccessfully set association between 100 and 101.
Cisco IOS 软件
Switch_IOS(config)#vlan primary_vlan_idSwitch_IOS(config-vlan)#private-vlan association secondary_vlan_idSwitch_IOS(config-vlan)#exit
验证专用 VLAN 配置。CatOS
Switch_CatOS> (enable) show pvlanPrimary Secondary Secondary-Type Ports------- --------- ---------------- ------------100 101 isolated 
Cisco IOS 软件
Switch_IOS#show vlan private-vlanPrimary Secondary Type Ports------- --------- ----------------- -------100 101 isolated 

将端口分配到 PVLAN

提示: 实施此过程之前,请发出 show pvlan capability mod/port 命令(适用于 CatOS),以确定某个端口能否变为 PVLAN 端口。

注意: 执行此过程的步骤 1 之前,请在接口配置模式下发出 switchport 命令,将端口配置为第 2 层交换接口。

在所有合适的交换机上配置主机端口。CatOS

Switch_CatOS> (enable)set pvlan primary_vlan_id secondary_vlan_id mod/port!--- Note: This command should be on one line.Successfully set the following ports to Private Vlan 100,101: 2/20
Cisco IOS 软件
Switch_IOS(config)#interface gigabitEthernet mod/portSwitch_IOS(config-if)#switchport private-vlan host primary_vlan_id secondary_vlan_id !--- Note: This command should be on one line.Switch_IOS(config-if)#switchport mode private-vlan hostSwitch_IOS(config-if)#exit
在其中一台交换机上配置混合端口。CatOS
Switch_CatOS> (enable) set pvlan mapping primary_vlan_id secondary_vlan_id mod/port!--- Note: This command should be on one line.Successfully set mapping between 100 and 101 on 3/26
注意: 对于 Catalyst 6500/6000,Supervisor 引擎将 CatOS 作为系统软件运行时,如果希望在 VLAN 之间进行第 3 层交换,则 Supervisor 引擎上的 MSFC 端口(15/1 或 16/1)应为混合端口。Cisco IOS 软件
Switch_IOS(config)#interface interface_type mod/portSwitch_IOS(config-if)#switchport private-vlan mapping primary_vlan_id secondary_vlan_id !--- Note: This command should be on one line.Switch_IOS(config-if)#switchport mode private-vlan promiscuous Switch_IOS(config-if)#end

第 3 层配置

此可选部分描述了允许 PVLAN 输入数据流路由的配置步骤。如果只需启用第 2 层连接,则可以省略此阶段。

VLAN 接口的配置方式与正常第 3 层路由的配置方式相同。此配置涉及:配置 IP 地址使用 no shutdown 命令激活接口验证 VLAN 是否存在于 VLAN 数据库中将要路由的辅助 VLAN 映射到主 VLAN。

Switch_IOS(config)#interface vlan primary_vlan_idSwitch_IOS(config-if)#private-vlan mapping secondary_vlan_list Switch_IOS(config-if)#end
注意: 仅对主 VLAN 配置第 3 层 VLAN 接口。在隔离或社区 VLAN 配置下,隔离及社区 VLAN 的 VLAN 接口将处于非活动状态。发出 show interfaces private-vlan mapping(适用于 Cisco IOS 软件)或 show pvlan mapping(适用于 CatOS)命令以验证映射。如果配置映射后需要修改辅助 VLAN 列表,请使用 add 或 remove 关键字。
Switch_IOS(config-if)#private-vlan mapping add secondary_vlan_listorSwitch_IOS(config-if)#private-vlan mapping remove secondary_vlan_list

注意: 对于有 MSFC 的 Catalyst 6000 交换机,请确保从 Supervisor 引擎到路由引擎的端口(例如,端口 15/1 或 16/1)为混合端口。

cat6000> (enable) set pvlan mapping primary_vlan secondary_vlan 15/1Successfully set mapping between 100 and 101 on 15/1

发出命令 show pvlan mapping 以验证映射。

cat6000> (enable) show pvlan mapping Port Primary Secondary---- ------- ---------15/1 100 101

配置

Access_Layer (Catalyst 4003:CatOS)Access_Layer> (enable) show config This command shows non-default configurations only. Use 'show config all' to show both default and non-default configurations. ............. !--- Output suppressed. #system set system name Access_Layer ! #frame distribution method set port channel all distribution mac both ! #vtp set vtp domain Cisco set vtp mode transparent set vlan 1 name default type ethernet mtu 1500 said 100001 state active  set vlan 100 name primary_for_101 type ethernet pvlan-type primary mtu 1500  said 100100 state active !--- This is the primary VLAN 100. !--- Note: This command should be on one line. set vlan 101 name isolated_under_100 type ethernet pvlan-type isolated mtu  1500 said 100101 state active !--- This is the isolated VLAN 101. !--- Note: This command should be on one line. set vlan 1002 name fddi-default type fddi mtu 1500 said 101002 state active !--- Output suppressed. #module 1 : 0-port Switching Supervisor ! #module 2 : 24-port 10/100/1000 Ethernet set pvlan 100 101 2/20!--- Port 2/20 is the PVLAN host port in primary VLAN 100, isolated !--- VLAN 101. set trunk 2/3 desirable dot1q 1-1005 set trunk 2/4 desirable dot1q 1-1005 set trunk 2/20 off dot1q 1-1005!--- Trunking is automatically disabled on PVLAN host ports. set spantree portfast 2/20 enable!--- PortFast is automatically enabled on PVLAN host ports. set spantree portvlancost 2/1 cost 3!--- Output suppressed. set spantree portvlancost 2/24 cost 3 set port channel 2/20 mode off!--- Port channeling is automatically disabled on PVLAN !--- host ports. set port channel 2/3-4 mode desirable silent ! #module 3 : 34-port 10/100/1000 Ethernet end

Core(Catalyst 4006:Cisco IOS 软件)Core#show running-config Building configuration... !--- Output suppressed. ! hostname Core ! vtp domain Cisco vtp mode transparent!--- VTP mode is transparent, as PVLANs require. ip subnet-zero ! vlan 2-4,6,10-11,20-22,26,28  ! vlan 100 name primary_for_101 private-vlan primary private-vlan association 101 ! vlan 101 name isolated_under_100 private-vlan isolated ! interface Port-channel1!--- This is the port channel for interface GigabitEthernet3/1 !--- and interface GigabitEthernet3/2. switchport switchport trunk encapsulation dot1q switchport mode dynamic desirable ! interface GigabitEthernet1/1 ! interface GigabitEthernet1/2 ! interface GigabitEthernet3/1!--- This is the trunk to the Access_Layer switch. switchport trunk encapsulation dot1q switchport mode dynamic desirable channel-group 1 mode desirable ! interface GigabitEthernet3/2!--- This is the trunk to the Access_Layer switch. switchport trunk encapsulation dot1q switchport mode dynamic desirable channel-group 1 mode desirable ! interface GigabitEthernet3/3 !!--- There is an omission of the interface configuration !--- that you do not use. ! interface GigabitEthernet3/26  switchport private-vlan mapping 100 101 switchport mode private-vlan promiscuous!--- Designate the port as promiscuous for PVLAN 101. !!--- There is an omission of the interface configuration !--- that you do not use. !!--- Output suppressed. interface Vlan25!--- This is the connection to the Internet. ip address 10.25.1.1 255.255.255.0 ! interface Vlan100!--- This is the Layer 3 interface for the primary VLAN. ip address 10.1.1.1 255.255.255.0 private-vlan mapping 101!--- Map VLAN 101 to the VLAN interface of the primary VLAN (100). !--- Ingress traffic for devices in isolated VLAN 101 routes !--- via interface VLAN 100.

多个交换机之间的专用 VLAN

有两种方法可以在多个交换机之间采用专用 VLAN。主要有以下两种方法:

常规中继

与常规 VLAN 一样,PVLAN 也可以在多个思科交换机之间使用。中继端口将主 VLAN 和辅助 VLAN 传输到相邻的交换机。中继端口处理专用 VLAN 的方式与其他任何 VLAN 相同。来自一台交换机中某个隔离端口的数据流无法到达另一台交换机中的隔离端口,这是多个交换机之间使用 PVLAN 的一项特性。

在所有中间设备(包括没有 PVLAN 端口的设备)上配置 PVLAN,以维护 PVLAN 配置的安全性并避免将配置为 PVLAN 的 VLAN 另作他用。

中继端口承载来自常规 VLAN 的数据流,以及来自主 VLAN、隔离 VLAN 和社区 VLAN 的数据流。

提示: 如果进行中继的两个交换机都支持 PVLAN,Cisco 建议使用标准中继端口。

由于 VTP 不支持 PVLAN,因此必须在第 2 层网络中的所有cisco交换机上手动配置 PVLAN。如果网络中的某些交换机上未配置主 VLAN 和辅助 VLAN 关联,则这些交换机上的第 2 层数据库不会进行合并。此情况可能导致这些交换机上产生不必要的 PVLAN 数据流泛洪。

专用 VLAN 中继

PVLAN 中继端口可以承载多个辅助 PVLAN 及非 PVLAN。在数据包的接收和传输过程中,PVLAN 中继端口上包含辅助或常规 VLAN 标记。

仅支持 IEEE 802.1q 封装。使用隔离中继端口可以通过单个中继对所有辅助端口的数据流进行组合。使用混合中继端口可以将此拓扑中所需的多个混合端口组合到单个承载多个主 VLAN 的中继端口中。

如果预计使用专用 VLAN 隔离主机端口承载多个 VLAN(正常 VLAN 或用于多个专用 VLAN 域),请使用隔离专用 VLAN 中继端口。这可用于连接某个不支持专用 VLAN 的下行交换机。

在专用 VLAN 混合主机端口正常使用但需要承载多个 VLAN(正常 VLAN 或用于多个专用 VLAN 域)的情况下,可以使用专用 VLAN 混合中继。这可用于连接某个不支持专用 VLAN 的上行路由器。

标签: #思科ipsubnetvlan