ACL 实验
ACL 实验
实验拓扑

实验需求
- 按照图示配置 IP 地址
- 全网路由互通
- 在 SERVER1 上配置开启 TELNET 和 FTP 服务
- 配置 ACL 实现如下效果
192.168.1.0/24网段不允许访问192.168.2.0/24网段,要求使用基本 ACL 实现- PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务
- PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务
192.168.2.0/24网段不允许访问 SERVER1,要求通过高级 ACL 实现
实验解法
1.配置 IP 地址/静态路由
# PC1的配置如下:int g0/0ip add 192.168.1.1 24ip route-static 0.0.0.0 0 192.168.1.254
# PC2的配置如下:int g0/0ip add 192.168.1.2 24ip route-static 0.0.0.0 0 192.168.1.254
# R1的配置如下:int g0/0ip add 100.1.1.1 24int g0/1ip add 192.168.1.254 24ip route-static 0.0.0.0 0 100.1.1.2
# R2的配置如下:int g0/0ip add 100.1.1.2 24int g0/1ip add 100.2.2.2 24int g0/2ip add 192.168.2.2 24ip route-static 192.168.1.0 24 100.1.1.1ip route-static 192.168.3.0 24 100.2.2.3
# R3的配置如下:int g0/0ip add 100.2.2.3 24int g0/1ip add 192.168.3.3 24ip route-static 0.0.0.0 0 100.2.2.2
# SERVER1的配置如下:int g0/0ip add 192.168.3.1 24ip route-static 0.0.0.0 0 192.168.3.3
# PC3配置IP为192.168.2.32.在 SERVER1 上配置开启 TELNET 和 FTP 服务
# SERVER1的配置如下:telnet server enableftp server enable3.配置 ACL 部分
分析:
- 需求 i,要求 192.168.1.0/24 网段不允许访问 192.168.2.0/24 网段,只能使用基本 ACL 实现。基本 ACL 只过滤源 IP 地址,只能在 R2 的 g0/2 接口上配置出方向包过滤来实现。如果配置在两个网段沿途的其他位置,将会影响到 192.168.1.0/24 网段和其他网段的正常通讯
- 需求 ii,PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务。既然要过滤指定的服务,就只能使用高级 ACL,高级 ACL 不会造成误过滤,所以可以配置在离源地址最近的接口的入方向,也就是 R1 的 g0/1 接口的入方向。另外,由于 H3C 的 ACL 用于包过滤默认动作是允许,所以并不需要专门配置允许 PC1 访问 SERVER1 的 TELNET,只需要配置拒绝访问 FTP 的规则即可
- 需求 iii,PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务。同理,只能使用高级 ACL,配置在 R1 的 g0/1 接口的入方向。而且也只需要配置拒绝访问 TELNET 的规则即可(由于需求iii和需求ii配置在同一个路由器同一个接口的同方向,所以把规则写入到同一个 ACL 即可)
- 需求 iv:192.168.2.0/24 网段不允许访问 SERVER1,要求通过高级 ACL 实现。高级 ACL 不会造成误过滤,所以可以配置在离源地址最近的接口的入方向,也就是 R2 的 g0/2 接口的入方向。另外,没有明确说明不允许访问什么服务,就是所有都不允许访问,所以高级 ACL 中的协议需要指定为 IP 协议
步骤 1:创建基本 ACL,使 192.168.1.0/24 网段不能访问 192.168.2.0/24 网段,并在 R2 的 g0/2 接口的出方向配置包过滤
#路由器R2的配置如下:acl basic 2000rule deny source 192.168.1.0 0.0.0.255interface g0/2packet-filter 2000 outbound步骤 2:创建高级 ACL,使 PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务;PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务,并在 R1 的 g0/1 接口的入方向配置包过滤
#路由器R1的配置如下:acl advanced 3000rule deny tcp source 192.168.1.1 0 destination 192.168.3.1 0 destination-port range 20 21rule deny tcp source 192.168.1.2 0 destination 192.168.3.1 0 destination-port eq 23interface g0/1packet-filter 3000 inbound步骤 3:创建高级 ACL,使PC3 不能访问 SERVER1,并在 R2 的 g0/2 接口的入方向配置包过滤
#路由器R2的配置如下:acl advanced 3000rule deny ip source 192.168.2.0 0.0.0.255 destination 192.168.3.1 0interface g0/2packet-filter 3000 inbound4.效果测试
步骤 1:PC1 和 PC2 都无法 Ping 通 PC3
[PC1]ping 192.168.2.3Ping 192.168.2.3 (192.168.2.3): 56 data bytes, press CTRL+C to breakRequest time outRequest time outRequest time outRequest time outRequest time out
--- Ping statistics for 192.168.2.3 ---5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss[PC1]%Sep 2 11:08:33:447 2026 PC1 PING/6/PING_STATISTICS: Ping statistics for 192.168.2.3: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.
[PC2]ping 192.168.2.3Ping 192.168.2.3 (192.168.2.3): 56 data bytes, press CTRL+C to breakRequest time outRequest time outRequest time outRequest time outRequest time out
--- Ping statistics for 192.168.2.3 ---5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss%Sep 2 11:08:45:747 2026 PC2 PING/6/PING_STATISTICS: Ping statistics for 192.168.2.3: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.步骤 2:PC1 可以连接 SERVER1 的 TELNET,但不能连接 FTP
<PC1>telnet 192.168.3.1Trying 192.168.3.1 ...Press CTRL+K to abortConnected to 192.168.3.1 ...
******************************************************************************* Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.** Without the owner's prior written consent, ** no decompiling or reverse-engineering shall be allowed. *******************************************************************************
Login failed.
The connection was closed by the remote host!<PC1>ftp 192.168.3.1Press CTRL+C to abort.
<PC1>步骤 3:PC2 可以连接 SERVER1 的 FTP,但不能连接 TELNET
<PC2>telnet 192.168.3.1Trying 192.168.3.1 ...Press CTRL+K to abortConnected to 192.168.3.1 ...Failed to connect to the remote host!
<PC2>ftp 192.168.3.1Press CTRL+C to abort.Connected to 192.168.3.1 (192.168.3.1).220 FTP service ready.User (192.168.3.1:(none)):530 This is a private system - No anonymous loginftp: Login failed.Remote system type is UNIX.Using binary mode to transfer files.ftp> quit221-Goodbye. You uploaded 0 and downloaded 0 kbytes.221 Logout.<PC2>步骤 4:PC3 不能 Ping 通 SERVER1
<H3C>ping 192.168.3.1Ping 192.168.3.1 (192.168.3.1): 56 data bytes, press CTRL_C to breakRequest time outRequest time outRequest time outRequest time outRequest time out
--- Ping statistics for 192.168.3.1 ---5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss<H3C>%Sep 2 11:12:10:943 2026 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.3.1: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.

