24 配置基本ACL 实现包过滤 通过配置基本ACL拒绝PC1192.168.10.100访问PC2 192.168.20.100R1 基本配置 <H3C>system-view [H3C]sysname r1 [r1]interface gigabitethernet 0/2 [r1-GigabitEthernet0/2]ip address 192.168.10.1 24 [r1-GigabitEthernet0/2]interface gigabitethernet 0/0 [r1-GigabitEthernet0/0]ip address 10.10.12.1 24 [r1-GigabitEthernet0/0]quit 配置默认路由 [r1]ip route-static 192.168.20.0 255.255.255.010.10.12.2 //配置默认路由 配置基本ACL [r1]acl number 2000 //创建基本ACL [r1-acl-ipv4-basic-2000]step 10 //配置步长为10 [r1-acl-ipv4-basic-2000]rule deny source192.168.10.100 0.0.0.0 //配置拒绝源地址通行规则 [r1-acl-ipv4-basic-2000]rule permit source any //配置允许源地址访问规则 [r1-acl-ipv4-basic-2000]quit 配置接口引用ACL [r1]interfacegigabitethernet 0/0 [r1-GigabitEthernet0/0]packet-filter 2000 outbound //配置接口的出方向访问引用ACL规则包过滤 R2 <H3C>system-view [H3C]sysname r2 [r2]interface gigabitethernet 0/2 [r2-GigabitEthernet0/2]ip address 192.168.20.1 24 [r2-GigabitEthernet0/2]interface gigabitethernet 0/0 [r2-GigabitEthernet0/0]ip address 10.10.12.2 24 [r2-GigabitEthernet0/0]quit [r2]ip route-static 192.168.10.0 255.255.255.010.10.12.1 此时当PC1地址为192.168.10.100时,无法访问对面PC2 192.168.20.100;数据在R1 的G 0/0出接口时被ACL2000过滤。把PC1的时址改成101时则能正常访问了。 反之,在R1的G 0/0接口inbound方向也可进行配置,例如禁止R2 192.168.20.100的PC访问本路由下的PC1。 [r1]acl number 2001 [r1-acl-ipv4-basic-2001]step 20 [r1-acl-ipv4-basic-2001]rule 0 deny source192.168.20.100 0.0.0.0 [r1-acl-ipv4-basic-2001]rule 10 permit source any [r1-acl-ipv4-basic-2001]quit [r1]interface gigabitethernet 0/0 [r1-GigabitEthernet0/0]packet-filter 2001 inbound [r1-GigabitEthernet0/0]quit 完成! |