• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C S5830V2[S5820V2]系列以太网交换机 典型配置举例-Release22xx系列-6W100

目录

43-端口安全典型配置举例

本章节下载 43-端口安全典型配置举例  (214.52 KB)

docurl=/cn/Service/Document_Software/Document_Center/Switches/Catalog/S5800/S5830V2/Configure/Typical_Configuration_Example/H3C_S5830V2[S5820V2]-Release22xx-6W100/201403/819609_30005_0.htm

43-端口安全典型配置举例


1  端口安全典型配置举例

1.1  简介

本章介绍了使用端口安全功能实现用户安全接入的典型配置举例。

1.2  使用限制

·     如果已全局开启了802.1X或MAC地址认证功能,则无法使能端口安全功能。

·     当端口安全功能开启后,端口上的802.1X功能以及MAC地址认证功能将不能被手动开启,且802.1X端口接入控制方式和端口接入控制模式也不能被修改,只能随端口安全模式的改变由系统更改。

·     端口上有用户在线的情况下,端口安全功能无法关闭。

·     端口安全模式的配置与端口加入聚合组或业务环回组互斥。

·     当多个用户通过认证时,端口下所允许的最大用户数根据不同的端口安全模式,取端口安全所允许的最大MAC地址数与相应模式下允许认证用户数的最小值。例如,userLoginSecureExt模式下,端口下所允许的最大用户为配置的端口安全所允许的最大MAC地址数与802.1X认证所允许的最大用户数的最小值。

1.3  端口安全autolearn模式典型配置举例

1.3.1  适用产品和版本

表1 配置适用的产品与软件版本关系

产品

软件版本

S5830V2&S5820V2系列以太网交换机

Release 2208P01,Release 2210

 

1.3.2  组网需求

图1所示,用户通过Switch连接到网络。通过配置端口安全autolearn模式,实现对接入用户的控制,具体需求如下:

·     最多同时允许64个用户通过交换机接入Internet,用户无需进行认证;

·     当用户数量超过设定值后,新用户无法通过Switch接入Internet。

图1 端口安全autolearn模式配置组网图

 

1.3.3  配置思路

·     配置交换机与用户相连端口的安全模式为autolearn。

·     为防止交换机与用户相连端口学习到的MAC地址的丢失,及安全MAC地址不老化会带来一些问题,需配置安全MAC地址并设定安全MAC地址老化时间(例如30分钟)。

·     设置最大安全MAC地址数为64,当再有新的MAC地址接入时,交换机与用户相连端口被暂时断开连接,30秒后自动恢复端口的开启状态。

1.3.4  配置注意事项

·     当端口安全已经使能且当前端口安全模式不是noRestrictions时,若要改变端口安全模式,必须首先执行undo port-security port-mode命令恢复端口安全模式为noRestrictions模式。

·     当端口工作于autoLearn模式时,无法更改端口安全允许的最大MAC地址数。

1.3.5  配置步骤

# 使能端口安全功能。

<Switch> system-view

[Switch] port-security enable

# 设置Sticky MAC地址的老化时间为30分钟。

[Switch] port-security timer autolearn aging 30

# 设置端口允许的最大安全MAC地址数为64。

[Switch] interface ten-gigabitethernet 1/0/1

[Switch-Ten-GigabitEthernet1/0/1] port-security max-mac-count 64

# 设置端口安全模式为autoLearn。

[Switch-Ten-GigabitEthernet1/0/1] port-security port-mode autolearn

# 设置触发入侵检测特性后的保护动作为暂时关闭端口,关闭时间为30秒。

[Switch-Ten-GigabitEthernet1/0/1] port-security intrusion-mode disableport-temporarily

[Switch-Ten-GigabitEthernet1/0/1] quit

[Switch] port-security timer disableport 30

1.3.6  验证配置

上述配置完成后,可以用display命令显示端口安全配置情况,如下:

<Switch> display port-security interface ten-gigabitethernet 1/0/1

 Port security is enabled globally

 AutoLearn aging time is 30 minutes

 Disableport Timeout: 30s

 OUI value:

 

