1 理解 ACL 原理与类型
1.1 需求
1)如图配置 IP 地址
2)PC1 不能访问 Server
3)PC2 允许访问 Server
4)允许其他所有的访问流量
1.2 方案
搭建实验环境,如图 - 1 所示。
图 - 1
1.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 - PC1
地址: 192.168.1.1
掩码: 255.255.255.0
网关: 192.168.1.254
2)配置终端设备 - PC2
地址: 192.168.2.1
掩码: 255.255.255.0
网关: 192.168.2.254
3)配置终端设备 - Server
地址: 192.168.100.1
掩码: 255.255.255.0
网关: 192.168.100.254
4)配置网络设备 - R1
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R1//更改设备名称
4. \[R1\]interface gi0/0/1 //连接 PC1
5. \[R1-GigabitEthernet0/0/1\]ip address 192.168.1.254 24 //配置IP地址
6. \[R1-GigabitEthernet0/0/1\]quit
8. \[R1\]interface gi0/0/2 //连接 PC2
9. \[R1-GigabitEthernet0/0/2\]ip address 192.168.2.254 24 //配置 IP 地址
10. \[R1-GigabitEthernet0/0/2\]quit
5)配置 ACL
1. \[R1\]acl 2000 //创建基本 ACL
2. \[R1-acl-basic-2000\]rule 10 deny source 192.168.1.1 0.0.0.255 //拒绝源为 PC1的流量
3. \[R1-acl-basic-2000\]quit
5. \[R1\]interface g0/0/0 //连接 Server1 的接口
6. \[R1-GigabitEthernet0/0/0\]traffic-filter outbound acl 2000 //调用在端口的出方向
7. \[R1-GigabitEthernet0/0/0\]quit
6)测试
1. display acl all //查看设备上所有的 ACL
2. display acl 2000 //查看 ACL 2000 的内容
3. PC1不能ping通Server1
4. PC2可以ping通Server1
5. PC1可以ping通 PC2
2 基本 ACL 配置
2.1 需求
1)如图配置 IP 地址
2)不允许 “售后服务部” 以任何的方式访问 “财务部” 服务器
3)售后服务器可以访问网络的任何其他设备
2.2 方案
搭建实验环境,如图 - 2 所示。
图 - 2
2.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 – PC1
地址:192.168.1.1
掩码:255.255.255.0
网关:192.168.1.254
2)配置终端设备 – PC2
地址:192.168.2.1
掩码:255.255.255.0
网关:192.168.2.254
3)配置终端设备 – 财务服务器
地址:192.168.3.1
掩码:255.255.255.0
网关:192.168.3.254
4)配置网络设备 - R1
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R1//更改设备名称
4. \[R1\]interface gi0/0/1 //连接 Client1
5. \[R1-GigabitEthernet0/0/1\] ip address 192.168.1.254 24
6. \[R1-GigabitEthernet0/0/1\] quit
8. \[R1\]interface gi0/0/0 //连接 R2的接口
9. \[R1-GigabitEthernet0/0/0\] ip address 192.168.12.1 24
10. \[R1-GigabitEthernet0/0/0\] quit
12. \[R1\]ip route-static 192.168.2.0 24 192.168.12.2 //去往PC2的路由条目
13. \[R2\]ip route-static 192.168.3.0 24 192.168.12.2 //去往财务服务器的路由
5)配置网络设备 - R2
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R2//更改设备名称
4. \[R2\]interface gi0/0/1 //连接 PC2
5. \[R2-GigabitEthernet0/0/1\] ip address 192.168.2.254 24
6. \[R2-GigabitEthernet0/0/1\] quit
8. \[R2\]interface gi0/0/0 //连接 R1 的接口
9. \[R2-GigabitEthernet0/0/0\] ip address 192.168.12.2 24
10. \[R2-GigabitEthernet0/0/0\] quit
12. \[R2\]interface gi0/0/2 //连接 服务器 的接口
13. \[R2-GigabitEthernet0/0/2\] ip address 192.168.3.254 24
14. \[R2-GigabitEthernet0/0/2\] quit
16. \[R2\]ip route-static 192.168.1.0 255.255.255.0 192.168.12.1 //去往PC1的网段
6)配置网络设备 – SW1
1. <Huawei>undo terminal monitor
2. <Huawei>sysname SW1
3. \[SW1\]vlan 10
4. \[SW1-vlan10\]quit
6. \[SW1\]interface GigabitEthernet 0/0/1
7. \[SW1-GigabitEthernet0/0/1\]port link-type access
8. \[SW1-GigabitEthernet0/0/1\]port default vlan 10
9. \[SW1-GigabitEthernet0/0/1\]quit
11. \[SW1\]interface GigabitEthernet 0/0/2
12. \[SW1-GigabitEthernet0/0/2\]port link-type access
13. \[SW1-GigabitEthernet0/0/2\]port default vlan 10
14. \[SW1-GigabitEthernet0/0/2\]quit
7)配置网络设备 – SW2
1. <Huawei>undo terminal monitor
2. <Huawei>sysname SW2
3. \[SW2\]vlan 20
4. \[SW2-vlan20\]quit
6. \[SW2\]interface GigabitEthernet 0/0/1
7. \[SW2-GigabitEthernet0/0/1\]port link-type access
8. \[SW2-GigabitEthernet0/0/1\]port default vlan 20
9. \[SW2-GigabitEthernet0/0/1\]quit
11. \[SW2\]interface GigabitEthernet 0/0/2
12. \[SW2-GigabitEthernet0/0/2\]port link-type access
13. \[SW2-GigabitEthernet0/0/2\]port default vlan 20
14. \[SW2-GigabitEthernet0/0/2\]quit
8)配置控制策略并调用
1. \[R2\]acl 2000 //创建基本ACL
2. \[R2-acl-basic-2000\]rule 10 deny source 192.168.1.0 0.0.0.255 //拒绝PC1的网段
3. \[R2-acl-basic-2000\]quit
5. \[R2\]interface GigabitEthernet 0/0/2
6. \[R2-GigabitEthernet0/0/2\]traffic-filter outbound acl 2000 //过滤出向流量
7. \[R2-GigabitEthernet0/0/2\]quit
3 高级 ACL 配置
3.1 需求
1)如图配置 IP 地址,配置路由,确保各设备互通
2)售后部仅仅能访问 Server1 上的 Web 服务,不能访问其他服务
3)售后部可以访问行政部的所有设备的任何服务
4)除了上述权限外,售后部不能访问网络中的其他任何地方
3.2 方案
搭建实验环境,如图 - 3 所示。
图 - 3
3.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 – 售后服务部
地址:192.168.1.1
掩码:255.255.255.0
网关:192.168.1.254
2)配置终端设备 – 行政部
地址:192.168.2.1
掩码:255.255.255.0
网关:192.168.2.254
3)配置终端设备 – Web 服务器
地址:192.168.3.1
掩码:255.255.255.0
网关:192.168.3.254
配置 web 服务:指定 web 服务器目录,启动 web 服务
4)配置网络设备 – R1
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R1//更改设备名称
4. \[R1\]interface gi0/0/2 //连接售后服务部
5. \[R1-GigabitEthernet0/0/2\] ip address 192.168.1.254 24
6. \[R1-GigabitEthernet0/0/2\] quit
8. \[R1\]interface gi0/0/0 //连接 R2的接口
9. \[R1-GigabitEthernet0/0/0\] ip address 192.168.12.1 24
10. \[R1-GigabitEthernet0/0/0\] quit
12. \[R1\]ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 //去往其他网段的默认路由
5)配置网络设备 – R2
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R2//更改设备名称
4. \[R2\]interface gi0/0/2 //连接 行政部
5. \[R2-GigabitEthernet0/0/2\] ip address 192.168.2.254 24
6. \[R2-GigabitEthernet0/0/2\] quit
8. \[R2\]interface gi0/0/1 //连接 R1 的接口
9. \[R2-GigabitEthernet0/0/1\] ip address 192.168.12.2 24
10. \[R2-GigabitEthernet0/0/1\] quit
12. \[R2\]interface gi0/0/0 //连接 R3 的接口
13. \[R2-GigabitEthernet0/0/0\] ip address 192.168.23.2 24
14. \[R2-GigabitEthernet0/0/0\] quit
16. \[R2\]ip route-static 192.168.1.0 255.255.255.0 192.168.12.1 //去往售后部的网段
17. \[R2\]ip route-static 192.168.3.0 255.255.255.0 192.168.23.3 //去往服务器的网段
6)配置网络设备 – R3
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R3//更改设备名称
4. \[R3\]interface gi0/0/2 //连接 Web服务器
5. \[R3-GigabitEthernet0/0/2\] ip address 192.168.3.254 24
6. \[R3-GigabitEthernet0/0/2\] quit
8. \[R3\]interface gi0/0/1 //连接 R2 的接口
9. \[R3-GigabitEthernet0/0/1\] ip address 192.168.23.3 24
10. \[R3-GigabitEthernet0/0/1\] quit
12. \[R3\]ip route-static 0.0.0.0 0.0.0.0 192.168.23.2 //去往其他网段的默认路由
7)在 R1 上配置并调用 ACL
1. \[R1\] acl 3000
3. \[R1-acl-adv-3000\]rule 10 permit tcp source 192.168.1.1 0 destination 192.168.3.1 0 destination-port eq 80
5. \[R1-acl-adv-3000\]rule 20 permit ip source 192.168.1.1 0 destination 192.168.2.0 0.0.0.255
7. \[R1-acl-adv-3000\]rule 30 deny ip source 192.168.1.1 0 destination any
9. \[R1\] interface gi0/0/2
10. \[R1-GigabitEthernet0/0/2\] traffic-filter inbound acl 3000 //在该接口入向调用ACL
4 高级 ACL 之 ICMP
4.1 需求
1)如图配置 IP 地址
2)售后部仅仅能 ping 通 Server1 上,不能访问其他服务
3)售后部可以访问行政部的所有设备的任何服务
4)除了上述权限外,售后部不能访问网络中的其他任何地方
4.2 方案
搭建实验环境,如图 - 4 所示。
图 - 4
4.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 – 售后服务部
地址:192.168.1.1
掩码:255.255.255.0
网关:192.168.1.254
2)配置终端设备 – 行政部
地址:192.168.2.1
掩码:255.255.255.0
网关:192.168.2.254
3)配置终端设备 – Web 服务器
地址:192.168.3.1
掩码:255.255.255.0
网关:192.168.3.254
配置 web 服务:指定 web 服务器目录,启动 web 服务
4)配置网络设备 – R1
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R1//更改设备名称
4. \[R1\]interface gi0/0/2 //连接售后服务部
5. \[R1-GigabitEthernet0/0/2\] ip address 192.168.1.254 24
6. \[R1-GigabitEthernet0/0/2\] quit
8. \[R1\]interface gi0/0/0 //连接 R2的接口
9. \[R1-GigabitEthernet0/0/0\] ip address 192.168.12.1 24
10. \[R1-GigabitEthernet0/0/0\] quit
12. \[R1\]ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 //去往其他网段的默认路由
5)配置网络设备 – R2
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R2//更改设备名称
4. \[R2\]interface gi0/0/2 //连接 行政部
5. \[R2-GigabitEthernet0/0/2\] ip address 192.168.2.254 24
6. \[R2-GigabitEthernet0/0/2\] quit
8. \[R2\]interface gi0/0/1 //连接 R1 的接口
9. \[R2-GigabitEthernet0/0/1\] ip address 192.168.12.2 24
10. \[R2-GigabitEthernet0/0/1\] quit
12. \[R2\]interface gi0/0/0 //连接 R3 的接口
13. \[R2-GigabitEthernet0/0/0\] ip address 192.168.23.2 24
14. \[R2-GigabitEthernet0/0/0\] quit
16. \[R2\]ip route-static 192.168.1.0 255.255.255.0 192.168.12.1 //去往售后部的网段
17. \[R2\]ip route-static 192.168.3.0 255.255.255.0 192.168.23.3 //去往服务器的网段
6)配置网络设备 – R3
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R3//更改设备名称
4. \[R3\]interface gi0/0/2 //连接 Web服务器
5. \[R3-GigabitEthernet0/0/2\] ip address 192.168.3.254 24
6. \[R3-GigabitEthernet0/0/2\] quit
8. \[R3\]interface gi0/0/1 //连接 R2 的接口
9. \[R3-GigabitEthernet0/0/1\] ip address 192.168.23.3 24
10. \[R3-GigabitEthernet0/0/1\] quit
12. \[R3\]ip route-static 0.0.0.0 0.0.0.0 192.168.23.2 //去往其他网段的默认路由
7)在 R1 上配置并调用 ACL
1. \[R1\] acl 3000
3. \[R1-acl-adv-3000\]rule 10 permit icmp source 192.168.1.1 0 destination 192.168.3.1 0
5. \[R1-acl-adv-3000\]rule 20 permit ip source 192.168.1.1 0 destination 192.168.2.0 0.0.0.255
7. \[R1-acl-adv-3000\]rule 30 deny ip source 192.168.1.1 0 destination any
9. \[R1\] interface gi0/0/2
10. \[R1-GigabitEthernet0/0/2\] traffic-filter inbound acl 3000 //在该接口入向调用ACL
5 高级 ACL 之 Telnet
5.1 需求
1)如图配置 IP 地址,配置路由,确保各设备互通
2)为了便于设备管理,为设备开启远程管理功能,登录密码:HCIE
3)仅仅允许 192.168.1.254 远程登录 R2,其他设备不可以
4)拒绝 R1 的任何 IP 地址远程登录 R3,其他设备都可以
5.2 方案
搭建实验环境,如图 - 5 所示。
图 - 5
5.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备 – 售后服务部
1. 地址:192.168.1.1
2. 掩码:255.255.255.0
3. 网关:192.168.1.254
2)配置终端设备 – 行政部
1. 地址:192.168.2.1
2. 掩码:255.255.255.0
3. 网关:192.168.2.254
3)配置终端设备 – Web 服务器
1. 地址:192.168.3.1
2. 掩码:255.255.255.0
3. 网关:192.168.3.254
4. 配置web服务:指定web服务器目录,启动 web 服务
4)配置网络设备 – R1
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R1//更改设备名称
4. \[R1\]interface gi0/0/2 //连接售后服务部
5. \[R1-GigabitEthernet0/0/2\] ip address 192.168.1.254 24
6. \[R1-GigabitEthernet0/0/2\] quit
8. \[R1\]interface gi0/0/0 //连接 R2的接口
9. \[R1-GigabitEthernet0/0/0\] ip address 192.168.12.1 24
10. \[R1-GigabitEthernet0/0/0\] quit
12. \[R1\]ip route-static 0.0.0.0 0.0.0.0 192.168.12.2 //去往其他网段的默认路由
5)配置网络设备 – R2
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R2//更改设备名称
4. \[R2\]interface gi0/0/2 //连接 行政部
5. \[R2-GigabitEthernet0/0/2\] ip address 192.168.2.254 24
6. \[R2-GigabitEthernet0/0/2\] quit
8. \[R2\]interface gi0/0/1 //连接 R1 的接口
9. \[R2-GigabitEthernet0/0/1\] ip address 192.168.12.2 24
10. \[R2-GigabitEthernet0/0/1\] quit
12. \[R2\]interface gi0/0/0 //连接 R3 的接口
13. \[R2-GigabitEthernet0/0/0\] ip address 192.168.23.2 24
14. \[R2-GigabitEthernet0/0/0\] quit
16. \[R2\]ip route-static 192.168.1.0 255.255.255.0 192.168.12.1 //去往售后部门的网段
17. \[R2\]ip route-static 192.168.3.0 255.255.255.0 192.168.23.3 //去往服务器的网段
19. \[R2\]user-interface vty 0 4
20. \[R2-ui-vty0-4\]authentication-mode password //指定认证方式为密码认证
21. Please configure the login password (maximum length 16):HCIE //配置密码为 HCIE
6)配置网络设备 – R3
1. <Huawei>system-view //进入系统模式
2. \[Huawei\]sysname R3//更改设备名称
4. \[R3\]interface gi0/0/2 //连接 Web服务器
5. \[R3-GigabitEthernet0/0/2\] ip address 192.168.3.254 24
6. \[R3-GigabitEthernet0/0/2\] quit
8. \[R3\]interface gi0/0/1 //连接 R2 的接口
9. \[R3-GigabitEthernet0/0/1\] ip address 192.168.23.3 24
10. \[R3-GigabitEthernet0/0/1\] quit
12. \[R3\]ip route-static 0.0.0.0 0.0.0.0 192.168.23.2 //去往其他网段的默认路由
14. \[R3\]user-interface vty 0 4
15. \[R3-ui-vty0-4\]authentication-mode password //指定认证方式为密码认证
16. Please configure the login password (maximum length 16):HCIE //配置密码为 HCIE
7)在 R2 上配置并调用 ACL
1. \[R2\]acl 2000
2. \[R2-acl-basic-2000\]rule 10 permit source 192.168.1.254 0
3. \[R2-acl-basic-2000\]quit
5. \[R2\]user-interface vty 0 4
6. \[R2-ui-vty0-4\]acl 2000 inbound
7. \[R2-ui-vty0-4\]quit
8)在 R3 上配置并调用 ACL
1. \[R3\]acl 2000
2. \[R3-acl-basic-2000\]rule 10 deny source 192.168.1.254 0
3. \[R3-acl-basic-2000\]rule 20 deny source 192.168.12.1 0
4. \[R3-acl-basic-2000\]rule 30 permit source any
5. \[R3-acl-basic-2000\]quit
7. \[R3\]user-interface vty 0 4
8. \[R3-ui-vty0-4\]acl 2000 inbound
9. \[R3-ui-vty0-4\]quit
https://tts.tmooc.cn/ttsPage/NTD/NTDTN202109/TCNE/DAY01/CASE/01/index.html