学习目标:

认识华三h3c的两种ACL:basic acl 、 advanced acl
如何区分acl中的source ip或destination ip在接口下调用时inbound/outbound所指的方向。



学习内容:

本次实验的拓扑如下:

1、如上图所示在交换机SW1上配置basic acl控制R1或客户server 3访问内网ssh服务的接口地址或loop back地址。以便验证华三系列交换机如何配置basic acl并调用在接口下。

2、如上图所示在交换机SW1上配置basic acl控制R1或客户server 3访问内网ssh服务的接口地址或loop back地址。以便验证华三系列交换机如何配置advance acl并调用在接口下。



实验过程:

基本配置:

内网ssh服务:
#
interface GigabitEthernet0/0
 ip address 188.8.3.2 255.255.255.0
#
 ip route-static 188.8.190.64 32 188.8.3.1  #指向客户server3的静态路由
 ip route-static 188.40.190.64 32 188.8.3.1  #指向客户server1的静态路由

SW1:

interface GigabitEthernet1/0/5
 ip address 188.8.3.1 255.255.255.0
 packet-filter 2005 outbound
#
acl basic 2005
 rule 100 deny logging counting
#

R1:
 nat static inbound 2.2.2.2 188.8.190.64  #客户server3的nat地址
 nat static inbound 8.8.8.8 188.40.190.64  #客户server1的nat地址

1、inbound/outbound的区别

根据上面的基础配置,在直连ssh内网服务的接口调用acl 2005 outbound,此时拒绝所有流量。当从ssh内网发起流量(反之亦然,从客户server 3发起流量现象一致)设备log提示:

从ssh内网188.8.3.2访问188.8.190.64:

<SW1>%Dec 15 22:17:38:838 2021 SW1 FILTER/6/FILTER_EXECUTION_ICMP: RcvIfName(1023)=GigabitEthernet1/0/5;Direction(1070)=outbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=ICMP;SrcIPAddr(1003)=188.8.190.64;DstIPAddr(1007)=188.8.3.2;IcmpType(1062)=ECHOREPLY(0);IcmpCode(1063)=0;MatchAclCount(1069)=1;Event(1048)=Deny;

反之,从客户server3访问188.8.3.2:

%Dec 15 22:17:54:168 2021 SW1 FILTER/6/FILTER_EXECUTION_ICMP: RcvIfName(1023)=GigabitEthernet1/0/5;Direction(1070)=outbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=ICMP;SrcIPAddr(1003)=188.8.190.64;DstIPAddr(1007)=188.8.3.2;IcmpType(1062)=ECHO(8);IcmpCode(1063)=0;MatchAclCount(1069)=1;Event(1048)=Deny;

根据上面的基础配置,在直连ssh内网服务的接口调用acl 2005 intbound,此时拒绝所有流量。当从ssh内网发起流量(反之亦然,从客户server 3发起流量现象一致)设备log提示:

从内网ssh访问客户server3
从客户server3访问内网ssh,两次的acl log日志相同:

[SW1]%Dec 15 22:23:41:587 2021 SW1 FILTER/6/FILTER_IPV4_EXECUTION: RcvIfName(1023)=GigabitEthernet1/0/5;Direction(1070)=inbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=TCP;SrcIPAddr(1003)=188.8.3.2;SrcPort(1004)=22;DstIPAddr(1007)=188.8.190.64;DstPort(1008)=29184;MatchAclCount(1069)=1;Event(1048)=Deny;

从客户server3访问内网ssh,两次的acl log日志相同:
%Dec 15 22:24:03:103 2021 SW1 FILTER/6/FILTER_IPV4_EXECUTION: RcvIfName(1023)=GigabitEthernet1/0/5;Direction(1070)=inbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=TCP;SrcIPAddr(1003)=188.8.3.2;SrcPort(1004)=17792;DstIPAddr(1007)=188.8.190.64;DstPort(1008)=22;MatchAclCount(1069)=1;Event(1048)=Deny;

综上:可知当acl部署在物理接口上时,源地址和目的地址的方向取决于接口的的配置inbound/outbound,且inbound指流量进入接口去往目的地址的方向,反之,outbound为流量流出物理接口去往目的地址的方向。(与我们日常所理解的in/out方向相同)

由此我们可以观察到放行流量的策略部署如下:

SW1
inbound部署策略:
interface GigabitEthernet1/0/5
 port link-mode route
 combo enable fiber
 ip address 188.8.3.1 255.255.255.0
 packet-filter 2005 inbound
#
acl basic 2005
 rule 5 permit source 188.8.3.2 0
 rule 100 deny logging counting
#
outbound部署策略:
interface GigabitEthernet1/0/5
 port link-mode route
 combo enable fiber
 ip address 188.8.3.1 255.255.255.0
 packet-filter 2005 outbound
#
acl basic 2005
 rule 5 permit source 188.8.190.64 0
 rule 100 deny logging counting
#

interface vlan 接口下的inbound/outbound:

基础配置同上,将物理接口修改为interface vlan 

SW1:
interface Vlan-interface5
 ip address 188.8.3.1 255.255.255.0
 packet-filter 2005 outbound
#
interface GigabitEthernet1/0/5
 port link-mode bridge
 port access vlan 5
 combo enable fiber
 stp edged-port
#
acl basic 2005
 rule 100 deny logging counting

    分别从ssh内网服务,以及客户server3发起ping:

从内网ssh服务发起流量:
[SW1]%Apr 22 15:30:50:467 2022 SW1 FILTER/6/FILTER_EXECUTION_ICMP: RcvIfName(1023)=Vlan-interface5;Direction(1070)=outbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=ICMP;SrcIPAddr(1003)=188.8.190.64;DstIPAddr(1007)=188.8.3.2;IcmpType(1062)=ECHOREPLY(0);IcmpCode(1063)=0;MatchAclCount(1069)=1;Event(1048)=Deny;
从客户server3发起:
[SW1]%Apr 22 15:30:58:598 2022 SW1 FILTER/6/FILTER_EXECUTION_ICMP: RcvIfName(1023)=Vlan-interface5;Direction(1070)=outbound;AclType(1067)=ACL;Acl(1068)=2005;Protocol(1001)=ICMP;SrcIPAddr(1003)=188.8.190.64;DstIPAddr(1007)=188.8.3.2;IcmpType(1062)=ECHO(8);IcmpCode(1063)=0;MatchAclCount(1069)=1;Event(1048)=Deny;

综上:可知当acl部署在interface vlan 时,源地址和目的地址的方向取决于interface的的配置inbound/outbound,但是和物理接口的in/out方向相反。inbound为流量出接口去往源地址的方向,反之,outbound为流量流入interface vlan接口去往源地址的方向。(与我们日常所理解的acl的in/out方向相反),这里也可以将interface vlan接口看作桥梁,以源地址(发起流量)为参照物,从参照物进入接口的流量视作interface vlan的inbound,桥梁进入参照物的流量视作interface vlan的outbound:

结论:

在华三设备上部署acl限制流量,在物理接口和interface vlan 接口下源地址和目的地址的inbound,outbound方向相反。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