Ten-GigabitEthernet1/0/1 is link-up

   Port mode: autoLearn

   NeedToKnow mode: Disabled

   Intrusion protection mode: DisablePortTemporarily

   Max number of secure MAC addresses: 64

   Current number of secure MAC addresses: 0

   Authorization is permitted

可以看到端口的最大安全MAC数为64,端口模式为autoLearn,入侵保护动作为DisablePortTemporarily,入侵发生后端口禁用时间为30秒。

配置完成后,允许地址学习,学习到的MAC地址数可以用上述命令显示,如学习到5个,那么存储的安全MAC地址数就为5,可以在端口视图下用display this命令查看学习到的MAC地址,如:

<Switch> system-view

[Switch] interface ten-gigabitethernet 1/0/1

[Switch-Ten-GigabitEthernet1/0/1] display this

#

interface Ten-GigabitEthernet1/0/1

 port link-mode bridge

 port-security max-mac-count 64

 port-security port-mode autolearn

 port-security intrusion-mode disableport-temporarily

 port-security mac-address security sticky 0002-0000-0015 vlan 1

 port-security mac-address security sticky 0002-0000-0014 vlan 1

 port-security mac-address security sticky 0002-0000-0013 vlan 1

 port-security mac-address security sticky 0002-0000-0012 vlan 1

 port-security mac-address security sticky 0002-0000-0011 vlan 1

#

当学习到的MAC地址数达到64后,用命令display port-security interface可以看到端口模式变为secure,再有新的MAC地址到达将触发入侵保护。

并且可以通过下述命令看到端口安全将此端口关闭:

<Switch> display interface ten-gigabitethernet 1/0/1

 gigabitEthernet1/0/1 current state: DOWN (  Port Security Disabled  )

 IP Packet Frame Type: PKTFMT_ETHNT_2, Hardware Address: 0023-8927-ad7d

 Description: Ten-GigabitEthernet1/0/1 Interface ......

30秒后,端口状态恢复:

[Switch-Ten-GigabitEthernet1/0/1] display interface ten-gigabitethernet 1/0/1

 Ten-GigabitEthernet1/0/1 current state: UP

 IP Packet Frame Type: PKTFMT_ETHNT_2, Hardware Address: 000f-cb00-5558

 Description: Ten-GigabitEthernet1/0/1 Interface

 ......

此时,如通过命令undo port-security mac-address security手动删除几条安全MAC地址后,端口安全的状态重新恢复为autoLearn,可以继续学习MAC地址。

1.3.7  配置文件

#

 port-security enable

 port-security timer autolearn aging 30

 port-security timer disableport 30

#

interface Ten-GigabitEthernet1/0/1

 port-security max-mac-count 64

 port-security port-mode autolearn

 port-security intrusion-mode disableport-temporarily

#

1.4  端口安全userLoginWithOUI模式典型配置举例

1.4.1  适用产品和版本

表2 配置适用的产品与软件版本关系

产品

软件版本

S5830V2&S5820V2系列以太网交换机

Release 2208P01,Release 2210

 

1.4.2  组网需求

图2所示,用户Host(已安装802.1X客户端软件)和打印机Printer通过交换机Switch连接到网络,交换机通过RADIUS服务器对用户进行身份认证,如果认证成功,用户被授权允许访问Internet资源。

通过配置端口安全userLoginWithOUI模式,实现对接入用户的控制,具体需求如下:

·     最多允许一个802.1X用户通过该端口接入Internet;

·     允许打印机通过与交换机相连端口实现与Internet资源正常连接;

·     当有非法用户接入时,触发入侵检测,将非法报文丢弃(不对端口进行关闭)。

图2 端口安全userLoginWithOUI模式组网图

 

1.4.3  配置思路

·     配置交换机与用户端相连的端口安全模式为userLoginWithOUI,即:该端口最多只允许一个802.1X认证用户接入,还允许一个指定OUI的源MAC地址的报文认证通过。为userLoginWithOUI端口安全模式配置5个OUI值(对应不同厂商的打印机MAC地址的OUI)。

·     配置端口安全的入侵检测功能:当交换机与用户端相连的端口接收到非法报文后,触发入侵检测,将非法报文丢弃,同时将其源MAC地址加入阻塞MAC地址列表中。

