標準ACL配置實例

訪問控制列表(一)

結構:

在這裏插入圖片描述

一.訪問控制列表概述:

訪問控制列表(ACL)

1.讀取第三層、第四層包頭信息bash

2.根據預先定義好的規則對包進行過濾ide

在這裏插入圖片描述

二.訪問控制類表的工做原理

訪問控制列表在接口應用的方向:

出:已通過路由器的處理,正離開路由器接口的數據包code

入:已達到路由器接口的數據包,將被路由器處理blog

列表應用到接口方向與數據方向有關

訪問控制列表的處理過程:

在這裏插入圖片描述

ACL規則:匹配爲自上而下逐條匹配,默認隱含的拒絕是拒絕全部(any)

白名單:

容許 1.2
容許 1.3
拒絕全部(不寫)接口

黑名單:

拒絕 1.2
拒絕 1.3
容許全部(必須寫)圖片

三.ACL訪問控制列表的類型:

標準訪問控制列表:

1.基於IP地址過濾數據包
2.標準訪問控制列表的訪問控制列表號是1~99ip

擴展訪問控制列表:

1.基於源IP、目標IP地址、指定協議、端口和標誌來過濾數據包
2.擴展訪問控制列表的訪問控制列表號是100~199路由

命名訪問控制列表(包含標準和擴展):

1.命名訪問控制列表容許在標準和擴展訪問控制列表中使用名稱待敵表號it

可靈活調整策略io

四.標準訪問控制列表的配置

建立ACL:

Router(config)#access-list accsee-list-number
    { permit容許數據包經過 | deny拒絕數據包經過 } source [ source-wildcard ]可對源IP進行控制

刪除ACL:

Router(config)#no access-list access-list-number

應用實例:

Router(config)# access-list 1 permit 192.168.1.0 0.0.0.255
Router(config)# access-list 1 permit 192.168.2.2 0.0.0.0
容許192.168.1.0/24和主機192.168.2.2的流量經過

隱含的拒絕語句:

Router(config)# access-list 1 deny 0.0.0.0 255.255.255.255

關鍵字:

host/any

Demo1:標準ACL的配置實例

在這裏插入圖片描述

交換機:
sw#conf t 
sw(config)#no ip routing
sw(config)#int f1/0
sw(config-if)#speed 100
sw(config-if)#dup full
路由器:
R1#conf t
R1(config)#int f0/0
R1(config-if)#ip add 192.168.10.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.20.1 255.255.255.0
R1(config-if)#no shut
客戶機配置IP地址:
PC1> ip 192.168.10.2 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1

PC2> ip 192.168.10.3 192.168.10.1 
Checking for duplicate address...
PC1 : 192.168.10.3 255.255.255.0 gateway 192.168.10.1

PC3> 
PC3> ip 192.168.20.2 192.168.20.1
Checking for duplicate address...
PC1 : 192.168.20.2 255.255.255.0 gateway 192.168.20.1
驗證互通:
PC1> ping 192.168.20.2           
192.168.20.2 icmp_seq=1 timeout
84 bytes from 192.168.20.2 icmp_seq=2 ttl=63 time=15.676 ms
84 bytes from 192.168.20.2 icmp_seq=3 ttl=63 time=17.680 ms
84 bytes from 192.168.20.2 icmp_seq=4 ttl=63 time=21.956 ms
84 bytes from 192.168.20.2 icmp_seq=5 ttl=63 time=12.700 ms

PC2> ping 192.168.20.2
192.168.20.2 icmp_seq=1 timeout
192.168.20.2 icmp_seq=2 timeout
84 bytes from 192.168.20.2 icmp_seq=3 ttl=63 time=17.735 ms
84 bytes from 192.168.20.2 icmp_seq=4 ttl=63 time=14.069 ms
84 bytes from 192.168.20.2 icmp_seq=5 ttl=63 time=14.960 ms

//此時全網段互通
全局模式下在R1上定義規則
R1(config-if)#access-list 1 deny host 192.168.10.2
R1(config)#do show access-list
R1(config)#access-list 1 permit any
R1(config)#int f0/0
R1(config-if)#ip access-group 1 in
PC1pingPC3顯示管理員拒絕:
PC1> ping 192.168.20.2
*192.168.10.1 icmp_seq=1 ttl=255 time=20.233 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=2 ttl=255 time=4.913 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=3 ttl=255 time=12.927 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=4 ttl=255 time=12.965 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=5 ttl=255 time=13.958 ms (ICMP type:3, code:13, Communication administratively prohibited)
PC1pingPC2能夠連通:
PC1>ping 192.168.10.3
84 bytes from 192.168.10.3 icmp_seq=1 ttl=64 time=0.000 ms
84 bytes from 192.168.10.3 icmp_seq=2 ttl=64 time=0.975 ms
84 bytes from 192.168.10.3 icmp_seq=3 ttl=64 time=0.997 ms
84 bytes from 192.168.10.3 icmp_seq=4 ttl=64 time=0.000 ms
84 bytes from 192.168.10.3 icmp_seq=5 ttl=64 time=1.731 ms
相關文章
相關標籤/搜索