取消
显示结果 
搜索替代 
您的意思是: 
cancel
4983
查看次数
30
有帮助
4
回复

WS-C2960-48TC-L MAC acl 不生效

huangmingchao
Level 1
Level 1
mac access-list extended WhiteListMac
deny any any
permit host 2857.beb9.620b any
permit host 2857.be17.10be any
permit host 2857.be17.10ef any
permit host 2857.be26.443c any
permit host 2857.be8e.e8c1 any
permit host e04f.4307.45a4 any
permit host e04f.4307.23cc any
我一开始deny写在最后,现在写在最上,里面的defult 也是deny any any
interface FastEthernet0/7
description
switchport access vlan 5
switchport mode access
switchport block multicast
switchport block unicast
mac access-group WhiteListMac in
no cdp enable
spanning-tree portfast
端口应用上之后除了permit的mac地址还是能送进来转发出去
Total Mac Addresses for this criterion: 139
show mac ad int fa 0/7
怎么才能让mac acl生效?
1 个已接受解答

已接受的解答

cruiseluo
Spotlight
Spotlight
由于mac acl的工作机制所以端口会学到mac地址
如果要使用port-security,请看以下示例配置
!
interface FastEthernet0/5
switchport access vlan 5
switchport mode access
switchport port-security
switchport port-security violation restrict
switchport port-security mac-address sticky
switchport port-security mac-address sticky bcee.7b87.0541
spanning-tree portfast
# Violation Mode 有4种,分别是protect、restrict、shutdown、shutdown vlan, 默认Violation Mode 是 shutdown
如果设置成shutdown模式,那么可能导致端口down掉,需要手动对该端口执行 shutdown 和 no shutdown,所以violation模式
最好设置成restrict模式。
# port-security mac-address 最好设置成sticky模式,这样端口可以自动学习到mac地址并且学到的地址是static模式,学到后在
running-config中自动添加一行"switchport port-security mac-address sticky bcee.7b87.0541",保存配置后,对交换机重新加电
配置仍然生效
# 如果要清除 sticky 到的mac地址 bcee.7b87.0541,那么把对应 bcee.7b87.0541 的电脑从交换机上网线拔掉
然后执行命令"clear port-security sticky address bcee.7b87.0541",再执行命令"sh mac-address-table | in bcee.7b87.0541"
就会发现 mac-address 中已经没有了 bcee.7b87.0541 ,而且 interface FastEthernet0/5 中也没有了 switchport port-security mac-address sticky bcee.7b87.0541
这一行。如果你要 sticky 另一台电脑的mac地址,那么直接把另一台电脑插到对应端口,然后执行"clear port-security sticky address bcee.7b87.0541"即可。

在原帖中查看解决方案

4 条回复4

cruiseluo
Spotlight
Spotlight
由于mac acl的工作机制所以端口会学到mac地址
如果要使用port-security,请看以下示例配置
!
interface FastEthernet0/5
switchport access vlan 5
switchport mode access
switchport port-security
switchport port-security violation restrict
switchport port-security mac-address sticky
switchport port-security mac-address sticky bcee.7b87.0541
spanning-tree portfast
# Violation Mode 有4种,分别是protect、restrict、shutdown、shutdown vlan, 默认Violation Mode 是 shutdown
如果设置成shutdown模式,那么可能导致端口down掉,需要手动对该端口执行 shutdown 和 no shutdown,所以violation模式
最好设置成restrict模式。
# port-security mac-address 最好设置成sticky模式,这样端口可以自动学习到mac地址并且学到的地址是static模式,学到后在
running-config中自动添加一行"switchport port-security mac-address sticky bcee.7b87.0541",保存配置后,对交换机重新加电
配置仍然生效
# 如果要清除 sticky 到的mac地址 bcee.7b87.0541,那么把对应 bcee.7b87.0541 的电脑从交换机上网线拔掉
然后执行命令"clear port-security sticky address bcee.7b87.0541",再执行命令"sh mac-address-table | in bcee.7b87.0541"
就会发现 mac-address 中已经没有了 bcee.7b87.0541 ,而且 interface FastEthernet0/5 中也没有了 switchport port-security mac-address sticky bcee.7b87.0541
这一行。如果你要 sticky 另一台电脑的mac地址,那么直接把另一台电脑插到对应端口,然后执行"clear port-security sticky address bcee.7b87.0541"即可。

huangmingchao
Level 1
Level 1
我试了port-security好使,但是鉴于每次都要把端口关闭方式mac学到来更改设置,我还是倾向mac acl,有没有好使灵活的办法?

cruiseluo
Spotlight
Spotlight
我在2960的实验如下:
192.168.1.1 14dd-a927-4cb1
192.168.1.2 70ba-ef78-78c8
192.168.1.3 0cda-415e-b056
192.168.1.4 3822-d6b3-2c06
192.168.1.5 0cda-415e-a256
192.168.1.6 0cda-414a-afda
192.168.1.7 001d-090b-e3c6
192.168.1.100 001e.bdc3.2cc3
2960初始配置:
!
mac access-list extended mac-test
deny host 14dd.a927.4cb1 host 001e.bdc3.2cc3
deny host 70ba.ef78.78c8 host 001e.bdc3.2cc3
deny host 0cda.415e.b056 host 001e.bdc3.2cc3
permit any any
!
interface FastEthernet0/23
switchport mode access
mac access-group mac-chun in
#配置完后192.168.1.1、192.168.1.2、192.168.1.3不能ping通192.168.1.100,192.168.1.4、192.168.1.5、192.168.1.6、192.168.1.7能ping通192.168.1.100
修改mac-test后的配置
!
mac access-list extended mac-test
deny host 14dd.a927.4cb1 host 001e.bdc3.2cc3
deny host 70ba.ef78.78c8 host 001e.bdc3.2cc3
deny host 0cda.415e.b056 host 001e.bdc3.2cc3
deny host 3822.d6b3.2c06 host 001e.bdc3.2cc3
deny host 0cda.415e.a256 host 001e.bdc3.2cc3
deny host 0cda.414a.afda host 001e.bdc3.2cc3
deny host 001d.090b.e3c6 host 001e.bdc3.2cc3
permit any any
#配置完后仍然是192.168.1.1、192.168.1.2、192.168.1.3不能ping通192.168.1.100,192.168.1.4、192.168.1.5、192.168.1.6、192.168.1.7能ping通192.168.1.100
也就是说后面4个deny语句并没有实际生效,把"mac access-list extended mac-test"删除,重新配成"mac access-list extended mac-new"
里面的所有语句都和"mac access-list extended mac-test"一样,在"interface FastEthernet0/23"里重新应用。发现后面4个deny语句仍然没有生效
保存配置后重启交换机后所有语句立即生效。如果不把"mac access-list extended mac-test"换成"mac access-list extended mac-new",重启交换机后所有语句也是立即生效

huangmingchao
Level 1
Level 1
cruiseluo 发表于 2017-8-9 12:51
我在2960的实验如下:
192.168.1.1 14dd-a927-4cb1

mac acl使用后 三层确实无法通信,但是二层的mac地址还是能雪道,DHCP包也能发过来,获取到ip后无法ping通对方网关,mac地址也从交换机转发到核心交换机处了,我现在用的方法是port-security。
现在的问题是没有不允许的mac地址通过,但如果需要增加或删除security内容就需要,关闭端口,清空动态mac,操作后再打开端口,影响业务,没办法在白天操作。
入门指南

使用上面的搜索栏输入关键字、短语或问题,搜索问题的答案。

我们希望您在这里的旅程尽可能顺利,因此这里有一些链接可以帮助您快速熟悉思科社区:









快捷链接