·     为认证用户添加认证域和RADIUS方案。

1.4.4  配置注意事项

·     参见1.3.4  配置注意事项

·     在标准的RADIUS协议中,RADIUS服务器的认证端口为UDP端口1812,我司设备作为RADIUS服务器时认证端口为UDP端口1645。因此,本举例中在Switch上配置RADIUS方案时,需要指定认证服务器的认证端口号为1645。

1.4.5  配置步骤

·     按照组网图配置设备各接口的IP地址,保证各主机、服务器和设备之间的路由可达。

·     如下服务器配置以H3C S5500-HI系列交换机作为RADIUS server为例,详细信息可参考相关产品手册。

 

1. Switch的配置

·     配置RADIUS方案

# 创建名为radsun的RADIUS方案,并配置主认证服务器IP和交互密钥。

<Switch> system-view

[Switch] radius scheme radsun

New Radius scheme

[Switch-radius-radsun] primary authentication 10.1.1.1 1645 key simple aabbcc

# 设置RADIUS服务器应答超时时间为5秒,RADIUS报文的超时重传次数的最大值为5。

[Switch-radius-radsun] timer response-timeout 5

[Switch-radius-radsun] retry 5

# 设置将去除域名的用户名发送给RADIUS服务器。

[Switch-radius-radsun] user-name-format without-domain

[Switch-radius-radsun] quit

# 创建名为sun的ISP域,并进入其视图。

[Switch] domain sun

# 指定名为radsun的RADIUS方案为该域lan-access用户的缺省RADIUS认证、授权方案。

[Switch-isp-sun] authentication default radius-scheme radsun

[Switch-isp-sun] authorization default radius-scheme radsun

[Switch-isp-sun] accounting default none

[Switch-isp-sun] quit

·     配置802.1X

# 配置802.1X的认证方式为CHAP。(该配置可选,缺省情况下802.1X的认证方式为CHAP)

[Switch] dot1x authentication-method chap

·     配置端口安全特性

# 添加5个OUI值。

[Switch] port-security oui index 1 mac-address 1234-0100-1111

[Switch] port-security oui index 2 mac-address 1234-0200-1111

[Switch] port-security oui index 3 mac-address 1234-0300-1111

[Switch] port-security oui index 4 mac-address 1234-0400-1111

[Switch] port-security oui index 5 mac-address 1234-0500-1111

# 设置端口安全模式为userLoginWithOUI。

[Switch] interface Ten-GigabitEthernet 1/0/1

[Switch-Ten-GigabitEthernet1/0/1] port-security port-mode userlogin-withoui

# 设置触发入侵检测功能后,将非法报文丢弃,同时将其源MAC地址加入阻塞MAC地址列表中。

[Switch-Ten-GigabitEthernet1/0/1] port-security intrusion-mode blockmac

[Switch-Ten-GigabitEthernet1/0/1] quit

# 使能端口安全功能。

[Switch] port-security enable

2. RADIUS server的配置

# 创建RADIUS用户“aaa”并进入RADIUS服务器用户视图

<Sysname> system-view

[Sysname] radius-server user aaa

# 指定用户aaa的密码为明文123456。

[Sysname -rdsuser-aaa] password simple 123456

[Sysname -rdsuser-aaa] quit

# 配置RADIUS客户端IP为10.1.1.2,共享密钥为明文aabbcc。

[Sysname] radius-server client-ip 10.1.1.2 key simple aabbcc

1.4.6  验证配置

查看名为radsun的RADIUS方案的配置信息:

[Switch] display radius scheme radsun

RADIUS Scheme Name  : radsun

  Index : 1

  Primary Auth Server:

    IP: 10.1.1.1                                 Port: 1645   State: active

    VPN : Not configured

Primary Acct Server:

    IP  : Not Configured                           Port: 1813   State: Block

    VPN : Not configured

 

  Accounting-On function                     : Disabled

    retransmission times                     : 50

    retransmission interval(seconds)         : 3

  Timeout Interval(seconds)                  : 5

  Retransmission Times                       : 5

  Retransmission Times for Accounting Update : 5

  Server Quiet Period(minutes)               : 5

  Realtime Accounting Interval(minutes)      : 12

  NAS IP Address                             : Not configured

  VPN                                        : Not configured

  User Name Format                           : without-domain

