版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tladagio/article/details/85260755
一、组网需求
1、要求接入交换机端口限制MAC地址学习数量,超过设置数量就会触发入侵检测,然后执行入侵检测的安全动作。
2、要求接入交换机的端口不接受非信任的DHCP服务器下发的IP。
二、配置MAC
1、端口最多只能接入一台设备,如果超过两个MAC自动关闭端口,需要手动删除学习记录并开启端口
[SW36]display version
H3C S3110-26TP-SI
[SW36]port-security enable
[SW36]interface Ethernet 1/0/1
[SW36-Ethernet1/0/1]port-security max-mac-count 1
[SW36-Ethernet1/0/1]port-security port-mode autolearn
[SW36-Ethernet1/0/1]port-security intrusion-mode disableport
[SW36-Ethernet1/0/1]quit
说明:
操作 | 命令 | 说明 |
使能端口安全功能 | port-security enable | 缺省情况下,端口安全功能处于关闭状态 |
配置端口安全允许的最大MAC地址数 | port-security max-mac-count count-value | 缺省情况下,最大MAC地址数不受限制 |
配置入侵检测特性 | port-security intrusion-mode { blockmac | disableport | disableport-temporarily } | 缺省情况下,不进行入侵检测处理 |
控制autoLearn模式下端口能够添加的最大安全MAC地址数
入侵检测特性:
当设备检测到一个非法的用户通过端口试图访问网络时,该特性用于配置设备可能对其采取的安全措施,包括以下三种方式:
blockmac:表示将非法报文的源MAC地址加入阻塞MAC地址列表中,源MAC地址为阻塞MAC地址的报文将被丢弃。此MAC地址在被阻塞3分钟(系统默认,不可配)后恢复正常。
disableport:表示将收到非法报文的端口永久关闭。
disableport-temporarily:表示将收到非法报文的端口暂时关闭一段时间。关闭时长可通过port-security timer disableport命令配置。
2、查看确认,会看到端口记录一条MAC与端口绑定信息
[SW36-Ethernet1/0/1]dis this
#
interface Ethernet1/0/1
port access vlan 3
port-security max-mac-count 1
port-security port-mode autolearn
port-security intrusion-mode disableport
port-security mac-address security sticky 9829-a60a-76df vlan 3
3、接入新设备触发入侵检测,端口down
[SW36]display logbuffer
SW36 PORTSEC/5/PORTSEC_VIOLATION: -IfName=Ethernet1/0/1-MACAddr=98:29:A6:0A:76:FD-VlanId=-3-IfStatus=Down; Intrusion detected.
[SW36]display interface brief down
The brief information of interface(s) under bridge mode:
Link: ADM - administratively down; Stby - standby
Interface Link Cause
Eth1/0/1 DOWN Port Security Disabled
Eth1/0/2 DOWN Not connected
三、配置DHCP Snooping
1、开启dhcp-snooping
[SW36]dhcp-snooping
[SW36-GigabitEthernet1/0/25]dhcp-snooping trust
说明:
操作 | 命令 | 说明 |
使能DHCP Snooping功能 | dhcp-snooping | 缺省情况下,DHCP Snooping功能处于关闭状态 |
配置端口为信任端口,并记录客户端IP地址和MAC地址的绑定关系 | dhcp-snooping trust | 缺省情况下,在使能DHCP Snooping功能后,设备的所有端口均为不信任端口 |
2、查看
[SW36]display dhcp-snooping
DHCP Snooping is enabled.
The client binding table for all untrusted ports.
Type : D--Dynamic , S--Static , R--Recovering
Type IP Address MAC Address Lease VLAN SVLAN Interface
==== =============== ============== ============ ==== ===== =================
D 192.168.3.69 9829-a60a-76df 171725 3 N/A Eth1/0/1