ensp学习第七弹acl


访问控制列表

基本acl 编号2000-2999 高级acl编号3000-3999

实验拓扑图

实验拓扑图

改为使用AR2220

实验目的

访问控制列表acl是由一条或者多条的规则组成的集合,规则就是描述报文匹配条件的判断语句,这些条件包括报文的源地址,目的地址,端口号。

acl实质上是一种报文过滤器,规则就是这个过滤器的滤芯。设备基于这些自己创建的规则进行报文匹配,可以过滤出特定的报文,并根据应用acl模块处理策略来允许和阻止该报文的通过

配置过程

1、配置个个路由器端口的IP地址

​ 给R1配置两个回环地址

​ 0 : 10.4.1.1 24

​ 1: 10.5.1.1 24

​ 并使用ospf使链路互通

[R1]ospf 1
		area 0
			network 10.1.1.1 0.0.0.0
			network 10.4.1.1 0.0.0.0
			network 10.5.1.1 0.0.0.0
[R2]ospf 1
		area 0
			network 10.1.1.2 0.0.0.0
			network 10.1.3.2 0.0.0.0
[R3]ospf 1
		area 0
			network 10.1.3.3 0.0.0.0

2、配置acl 匹特定的流量

配置有一条默认的规则 那就是

​ 基础acl要尽可能的靠近目的端口

​ 尽可能的让每一条报文都到达目的端口

[Huawei-acl-basic-2000] rule [ rule-id ] { deny | permit } [ source { source-address source-wildcard | any } | time-range time-name ] 

​ 高级acl要尽可能的靠近源端口

​ 不浪费网络资源

当参数protocol为IP时

rule [ rule-id ] { deny | permit } ip [ destination { destination-address destination-wildcard | any } | source { source-address source-wildcard | any } | time-range time-name | [ dscp dscp | [ tos tos | precedence

当参数protocol为TCP时

rule [ rule-id ] { deny | permit } { protocol-number | tcp } [ destination { destination-address destination-wildcard | any } | destination-port { eq port | gt port | lt port | range port-start port-end } | source { source-address source-wildcard | any } | source-port { eq port | gt port | lt port | range port-start port-end } | tcp-flag { ack | fin | syn } * | time-range time-name ] *

配置R3为telent服务器

[R3]telent server enable
	user-interface vty 0 4

user-interface 用来进入一个用户界面或者多个用户界面试图

VTY 用户界面 用来管理或者 监控通过的telent或者ssh方式登录的用户

在R3上配置acl

permit是允许通过该报文

deny是抛弃该报文

[R3]user-interface vty 0 4
		user privilege level 3
    	set authentication password cipher lyz
    acl 3000
  		rule 5 permit tcp source 10.4.1.1 0.0.0.0 destination 10.1.3.3 0.0.0.0 destination-port eq 23
  		rule 10 deny tcp source any
	user-interface vty 0 4
	acl 3000 inbound
[R1]telnet -a 10.4.1.1 10.1.3.3

规则的默认步长是5,目的就是为了以后在往中间去添加规则,如果五个不够添加的话,但是还是必须要往前面添加,那就只能全部删了重新来

acl 3000

在R2上配置acl

已解决!!!

尽量使用AR2220,AR2240或者AR3260设备。 AR201基本都是二层口吧

使用router不支持命令201也是不支持命令traffic-filter inbound acl 3001

acl 3001
 		rule 5 permit tcp source 10.4.1.1 0.0.0.0 destination 10.1.3.3 0.0.0.0 destination-port eq 23
 		rule 10 deny tcp source any

在 0/0/1端口进行流量过滤

[R2]int g 0/0/1
		traffic-filter inbound acl 3001
[R2]dis acl 3001
[R1]telnet -a 10.4.1.1 10.1.3.3

3、配置流量过滤

[R3]acl 3000 inbound
[R2]traffic-filter inbound acl 3001

R1登录R3

思考题

R3 现在同时为telent和ftp服务器现在要求R1的loopback 0 接口地址能访问ftp服务,R1的loopback1接口访问telent服务

配置配置只能访问telent服务,就跟上面的步骤一样

配置只能访问ftp服务

rule 7 permit tcp source 10.5.1.1 0 destination 10.1.3.3 0 destination-port eq 
ftp

就可以完成R1的另一个loopback接口只能访问ftp服务

ftp R1访问R3


文章作者: 毛豆不逗比
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 毛豆不逗比 !
  目录
{% include '_third-party/exturl.swig' %} {% include '_third-party/bookmark.swig' %} {% include '_third-party/copy-code.swig' %} + {% include '_custom/custom.swig' %}