查看名为sun的ISP域的配置信息:

<Switch> display domain sun

Domain:sun

 State: Active

 Access-limit: Disable

 Access-Count: 0

 default Authentication Scheme:  radius: radsun

 default Authorization  Scheme:  radius: radsun

 default Accounting     Scheme:  none

查看端口安全的配置信息:

<Switch> display port-security interface ten-gigabitethernet 1/0/1

Port security is enabled globally

 AutoLearn aging time is 0 minutes

 Disableport Timeout: 20s

 OUI value:

   Index is 1,  OUI value is 123401

   Index is 2,  OUI value is 123402

   Index is 3,  OUI value is 123403

   Index is 4,  OUI value is 123404

   Index is 5,  OUI value is 123405

 

 Ten-GigabitEthernet1/0/1 is link-up

   Port mode: userLoginWithOUI

   NeedToKnow mode: Disabled

   Intrusion protection mode: BlockMacAddress

   Max number of secure MAC addresses: Not configured

   Current number of secure MAC addresses: 0

   Authorization is permitted     

配置完成后,如果有802.1X用户上线,则可以看到存储的安全MAC地址数为1。还可以通过下述命令查看802.1X用户的情况:

<Switch> display dot1x interface ten-gigabitethernet 1/0/1

 802.1X protocol is enabled globally

 CHAP authentication is enabled

Configuration: Transmit Period    30 s,  Handshake Period       15 s

                Quiet Period      60 s,  Quiet Timer is disabled

                Supp Timeout      30 s,  Server Timeout        100 s

                Reauth Period   3600 s

                Max attempts for sending an authentication request    2

 Max number of 802.1X users is 1024 per slot

 Current number of online 802.1X users is 1

 

 Ten-GigabitEthernet1/0/1  is link-up

   802.1X protocol is enabled

   Handshake is enabled

   Handshake secure is disabled

   802.1X unicast-trigger is disabled

   Periodic reauthentication is disabled

   The port is an authenticator

   Authentication mode is Auto

   Port access control type is MAC-based

   802.1X multicast-trigger is enabled

   Mandatory authentication domain: Not configured

   Max online users is 256

 

   EAPOL Packets: Tx 16331, Rx 102

   Sent EAP Request/Identity Packets : 16316

        EAP Request/Challenge Packets: 6

        EAP Success Packets: 4, Fail Packets: 5

   Received EAPOL Start Packets : 6

            EAPOL LogOff Packets: 2

            EAP Response/Identity Packets : 80

            EAP Response/Challenge Packets: 6

            Error Packets: 0

 1. Authenticated user : MAC address: 0002-0000-0011

 

   Controlled Users: 1

此外,端口还允许一个与OUI值匹配的MAC地址的用户通过,可以通过下述命令查看:

<Switch> display mac-address interface ten-gigabitethernet 1/0/1

MAC Address     VLAN ID   State          Port/NickName                         Aging

1234-0300-0011  1         Learned        Ten-GigabitEthernet1/0/1                Y

1.4.7  配置文件

#

 port-security enable

 port-security oui index 1 mac-address 1234-0100-0000

 port-security oui index 1 mac-address 1234-0200-0000

 port-security oui index 1 mac-address 1234-0300-0000

 port-security oui index 1 mac-address 1234-0400-0000

 port-security oui index 1 mac-address 1234-0500-0000

#

radius scheme radsun

 primary authentication 10.1.1.1 1645 key cipher $c$3$krBjik3mdDkyVGW9JRInyID3GMYJOw==

 timer response-timeout 5

 user-name-format without-domain

 retry 5

#

domain sun

 authentication default radius-scheme radsun

 authorization default radius-scheme radsun

 accounting default none

#

interface Ten-GigabitEthernet1/0/1

 port-security port-mode userlogin-withoui

 port-security intrusion-mode blockmac

#

1.5  端口安全macAddressOrUserLoginSecure模式典型配置举例

1.5.1  适用产品和版本

表3 配置适用的产品与软件版本关系

