软考网络工程师《华为基础实验》二十二 配置访问控制列表ACL.docx
《软考网络工程师《华为基础实验》二十二 配置访问控制列表ACL.docx》由会员分享,可在线阅读,更多相关《软考网络工程师《华为基础实验》二十二 配置访问控制列表ACL.docx(10页珍藏版)》请在冰豆网上搜索。
![软考网络工程师《华为基础实验》二十二 配置访问控制列表ACL.docx](https://file1.bdocx.com/fileroot1/2023-1/27/42898272-e361-432d-a9c8-e21b66d0e76f/42898272-e361-432d-a9c8-e21b66d0e76f1.gif)
软考网络工程师《华为基础实验》二十二配置访问控制列表ACL
2018软考网络工程师《华为基础实验》二十二配置访问控制列表ACL
一、ACL基础概念
1、访问控制列表根据源地址、目标地址、源端口或目标端口等协议信息对数据包进行过滤,
从而达到访问控制的目的。
可以在路由器、三层交换机等设备上使用,目前部分新二层交换
机也支持ACL。
2、ACL由编号或名字标识,ACL包含一组语句(规则)。
3、ACL包括permit/deny两种动作,表示允许/拒绝,匹配(命中规则)是指存在ACL,且在
ACL中查找到了符合条件的规则。
4、ACL在系统视图模式下配置,生成的ACL命令需要被应用才能起效。
5、ACL的分类
可当一个分组经过时,路由器按照一定的步骤找出与分组信息匹配的ACL语句对其进
行处理。
n 按配置顺序的匹配规则(config 模式),ACL 的默认匹配规则为 config 模式,以对ACL语句的处理规则总结出以下要点。
(1)一旦发现匹配的语句,就不再处理列表中的其他语句。
(2)语句的排列顺序很重要。
(3)如果整个列表中没有匹配的语句,则分组被丢弃。
例如下面两条语句组成的一个基本 ACL
ruledenysource172.16.0.00.0.255.255
rulepermitsource172.16.1.00.0.0.255
第二条语句就被忽略了。
要达到预想的结果—允许来自除主机 172.16.1.1 之外的、属
于子网 172.16.1.0/24 的所有通信,则两条语句的顺序必须互换。
n 按照自动排序规则(auto 模式)
自动排序指系统使用“深度优先”的原则,将规则按照精确度从高到低进行排序,并按
照精确度从高到低进行报文匹配。
规则中定义的匹配项限制越严格,规则的精确度就越
高,即优先级越高,系统越优先匹配。
例如在auto模式下的ACL3001,如下:
ruledenyipdestination172.16.0.00.0.255.255
rulepermitipdestination172.16.10.00.0.0.255
配置完上述两条规则后,ACL3001的规则排序如下。
6、ACL规则的步长
系统为ACL中首条未手工指定编号的规则分配编号时,使用步长值作为该规则的起始编
号;为后续规则分配编号时,则使用大于当前ACL内最大规则编号且是步长整数倍的最
小整数作为规则编号。
缺省步长为5。
设置步长的目的,是为了方便大家在ACL规则之
间插入新的规则。
二、ACL配置命令
1、配置基本ACL命令
#创建一个数字型的基本ACL
acl [acl-number ][ match-order { auto | config }]
#创建一个命名型的基本ACL
aclname acl-name { basic |acl-number }[ match-order { auto | config }]
#配置基本acl的规则的操作命令
rule [ rule-id ]{ deny | permit } source { source-addresssource-wildcard | any } | vpn-instance vpn-instance-name |[fragment |no-first- fragment] | logging | time-range time-range-name ]
1)ACL语句的删除
undoacl {[number] acl-number |all } 或 undoaclname acl-name
2)调整ACL步长
在系统视图模式下执行:
step step
3)查看和清除ACL信息
#确认设备ACL资源的分配情况
displayaclresource[slot slot-id]
#清除ACL统计信息(用户视图下)
resetaclcounter {name acl-name | acl-number|all}
4)通配符掩码
ACL规定使用通配符掩码来说明子网地址,通配符掩码就是子网掩码按位取反的结果。
如下两
个特殊的通配符掩码需要说明。
0.0.0.0
255.255.255.255
通配符掩码0.0.0.0表示ACL语句中的32位地址要求全部匹配,因而叫做主机掩码。
例如
192.168.1.10.0.0.0表示主机192.168.1.1的IP地址
2、配置基本ACL的实例
1)在ACL2001中配置规则,允许源IP地址是192.168.1.3主机地址的报文通过。
system-view
[HUAWEI]acl2001
[HUAWEI-acl-basic-2001]rulepermitsource192.168.1.30
2)配置基于源IP地址(网段地址)过滤报文的规则
在ACL2001中配置规则,仅允许源IP地址是192.168.1.3主机地址的报文通过,拒绝源IP地址是
192.168.1.0/24网段其他地址的报文通过,并配置ACL描述信息为Permitonly192.168.1.3through。
system-view[HUAWEI]acl2001
[HUAWEI-acl-basic-2001]rulepermitsource192.168.1.30
[HUAWEI-acl-basic-2001]ruledenysource192.168.1.00.0.0.255
[HUAWEI-acl-basic-2001]descriptionPermitonly192.168.1.3through
3)配置基于时间的ACL规则
创建时间段working-time(周一到周五每天8:
00到18:
00),并在名称为work-acl的ACL中配置规则,在working-time限定的时间范围内,拒绝源IP地址是192.168.1.0/24网段地址的报文通过。
system-view
[HUAWEI]time-rangeworking-time8:
00to18:
00working-day
[HUAWEI]aclnamework-aclbasic
[HUAWEI-acl-basic-work-acl]ruledenysource192.168.1.00.0.0.255time-rangeworking-time
4)配置基于IP分片信息、源IP地址(网段地址)过滤报文的规则
在ACL2001中配置规则,拒绝源IP地址是192.168.1.0/24网段地址的非首片分片报文通过。
system-view
[HUAWEI]acl2001
[HUAWEI-acl-basic-2001]ruledenysource192.168.1.00.0.0.255fragment
3、配置高级 ACL 的命令语法
rule[rule-id]{permit|deny}protocol[source{source-addrwildcard|any}][destination{dest-addrwildcard|any}][source-portoperatorport1[port2]][destination-portoperatorport1[port2]][icmp-typetypecode][established][[{precedenceprecedencetostos|dscpdscp}*|vpn-instanceinstance]|fragment|time-rangename]
5)配置基于ICMP协议类型、源IP地址(主机地址)和目的IP地址(网段地址)过滤报文的规则在ACL3001中配置规则,允许源IP地址是192.168.1.3主机地址且目的IP地址是192.168.2.0/24网
段地址的ICMP报文通过。
system-view
[HUAWEI]acl3001
[HUAWEI-acl-adv-3001]rulepermiticmpsource192.168.1.30destination192.168.2.0
0.0.0.255
6)配置基于TCP协议类型、TCP目的端口号、源IP地址(主机地址)和目的IP地址(网段地址)
过滤报文的规则
在名称为deny-telnet的高级ACL中配置规则,拒绝IP地址是172.16.10.3的主机与172.16.20.0/24网段的主机建立Telnet连接。
system-view
[HUAWEI]aclnamedeny-telnet
[HUAWEI-acl-adv-deny-telnet]ruledenytcpdestination-porteqtelnetsource172.16.10.30destination172.16.20.00.0.0.255
在名称为no-web的高级ACL中配置规则,禁止172.16.10.3和172.16.10.4两台主机访
问Web网页(HTTP协议用于网页浏览,对应TCP端口号是80),并配置ACL描述信息为
Webaccessrestrictions。
system-view[HUAWEI]aclnameno-web
[HUAWEI-acl-adv-no-web]descriptionWebaccessrestrictions
[HUAWEI-acl-adv-no-web]ruledenytcpdestination-porteq80source172.16.10.30
[HUAWEI-acl-adv-no-web]ruledenytcpdestination-porteq80source172.16.10.40
三、实验要求
n 在路由器Router上创建基本ACL
n 在VTY(VirtualTypeTerminal)上应用所配置的基本ACL
n
在Router上配置基本ACl过滤网络流量
n 在Router上配置高级ACL基于目标和服务过滤流量网络拓扑图:
操作步骤:
1、配置Router路由器,指定接口IP地址
system-view
Entersystemview,returnuserviewwithCtrl+Z.
[Huawei]sysnameRouter
[Router]interfaceGigabitEthernet0/0/0
[Router-GigabitEthernet0/0/0]ipadd172.16.10.124
[Router-GigabitEthernet0/0/0]intG0/0/1
[Router-GigabitEthernet0/0/1]ipadd172.16.20.124
[Router-GigabitEthernet0/0/1]intG0/0/2
[Router-GigabitEthernet0/0/2]ipadd172.16.30.124
[Router-GigabitEthernet0/0/2]intG2/0/0
[Router-GigabitEthernet2/0/0]ipadd172.16.0.124
[Router-GigabitEthernet2/0/0]intG1/0/0
[Router-GigabitEthernet1/0/0]ipadd172.16.40.124
[Router-GigabitEthernet1/0/0]quit
2、配置拓扑中的“网络管理员PC”,用路由器模拟,网关(默认路由)指向Routersystem-view
Entersystemview,returnuserviewwithCtrl+Z.
[Huawei]sysnameManager
[Manager]interfaceGigabitEthernet0/0/0[Manager-GigabitEthernet0/0/0]ipadd172.16.0.224
[Manager-GigabitEthernet0/0/0]ping172.16.0.1
PING172.16.0.1:
56databytes,pressCTRL_Ctobreak
Replyfrom172.16.0.1:
bytes=56Sequence=1ttl=255time=90ms
Replyfrom172.16.0.1:
bytes=56Sequence=2ttl=255time=20ms
Replyfrom172.16.0.1:
bytes=56Sequence=3ttl=255time=20ms
Replyfrom172.16.0.1:
bytes=56Sequence=4ttl=255time=10ms
Replyfrom172.16.0.1:
bytes=56Sequence=5ttl=255time=10ms
[manager]iproute-static0.0.0.00.0.0.0172.16.10.1
3、配置拓扑中的“CLIENT1”,用路由器模拟,需要添加默认路由(网关指向路由器)
system-view[Huawei]sysnameClient[Client]intG0/0/0
[Client-GigabitEthernet0/0/0]ipadd172.16.10.224
[Client]iproute-static0.0.0.00.0.0.0172.16.10.1
4、配置Router,使用基本ACL控制对本路由器的进程登录,只允许172.16.0.2(网络管理员PC)对Router进行进程管理
[Router]aclnumber2000
[Router-acl-basic-2000]rulepermitsource172.16.0.20.0.0.0
[Router-acl-basic-2000]ruledenysourceany
[Router-acl-basic-2000]quit
[Router]user-interfacevty04
[Router-ui-vty0-4]authentication-modepassword
Pleaseconfiguretheloginpassword(maximumlength16):
Huawei
[Router-ui-vty0-4]acl2000inbound
[Router-ui-vty0-4]quit
[Router]displayacl2000BasicACL2000,2rulesAcl'sstepis5
rule5permitsource172.16.0.20rule10deny
5、测试上一步的配置效果,确认“网络管理员PC”可以进程登录Router,“Client1”不能
进程登录Routertelnet172.16.10.1
PressCTRL_]toquittelnetmode
Trying172.16.10.1...
Error:
Can'tconnecttotheremotehost
telnet172.16.0.1
PressCTRL_]toquittelnetmode
Trying172.16.0.1...
Connectedto172.16.0.1...
Loginauthentication
Password:
quit
Configurationconsoleexit,pleaseretrytologon
Theconnectionwasclosedbytheremotehost
6、在Router上配置基本ACL,确保Router向服务器网络(172.16.40.0/24)转发流量时,丢弃来自172.16.10.0/24的数据
[Router]acl2001
[Router-acl-basic-2001]ruledenysource172.16.10.00.0.0.255
[Router-acl-basic-2001]quit
[Router]interfaceGigabitEthernet1/0/0
[Router-GigabitEthernet1/0/0]traffic-filteroutboundacl2001
7、配置拓扑中的Server1,用路由器模拟,网关(默认路由)指向Routersystem-view
Entersystemview,returnuserviewwithCtrl+Z.[Huawei]sysnameServer1
[Server1]interfaceGigabitEthernet0/0/0
[Server1-GigabitEthernet0/0/0]ipadd172.16.40.10024
[Server1]iproute-static0.0.0.00.0.0.0172.16.40.1
8、做ping测试验证第6步的ACL效果,Client是无法ping通Server1的,而网段的主机
(如网络管理员PC)可以ping通Server1
ping172.16.40.100
PING172.16.40.100:
56databytes,pressCTRL_Ctobreak
Requesttimeout
Requesttimeout
Requesttimeout
Requesttimeout
Requesttimeout
---172.16.40.100pingstatistics---
5packet(s)transmitted
0packet(s)received
100.00%packetloss
[Manager]ping172.16.40.100
PING172.16.40.100:
56databytes,pressCTRL_Ctobreak
Replyfrom172.16.40.100:
bytes=56Sequence=1ttl=254time=80ms
Replyfrom172.16.40.100:
bytes=56Sequence=2ttl=254time=40ms
Replyfrom172.16.40.100:
bytes=56Sequence=3ttl=254time=40ms
Replyfrom172.16.40.100:
bytes=56Sequence=4ttl=254time=30ms
Replyfrom172.16.40.100:
bytes=56Sequence=5ttl=254time=30ms
---172.16.40.100pingstatistics---
5packet(s)transmitted
5packet(s)received
0.00%packetloss
round-tripmin/avg/max=30/44/80ms
9、配置高级ACL,确保172.16.0.0/24网络中的主机,在访问172.16.40.100时,只能telnet,
而不能进行其他方式的访问,同时,对172.16.40.0/24中的其他主机以及对172.16.40.0/24
以外的其他主机的访问都不受限制
[Router]acl3000
[Router-acl-adv-3000]rulepermittcpdestination172.16.40.1000.0.0.0destination-porteq23
[Router-acl-adv-3000]ruledenyipdestination172.16.40.1000.0.0.0
[Router]interfaceGigabitEthernet2/0/0
[Router-GigabitEthernet2/0/0]traffic-filterinboundacl3000
[Router-GigabitEthernet2/0/0]quit
10、用“网络管理员PC”测试,这台主机现在可以telnet访问Server1,但无法ping通Server1,同时它访问别的主机都是没有问题
telnet172.16.40.100PressCTRL_]toquittelnetmodeTrying172.16.40.100...
Connectedto172.16.40.100...
Loginauthentication
Password:
quit
Configurationconsoleexit,pleaseretrytologon
Theconnectionwasclosedbytheremotehost
ping172.16.40.100
PING172.16.40.100:
56databytes,pressCTRL_CtobreakRequesttimeout
RequesttimeoutRequesttimeoutRequesttimeoutRequesttimeout
---172.16.40.100pingstatistics---
5packet(s)transmitted
0packet(s)received
100.00%packetloss