ACL 实验

ACL 实验

实验拓扑#

实验需求#

  1. 按照图示配置 IP 地址
  2. 全网路由互通
  3. 在 SERVER1 上配置开启 TELNET 和 FTP 服务
  4. 配置 ACL 实现如下效果
    1. 192.168.1.0/24 网段不允许访问 192.168.2.0/24 网段,要求使用基本 ACL 实现
    2. PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务
    3. PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务
    4. 192.168.2.0/24 网段不允许访问 SERVER1,要求通过高级 ACL 实现

实验解法#

1.配置 IP 地址/静态路由#

# PC1的配置如下:
int g0/0
ip add 192.168.1.1 24
ip route-static 0.0.0.0 0 192.168.1.254
# PC2的配置如下:
int g0/0
ip add 192.168.1.2 24
ip route-static 0.0.0.0 0 192.168.1.254
# R1的配置如下:
int g0/0
ip add 100.1.1.1 24
int g0/1
ip add 192.168.1.254 24
ip route-static 0.0.0.0 0 100.1.1.2
# R2的配置如下:
int g0/0
ip add 100.1.1.2 24
int g0/1
ip add 100.2.2.2 24
int g0/2
ip add 192.168.2.2 24
ip route-static 192.168.1.0 24 100.1.1.1
ip route-static 192.168.3.0 24 100.2.2.3
# R3的配置如下:
int g0/0
ip add 100.2.2.3 24
int g0/1
ip add 192.168.3.3 24
ip route-static 0.0.0.0 0 100.2.2.2
# SERVER1的配置如下:
int g0/0
ip add 192.168.3.1 24
ip route-static 0.0.0.0 0 192.168.3.3
# PC3配置IP为192.168.2.3

2.在 SERVER1 上配置开启 TELNET 和 FTP 服务#

# SERVER1的配置如下:
telnet server enable
ftp server enable

3.配置 ACL 部分#

分析:

  1. 需求 i,要求 192.168.1.0/24 网段不允许访问 192.168.2.0/24 网段,只能使用基本 ACL 实现。基本 ACL 只过滤源 IP 地址,只能在 R2 的 g0/2 接口上配置出方向包过滤来实现。如果配置在两个网段沿途的其他位置,将会影响到 192.168.1.0/24 网段和其他网段的正常通讯
  2. 需求 ii,PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务。既然要过滤指定的服务,就只能使用高级 ACL,高级 ACL 不会造成误过滤,所以可以配置在离源地址最近的接口的入方向,也就是 R1 的 g0/1 接口的入方向。另外,由于 H3C 的 ACL 用于包过滤默认动作是允许,所以并不需要专门配置允许 PC1 访问 SERVER1 的 TELNET,只需要配置拒绝访问 FTP 的规则即可
  3. 需求 iii,PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务。同理,只能使用高级 ACL,配置在 R1 的 g0/1 接口的入方向。而且也只需要配置拒绝访问 TELNET 的规则即可(由于需求iii和需求ii配置在同一个路由器同一个接口的同方向,所以把规则写入到同一个 ACL 即可)
  4. 需求 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 2000
rule deny source 192.168.1.0 0.0.0.255
interface g0/2
packet-filter 2000 outbound
步骤 2:创建高级 ACL,使 PC1 可以访问 SERVER1 的 TELNET 服务,但不能访问 FTP 服务;PC2 可以访问 SERVER1 的 FTP 服务,但不能访问 TELNET 服务,并在 R1 的 g0/1 接口的入方向配置包过滤#
#路由器R1的配置如下:
acl advanced 3000
rule deny tcp source 192.168.1.1 0 destination 192.168.3.1 0 destination-port range 20 21
rule deny tcp source 192.168.1.2 0 destination 192.168.3.1 0 destination-port eq 23
interface g0/1
packet-filter 3000 inbound
步骤 3:创建高级 ACL,使PC3 不能访问 SERVER1,并在 R2 的 g0/2 接口的入方向配置包过滤#
#路由器R2的配置如下:
acl advanced 3000
rule deny ip source 192.168.2.0 0.0.0.255 destination 192.168.3.1 0
interface g0/2
packet-filter 3000 inbound

4.效果测试#

步骤 1:PC1 和 PC2 都无法 Ping 通 PC3#
[PC1]ping 192.168.2.3
Ping 192.168.2.3 (192.168.2.3): 56 data bytes, press CTRL+C to break
Request time out
Request time out
Request time out
Request time out
Request 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.3
Ping 192.168.2.3 (192.168.2.3): 56 data bytes, press CTRL+C to break
Request time out
Request time out
Request time out
Request time out
Request 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.1
Trying 192.168.3.1 ...
Press CTRL+K to abort
Connected 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.1
Press CTRL+C to abort.
<PC1>
步骤 3:PC2 可以连接 SERVER1 的 FTP,但不能连接 TELNET#
<PC2>telnet 192.168.3.1
Trying 192.168.3.1 ...
Press CTRL+K to abort
Connected to 192.168.3.1 ...
Failed to connect to the remote host!
<PC2>ftp 192.168.3.1
Press 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 login
ftp: Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.
<PC2>
步骤 4:PC3 不能 Ping 通 SERVER1#
<H3C>ping 192.168.3.1
Ping 192.168.3.1 (192.168.3.1): 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request 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.
Profile Image of the Author
Ynm
Hello, I'm Ynm.
公告
近期Cloudflare全球网络波动导致本站部分地区访问变慢,若遇长时间加载,刷新或稍后重试通常可恢复。 欢迎来到我的博客,本博客仅供学习交流使用,请严格遵守法律法规,未经授权严禁对真实目标进行扫描或攻击!
分类
标签
最新动态