产品

软件版本

S5830V2&S5820V2系列以太网交换机

Release 2208P01,Release 2210

 

1.5.2  组网需求

图3所示,Host通过交换机连接到网络,交换机通过RADIUS服务器对客户端进行身份认证。如果认证成功,客户端被授权允许访问Internet资源。

通过配置端口安全macAddressOrUserLoginSecure模式,实现对接入用户的控制,具体需求如下:

·     交换机与用户相连端口下接入的用户可以使用802.1X认证或MAC地址认证;

·     802.1X认证用户数量限制为1个;但可以有多个MAC地址认证用户上线;

·     在线的MAC地址认证用户和802.1X认证用户总和不能超过64个;

·     MAC地址认证设置用户名格式为固定用户名格式,用户名为aaa,密码为123456;

·     为防止报文发往未知目的MAC地址,启动NeedToKnow特性。

图3 端口安全macAddressOrUserLoginSecure模式组网图

 

1.5.3  配置思路

·     配置交换机与用户端相连的端口安全模式为macAddressOrUserLoginSecure,即:对于非802.1X报文进行MAC地址认证,对于802.1X报文进行802.1X认证。

·     为实现通过端口安全的入侵检测功能限制认证端口出方向的报文转发。可配置NeedToKnow功能为ntkonly模式,即仅允许目的MAC地址为已通过认证的MAC地址的单播报文通过。

·     为认证用户添加认证域和RADIUS方案。

1.5.4  配置注意事项

参见1.4.4  配置注意事项

1.5.5  配置步骤

·     按照组网图配置设备各接口的IP地址,保证各主机、服务器和设备之间的路由可达。

·     如下服务器配置以H3C S5500-HI系列交换机作为RADIUS server为例,详细信息可参考相关产品手册。

 

1. Switch的配置

·     配置RADIUS特性

# 创建名为radsun的RADIUS方案,并配置主认证服务器IP和交互密钥。

<Switch> system-view

[Switch] radius scheme radsun

New Radius scheme

[Switch-radius-radsun] primary authentication 10.1.1.1 1645 key simple aabbcc

# 设置RADIUS服务器应答超时时间为5秒,RADIUS报文的超时重传次数的最大值为5。

[Switch-radius-radsun] timer response-timeout 5

[Switch-radius-radsun] retry 5

# 设置将去除域名的用户名发送给RADIUS服务器。

[Switch-radius-radsun] user-name-format without-domain

[Switch-radius-radsun] quit

# 创建名为sun的ISP域,并进入其视图。

[Switch] domain sun

# 指定名为radsun的RADIUS方案为该域lan-access用户的缺省RADIUS认证、授权方案。

[Switch-isp-sun] authentication lan-access radius-scheme radsun

[Switch-isp-sun] authorization lan-access radius-scheme radsun

[Switch-isp-sun] accounting lan-access none

[Switch-isp-sun] quit

·     配置端口安全相关特性

# 配置802.1X的认证方式为CHAP。(该配置可选,缺省情况下802.1X的认证方式为CHAP)

[Switch] dot1x authentication-method chap

# 配置MAC地址认证用户所使用的ISP域。

[Switch] mac-authentication domain sun

# 配置MAC认证的用户名为aaa,密码为123456。

[Switch] mac-authentication user-name-format fixed account aaa password simple 123456

# 设置端口允许的最大安全MAC地址数为64。

[Switch] interface ten-gigabitethernet 1/0/1

[Switch-Ten-GigabitEthernet1/0/1] port-security max-mac-count 64

# 设置端口安全模式为macAddressOrUserLoginSecure。

[Switch-Ten-GigabitEthernet1/0/1] port-security port-mode userlogin-secure-or-mac

# 设置端口NeedToKnow模式为ntkonly。

[Switch-Ten-GigabitEthernet1/0/1] port-security ntk-mode ntkonly

[Switch-Ten-GigabitEthernet1/0/1] quit

# 使能端口安全功能。

[Switch] port-security enable

2. RADIUS server的配置

# 创建RADIUS用户“aaa”并进入RADIUS服务器用户视图

<Sysname> system-view

[Sysname] radius-server user aaa

