訪問控制列表(Access Control Lists,簡稱ACL)是應用在路由器接口的指令列表。這些指令列表用來告訴路由器哪些數據包能夠收、哪些數據包須要拒絕。至於數據包是被接收仍是拒絕,能夠由相似於源地址、目的地址、端口號等的特定指示條件來決定。ACL讀取第三層、第四層包頭信息,並根據預先定義好的規則對包進行過濾。
安全
1.限制網絡流量、提升網絡性能
2.提供對通訊流量的控制手段
3.提供網絡訪問的基本安全手段
4.在網絡設備接口處,決定哪一種類型的通訊流量被轉發、哪一種類型的通訊流量被阻塞網絡
出方向:已通過路由器的處理,正離開路由器接口的數據包
入方向:已達到路由器接口的數據包,將被路由器處理
列表應用到接口方向與數據方向有關ide
ACL規則:匹配爲自上而下逐條匹配,默認隱含的拒絕是拒絕全部(any) 白名單 容許 1.2 容許 1.3 拒絕全部(可不寫,隱含的拒絕會拒絕全部) **黑名單** 拒絕 1.2 拒絕 1.3 容許全部(必須寫,不然隱含的拒絕會拒絕全部)
基於IP地址過濾數據包
標準訪問控制列表的訪問控制列表號是1~99性能
基於源IP、目標IP地址、指定協議、端口和標誌來過濾數據包
擴展訪問控制列表的訪問控制列表號是100~199測試
命名訪問控制列表容許在標準和擴展訪問控制列表中使用名稱待敵表號
調整安全策略相對靈活code
access-list access-list-number { permit | deny} source [source-wildcard ] //permit表示容許數據包經過 ,deny表示拒絕數據包經過 ,source [ source-wildcard ]只對源IP進行控制+(反子網掩碼)
範例演示blog
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的流量經過
no access-list access-list-number //直接刪除ACL列表號
access-list 1 deny 0.0.0.0 255.255.255.255 //拒絕全部ip
host //host後面可跟ip地址,免去子網掩碼的輸入 any //等同於拒絕全部ip
ip access-group access-list-number {in | out} //in定義於離控制方最近的端口
no ip access-group access-list-number {in | out}
1.首先配置交換機接口
conf t //進入全局模式 no ip routing //關閉路由功能 int f1/0 //進入端口f1/0 speed 100 //配置速率 dup full //配置全雙工模式
2.配置路由器R2ip
conf t int f0/0 ip add 192.168.10.1 255.255.255.0 //配置端口f0/0的IP地址 no shut nt f0/1 p add 192.168.20.1 255.255.255.0 //配置端口f0/1的IP地址 no shut do show ip route //查看路由表
3.PC機配置IP地址
(1)配置PC1的IP地址及網關路由
ip 192.168.10.2 192.168.10.1
(2)配置PC2的IP地址及網關
ip 192.168.10.3 192.168.10.1
(3)配置PC3的IP地址及網關
ip 192.168.20.2 192.168.20.1
4.測試PC機間的通信
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=31.242 ms 84 bytes from 192.168.20.2 icmp_seq=3 ttl=63 time=31.241 ms 84 bytes from 192.168.20.2 icmp_seq=4 ttl=63 time=31.243 ms 84 bytes from 192.168.20.2 icmp_seq=5 ttl=63 time=31.222 ms PC3> ping 192.168.10.3 192.168.10.3 icmp_seq=1 timeout 84 bytes from 192.168.10.3 icmp_seq=2 ttl=63 time=31.518 ms 84 bytes from 192.168.10.3 icmp_seq=3 ttl=63 time=31.266 ms 84 bytes from 192.168.10.3 icmp_seq=4 ttl=63 time=31.263 ms 84 bytes from 192.168.10.3 icmp_seq=5 ttl=63 time=31.244 ms
5.在路由器R1上建立ACL並使用在f0/0端口
access-list 1 deny host 192.168.10.2 //拒絕ip爲192.168.10.2 的主機訪問 access-list 1 permit any //容許其餘全部ip訪問 int f0/0 ip access-group 1 in //將ACL應用與f0/0端口的入方向 do show access-list //查看ACL列表
6.驗證ACL配置
(1)測試PC1與PC3 通信
PC1> ping 192.168.20.2 *192.168.10.1 icmp_seq=1 ttl=255 time=31.223 ms (ICMP type:3, code:13, Communication administratively prohibited) *192.168.10.1 icmp_seq=2 ttl=255 time=15.618 ms (ICMP type:3, code:13, Communication administratively prohibited) *192.168.10.1 icmp_seq=3 ttl=255 time=15.621 ms (ICMP type:3, code:13, Communication administratively prohibited) *192.168.10.1 icmp_seq=4 ttl=255 time=15.622 ms (ICMP type:3, code:13, Communication administratively prohibited) *192.168.10.1 icmp_seq=5 ttl=255 time=15.620 ms (ICMP type:3, code:13, Communication administratively prohibited)
結論:發現沒法通信並提示通信被管理方禁止,ACL生效
(2)測試PC1 與PC2 通信
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.000 ms 84 bytes from 192.168.10.3 icmp_seq=3 ttl=64 time=0.000 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=0.000 ms
結論:局域網內部不受ACL限制,能夠正常通信