更新时间:2025-05-23
注意:XS3000万兆交换机仅XSW3.1.0版本支持802.x认证,且仅支持对接思科。对接思科配置示例如下:
【组网需求】
如图所示,管理员希望PC1和PC2通过认证后允许访问Internet,认证失败仅允许访问Update Server。
【组网图】

【配置思路】
1、在SW上开启802.1X接入控制,认证方式选择radius。
2、端口配置基于mac认证,配置guest-vlan为4,为认证失败访问的资源。
【操作步骤】
#SW设备上创建vlan2-5。
Switch#configure terminal
Switch(config)#vlan 2-5
#配置e0/0/1为hybrid端口,pvid为2,并且允许vlan3-5的报文通过。
Switch(config-vlan-range)#interface ethernet 0/0/1
Switch(config-if-ethernet-0/0/1)#switchport link-type hybrid
Switch(config-if-ethernet-0/0/1)#switchport pvid 2
Switch(config-if-ethernet-0/0/1)#switchport hybrid untagged vlan 3-5
#配置e0/0/3-e0/0/5为access端口,分别允许vlan3-5通过。
Switch(config-if-ethernet-0/0/1)#interface eth 0/0/3
Switch(config-if-ethernet-0/0/3)#switchport link-type access
Switch(config-if-ethernet-0/0/3)#switchport pvid 3
Switch(config-if-ethernet-0/0/3)#interface ethernet 0/0/4
Switch(config-if-ethernet-0/0/4)#switchport link-type access
Switch(config-if-ethernet-0/0/4)#switchport pvid 4
Switch(config-if-ethernet-0/0/4)#interface ethernet 0/0/5
Switch(config-if-ethernet-0/0/5)#switchport link-type access
Switch(config-if-ethernet-0/0/5)#switchport pvid 5
#配置vlan5的ip地址为100.100.100.88。
Switch(config)#interface vlan-interface 5
Switch(config-if-vlanInterface-5)#ip address 100.100.100.88 255.255.255.0
#配置radius服务器test,服务器的地址为100.100.100.249秘钥为123456,配置用户认证时不带域名,并配置源地址为vlan5的接口地址
Switch(config)#aaa
Switch(config-aaa)#radius host test
Switch(config-aaa-radius-test)#primary-auth-ip 100.100.100.249 1812
Switch(config-aaa-radius-test)#auth-secret-key 123456
Switch(config-aaa-radius-test)#username-format without-domain
Switch(config-aaa-radius-test)#nas-ipaddress 100.100.100.88
#配置域test,绑定radius服务器test,配置默认引用域为test
Switch(config-aaa-radius-test)#domain test
Switch(config-aaa-domain-test)#radius host binding test
Switch(config-aaa-domain-test)#state active
Switch(config-aaa-domain-test)#ex
Switch(config-aaa)#default domain-name enable test
#配置开启radius vlan并配置格式为2decimal
Switch(config-aaa)#radius vlan enable
Switch(config-aaa)#radius vlan-format string2decimal
#配置全局开启802.1x,配置端口1的认证基于mac,配置guest-vlan为4
Switch(config)#dot1x enable
Switch(config)#interface ethernet 0/0/1
Switch(config-if-ethernet-0/0/1)#dot1x port-method macbased
Switch(config-if-ethernet-0/0/1)#dot1x guest-vlan 4
#PC1发起认证,输入错误的用户名或密码后认证失败后,PC1用户在guest-vlan 4中,可以访问Update Server
Switch#show dot1x user
No 1 mac : 00:00:00:11:11:11
username : xinertel@test status: guest-online
port : e0/0/1 vlan : 4
acl : N/A
login time: 04:46:13 1970/01/02
Total online [1]. (guest online [1], critical online [0])
#PC2发起认证成功后,PC2用户在radius vlan3中,可以访问Internet。
Switch(config)#show dot1x user
No 1 mac : 00:00:00:11:11:11
username : test@test status: online
port : e0/0/1 vlan : 3
acl : N/A
login time: 05:16:28 1970/01/02
Total online [1]. (guest online [0], critical online [0])