# 指定用户aaa的密码为明文123456。

[Sysname -rdsuser-aaa] password simple 123456

[Sysname -rdsuser-aaa] quit

# 配置RADIUS客户端IP为10.1.1.2,共享密钥为明文aabbcc。

[Sysname] radius-server client-ip 10.1.1.2 key simple aabbcc

1.5.6  验证配置

查看端口安全的配置信息:

<Switch> display port-security interface ten-gigabitethernet 1/0/1

 Port security is enabled globally

 AutoLearn aging time is 0 minutes

 Disableport Timeout: 20s

 OUI value:

 

 Ten-GigabitEthernet1/0/1 is link-up

   Port mode: macAddressOrUserLoginSecure

   NeedToKnow mode: NeedToKnowOnly

   Intrusion protection mode: NoAction

   Max number of secure MAC addresses: 64

   Current number of secure MAC addresses: 0

   Authorization is permitted

 

查看MAC地址认证情况:

<Switch> display mac-authentication interface ten-gigabitethernet 1/0/1

MAC authentication is enabled

 User name format is fixed account

 Fixed username:aaa

 Fixed password: ******

          Offline detect period is 300s

          Quiet period is 60s

          Server response timeout value is 100s

          Max number of users is 1024 per slot

          Current number of online users is 3

          Current authentication domain is sun

 

Silent MAC User info:

          MAC Addr         VLAN ID  From Port                    Port Index

 

Ten-GigabitEthernet1/0/1 is link-up

  MAC authentication is enabled

  Max number of online users is 256

  Current number of online users is 32

  Current authentication domain: Not configured

  Authentication attempts: successful 3, failed 1

          MAC Addr          Auth state

          1234-0300-0011   authenticated

          1234-0300-0012   authenticated

          1234-0300-0013   authenticated

 

查看802.1X认证情况:

<Switch> display dot1x interface ten-gigabitethernet 1/0/1

 802.1X protocol is enabled globally

 CHAP authentication is enabled

 Configuration: Transmit Period   30 s,  Handshake Period       15 s

                Quiet Period      60 s,  Quiet Timer is disabled

                Supp Timeout      30 s,  Server Timeout        100 s

                Reauth Period   3600 s

                Max attempts for sending an authentication request    2

 Max number of 802.1X users is 1024 per slot

 Current number of online 802.1X users is 1

Ten-GigabitEthernet1/0/1  is link-up

   802.1X protocol is enabled

   Handshake is enabled

   802.1X unicast-trigger is disabled

   Periodic reauthentication is disabled

   The port is an authenticator

   Authentication mode is Auto

   Port access control type is MAC-based

   802.1X multicast-trigger is enabled

   Mandatory authentication domain: Not configured 

   Max online users is 256

 

   EAPOL Packet: Tx 16331, Rx 102

   Sent EAP Request/Identity Packets : 16316

        EAP Request/Challenge Packets: 6

        EAP Success Packets: 4, Fail Packets: 5

   Received EAPOL Start Packets : 6

            EAPOL LogOff Packets: 2

            EAP Response/Identity Packets : 80

            EAP Response/Challenge Packets: 6

            Error Packets: 0

 1. Authenticated user : MAC address: 0002-0000-0011

 

   Controlled Users: 1

此外,因为设置了NeedToKnow特性,目的MAC地址未知、广播和多播报文都被丢弃。

1.5.7  配置文件

#

 port-security enable

#

 mac-authentication domain sun

 mac-authentication user-name-format fixed account aaa password cipher $c$3$6DXUG/ZZMl7AbkMpJEo2uoni19WCI0nJGw

#

radius scheme radsun

 primary authentication 10.1.1.1 1645 key cipher $c$3$krBjik3mdDkyVGW9JRInyID3GMYJOw==

 timer response-timeout 5

 user-name-format without-domain

 retry 5

#

domain sun

 authentication lan-access radius-scheme radsun

 authorization lan-access radius-scheme radsun

 accounting lan-access none

#

interface Ten-GigabitEthernet1/0/1

 port-security max-mac-count 64

 port-security port-mode userlogin-secure-or-mac

 port-security ntk-mode ntkonly

#

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们