ACL和NAT

92 阅读2分钟

(学习笔记的第十一页)

ACL

白名单:默认拒绝所有,只放一个,只可以通信一个,专门负责自己内部的业务
黑名单:默认开放所有,加入一个,不能只通信一个,就想京东、淘宝。可能会有人恶意攻击你

ACL的应用

ACL两种应用:
  1. 应用在接口的ACL-----过滤数据包(原目ip地址,原目 mac, 端口 五元组)
  2. 应用在路由协议-------匹配相应的路由条目( )

acl的工作原理:

当数据包从接口经过时,由于接口启用了acl, 此时路由器会对报文进行检查,然后进行相对的处理。

ACL的种类

  1. 编号2000-2999---基本ACL----依据依据数据包当中的源IP地址匹配数据(数据时从哪个IP地址过来的)
  2. 编号3000-3999---高级ACL----依据数据包当中源、目的IP,源、目的端口、协议号匹配数据

实验:

image.png

基本acl

只需要在路由器中配置地址

int g0/0/0
ip address 192.168.1.254 255.255.255.0

每个端口都要配置

int g0/0/1
ip address 192.168.2.254 255.255.255.0

int g0/0/2
ip address 192.168.3.254 255.255.255.0

配完之后就是建立基本acl acl 2000
#基本acl 列表
rule 5 deny source 192.168.1.1 0
#默认编号5 拒绝 来自192.168.1.1 的流量

然后建立数据流向

int g0/0/1
traffic-filter outbound acl 2000

然后就完成了

高级acl

首先建立acl
acl number 3000
rule 5 deny tcp source 192.168.1.1 0 destination 192.168.2.1 0 destination port eq 80
(80是http的端口号,我们直接禁用端口号)

创建完就可以创建数据流向了
先进入需要端口
int g0/0/0
然后就输入这串代码就行了\c traffic-filter inbound acl 3000

NAT

NAT是网络地址翻译 如果数据包的目的ip或者源ip为私网地址,运营商的设备无法转发数据。

nat第工作原理

就是将一个数据包中的私网地址翻译公网地址

实验

image.png

内网出去外网地址

在AR2路由器上的 g0/0/1 口配置
int g0/0/1
ip address 200.1.1.1 255.255.255.0
undo nat static global 200.1.1.100 inside 192.168.1.1 netmask 255.255.255.255
nat server protocol tcp global current interface www inside 192.168.1.10
nat static enable

从外网进入内网

在AR2路由器上的 g0/0/1 口配置
acl 2000
rule permit source 192.168.1.0 0.0.0.255
int g0/0/1
undo nat static global 200.1.1.100 inside 192.168.1.1 netmask 255.255.255.255
nat outbound 2000\