802.1X协议是一种基于端口的网络接入控制协议(Port-Based Network Access Control Protocol),“基于端口的网络接入控制”是指在局域网接入设备的端口这一级对所接入的用户设备进行认证和控制。连接在端口上的用户设备如果能通过认证,就可以访问网络中的资源;如果不能通过认证,则无法访问网络中的资源。
802.1X协议体系结构
802.1X系统为典型的Client/Sever结构
包括三个实体:客户端(Client)、认证设备(Device)和认证服务器(server)
802.1X和PPPOE认证、Web认证的对比
802.1X | PPPOE | WEB认证 | |
---|---|---|---|
是否需要配置客户端软件 | 是(Windows系统带有客户端) | 是(Windows系统带有客户端) | 否 |
业务报文效率 | 高 | 低,有封装开销 | 高 |
组播支持能力 | 好 | 低,对设备要求高 | 好 |
有线网上的安装性 | 扩展后可用 | 可用 | 可用 |
设备端的要求 | 低 | 高 | 较高 |
增值应用支持 | 简单 | 复杂 | 复杂 |
802.1X适用于运营管理相对简单、业务复杂度较低的企业以及园区,802.1X是理想的低成本运营解决方案。
第一步:开启全局的802.1X
[H3C]dot1x
第二步:开启端口的802.1X特性
[H3C-GigabitEthernet1/0/1]dot1x
第三步:设置802.1X用户认证方法
[H3C]dot1x authentication-method [ chap | eap | pap]
缺省情况下,802.1X用户认证方法为CHAP认证,用户可以根据需要设置其认证方法。
第四步:设置端口接入控制方式
[H3C-GigabitEthernet1/0/1]dot1x port-method { macbased | portbased} [interface interface-list]
802.1X的定时器配置
[H3C]dot1x timer [
ead-timeout Set the EAD quick deployment timeout timer #EAD超时定时器默认30秒
handshake-period Set the handshake timer #握手定时器默认15秒
quiet-period Set the quiet timer #静默定时器默认60秒
reauth-period Set the online user re-authentication timer #周期性重认证定时器3600秒
server-timeout Set the authentication server timeout timer #认证服务器超时定时器默认100秒
supp-timeout Set the supplicant timeout timer #客户端认证超时定时器
tx-period Set the identity request timeout timer #用户名请求超时定时器默认30秒
]
开启静默定时器功能
[H3C]dot1x quiet-period
开启在线用户握手功能
[H3C-GigabitEthernet1/0/1]dot1x handshake
在以太网端口视图下配置Guest VLAN
[H3C-GigabitEthernet1/0/1]dot1x guest-vlan [vlan-id]
通过远程服务器下发数字型VLAN时,设备不需要创建VLAN
通过远程服务器下发字符型VLAN时,设备上需要创建所下发的VLAN,并配置VLAN的name
[H3C]vlan 10
[H3C-vlan10]name [name]
若采用本地用户进行认证,下发VLAN需要配置如下属性
[H3C]local-user [user]
[H3C-luser-manage-zx]authorization-attribute vlan [vlan-id]
一台主机Host通过802.1X认证接入网络,认证服务器为RADIUS服务器,Host接入交换机G1/0/1在VLAN1内,认证前后分别下发Guest VLAN20和动态vlan10。
----------配置RADIUS方案h3c---------
[H3C]radius scheme h3c
[H3C-radius-h3c] primary authentication 82.0.0.3 1812
[H3C-radius-h3c] primary accounting 82.0.0.3 1813
[H3C-radius-h3c] key authentication cipher h3c
[H3C-radius-h3c] key accounting cipher h3c
----------配置认证域h3c,该域使用已配置的RADIUS方案h3c---------
[H3C]domain name h3c
[H3C-isp-h3c]authentication default radius-scheme h3c
[H3C-isp-h3c]authorization default radius-scheme h3c
[H3C-isp-h3c]accounting default radius-scheme h3c
----------开启全局802.1X特性----------
[H3C]dot1x
----------开启指定端口的802.1X特性----------
[H3C]int G1/0/1
[H3C-GigabitEthernet1/0/1]dot1x
----------配置端口上进行接入控制的方式为portbased----------
[H3C-GigabitEthernet1/0/1]dot1x port-method portbased
----------创建指定端口的Guest VLAN-----------
[H3C]vlan 20
[H3C]int G1/0/1
[H3C-GigabitEthernet1/0/1]dot1x guest-vlan 20
显示802.1X的会话连接信息、相关统计信息或配置信息
[H3C]dis dot1x [ sessions | statistics] [接口]
清除802.1X的统计信息
reset dot1x statistics [接口]
显示802.1X认证用户的连接信息
dis dot1x connection [ interface interface-list | slot slot-number | user-mac H-H-H | user-name user-name]
第一步:启动全局的MAC地址认证
[H3C]mac-authentication
第二步:启动端口的MAC地址认证
[H3C]int G1/0/2
[H3C-GigabitEthernet1/0/2]mac-authentication
第三步:配置MAC地址认证的用户名与密码
[H3C]mac-authentication user-name-format
fixed [ account name ] [ password{cipher|simple} password]
mac-address [{with-hyphen | without-hyphen} [lowercase | uppercase]]
第四步:配置MAC认证用户使用的认证域
[H3C]mac-authentication domain [domain-name]
用户主机Host通过端口G1/0/1连接到设备上,设备通过RADIUS服务器对用户进行认证、授权、计费,在各个端口上对用户接入进行MAC地址认证,以控制其对Internet的访问。
组网需求:
----------配置RADIUS方案h3c----------
[H3C]radius scheme h3c
[H3C-radius-h3c]primary authentication 10.1.1.1 1812
[H3C-radius-h3c]primary accounting 10.1.1.2 1813
[H3C-radius-h3c]key authentication simple h3c
[H3C-radius-h3c]key accounting simple h3c
[H3C-radius-h3c]user-name-format without-domain
----------配置ISP域的AAA方案----------
[H3C]domain name h3c
[H3C-isp-h3c]authentication default radius-scheme h3c
[H3C-isp-h3c]authorization default radius-scheme h3c
[H3C-isp-h3c]accounting default radius-scheme h3c
---------开启全局MAC地址认证特性---------
[H3C]mac-authentication
---------开启指定端口的MAC地址认证特性---------
[H3C]int G1/0/1
[H3C-GigabitEthernet1/0/1]mac-authentication
---------配置MAC地址认证用户所使用的ISP域---------
[H3C]mac-authentication domain h3c
---------配置MAC地址认证的定时器----------
[H3C]mac-authentication timer offline-detect 180
[H3C]mac-authentication timer quiet 180
----------配置MAC地址认证使用固定用户名格式:用户名为aaa,密码为123456----------
[H3C]mac-authentication user-name-format fixed account aaa password simple 123456
----------display mac-authentication 或 dis mac-authentication connection 验证配置---------
第一步:使能端口安全功能,在使能端口安全功能之前,需要关闭全局的802.1X和MAC地址认证功能。
[H3C]port-security enable
第二步:配置端口允许最大安全的MAC地址数,端口安全允许某个端口下有多个用户通过认证,但是允许的用户数不能超过规定的最大值。
[H3C-GigabitEthernet1/0/1]port-security max-mac-count [count-value]
第三步:配置端口安全模式,在配置端口安全模式之前,需要满足以下条件:
[H3C-GigabitEthernet1/0/1]port-security port-mode
autolearn
mac-authentication
mac-else-userlogin-secure
mac-else-userlogin-secure-ext
secure
userlogin
userlogin-secure
userlogin-secure-ext
userlogin-secure-or-mac
userlogin-secure-or-mac-ext
userlogin-withoui
第四步:配置端口NeedToKonw特性,该功能用来限制认证端口上出方向的报文转发。
即认证通过后,以此MAC为目的地址的报文都可以正常转发,可以设置以下三种方式:
除缺省情况之外,配置了NeedToKonw的端口在以上任何一种方式下都不允许未知MAC地址的单播报文通过。
[H3C-GigabitEthernet1/0/1]port-security ntk-mode
ntk-withbroadcasts
ntk-withmulticasts
ntkonly
第五步:配置入侵检测特性,当设备检测到一个非法的用户通过端口视图访问网络时,该特性用于配置设备可能对其采取的安全措施,包括以下三种方式:
[H3C-GigabitEthernet1/0/1]port-security intrusion-mode
blockmac #表示将非法报文的源MAC地址加入阻塞MAC地址列表
disableport #表示将收到非法报文的端口永久关闭
disableport-temporarily #表示将收到非法报文的端口暂时关闭一段时间。关闭时长通过 port-security timer disableport
在交换机的端口G1/0/1上对接入用户做如下的限制,允许64个用户自由接入,不进行认证,将学习到的用户MAC地址添加为安全MAC地址;当安全MAC地址数量达到64后,停止学习;当再有新的MAC地址接入时,触发入侵检测,并将此MAC阻塞。
组网需求:
[H3C]port-security enable #系统模式下打开端口安全
[H3C]int G1/0/1
[H3C-GigabitEthernet1/0/1]port-security max-mac-count 64 #设置端口允许的最大安全MAC地址数为64
[H3C-GigabitEthernet1/0/1]port-security port-mode autolearn #设置端口安全模式为autolearn
[H3C-GigabitEthernet1/0/1]port-security intrusion-mode blockmac #触发入侵检测特性后保护动作为blockmac
[H3C]display port-security interface G1/0/1 #显示端口安全配置情况
--------------无法配置端口安全模式-------------
[H3C-GigabitEthernet1/0/1]port-security port-mode autolearn
---------------报错Error---------------change it to the other
因为当前端口安全模式下已配置的情况下,无法直接对端口安全模式进行设置,
首先需要设置端口安全模式为noRestricitions状态。然后再配置端口安全模式。
[H3C-GigabitEthernet1/0/1]undo port-security port-mode
[H3C-GigabitEthernet1/0/1]port-security port-mode autolearn
--------------无法配置端口安全MAC地址时--------------
[H3C-GigabitEthernet1/0/1]port-security mac-address security 1-2-2 vlan 1
--------------报错Error------------------
因为端口安全模式为非autoLearn时,不能对安全MAC地址进行设置
首先需要设置端口安全模式为autoLearn状态,然后再配置端口安全MAC地址。
[H3C-GigabitEthernet1/0/1]undo port-security port-mode
[H3C-GigabitEthernet1/0/1]port-security max-mac-count 64
[H3C-GigabitEthernet1/0/1]port-security port-mode autolearn
[H3C-GigabitEthernet1/0/1]port-security mac-address security 1-1-2 vlan 1