此任务中的示例显示了如何阻止 IP 地址为 12.0.0.100 的主机发来的 IP 通信。有关此任务的拓扑,请参见Basic SEFOS Topology。
过滤器类型可以是扩展类型或标准类型。标准过滤器可根据源 IP 地址和目标 IP 地址过滤通信。扩展过滤器还可指定协议 ID、TCP/UDP 端口号、DSCP 值和流标签。在此示例中,将过滤掉源地址为 12.0.0.100 的 IP 数据包。
ACL 过滤器可根据交换机中配置或编程的某些过滤条件来过滤硬件上的数据包。交换机将根据所配置的访问列表检查每个数据包,从而确定是阻止还是转发数据包。在 SEFOS-1 交换机上键入以下命令。
请参见Connect to SEFOS。
SEFOS-1# configure terminal SEFOS-1(config)# interface vlan 1 SEFOS-1(config-if)# shutdown SEFOS-1(config-if)# ip address 12.0.0.1 255.0.0.0 SEFOS-1(config-if)# no shutdown SEFOS-1(config-if)# exit SEFOS-1(config)# interface xl-ethernet 0/25 SEFOS-1(config-if)# no shutdown SEFOS-1(config-if)# exit SEFOS-1(config)# interface xl-ethernet 0/26 SEFOS-1(config-if)# no shutdown SEFOS-1(config-if)# exit
SEFOS-1(config)# ip access-list extended 11
SEFOS-1(config-ext-nacl)# deny ip host 12.0.0.100 any SEFOS-1(config-ext-nacl)# end
# ping 12.0.0.17 12.0.0.17 is alive
SEFOS-1(config)# interface xl-ethernet 0/25 SEFOS-1(config-if)# ip access-group 11 in SEFOS-1(config-if)# exit SEFOS-1(config)# vlan 1 SEFOS-1(config-vlan)# ports xl-ethernet 0/25 xl-ethernet 0/26 untagged xl-ethernet 0/25 xl-ethernet 0/26
% Member Ports cannot be added/deleted on Default VLAN SEFOS-1(config-vlan)# end
SEFOS-1# show access-lists ... IP address Type : IPV4 ... In Port List : X10/25 ... Filter Action : Deny Status : Active
从主机 A 发送的数据包不会转发给端口 26,因为过滤器操作已设置为 deny。从主机 A 对 12.0.0.17 执行 ping 失败,12.0.0.17 没有应答。
SEFOS-1# configure terminal SEFOS-1(config)# interface xl-ethernet 0/25 SEFOS-1(config-if)# no ip access-group 11 in SEFOS-1(config-if)# end SEFOS-1# show access-lists ... Status : InActive
执行 ping 会从主机 B 收到应答。从主机 A 发送的数据包将转发给端口 26。以下两个连续的 ping 命令显示:ACL 列表中设置的 deny 过滤器操作应用于一个端口,另一个端口移除了该操作。
# ping 12.0.0.17 no answer from 12.0.0.17 # ping 12.0.0.17 12.0.0.17 is alive