扩展ACL

扩展ACL:
能够同时匹配IP数据包的(源IP 目标IP) 传输层协议

IP-ACL(3层ACL,针对的是3层流量)
扩展ACL匹配流量,更加精确:
     确定流量的唯一5元组:
         源IP、目标IP、源端口、目标端口、传输层协议。
     对数据而言,凡是能够通过“传输层协议+端口号”的方式
     进行表示的,则表示该数据是属于“应用层”。
     路由器查找路由表时,有一个最长匹配原则,
        匹配的越长,表示地址越精确。

实验名称:扩展ACL的原理与应用
实验拓扑:

实验需求:
R1可以ping通R4;
R1的 loopback 10 无法 telnet R4 ;
实验步骤:
1、确保网络互通
基于拓扑图,配置设备端口地址;
配置静态路由,确保网段互通;
&默认路由: 0.0.0.0 0.0.0.0 -> 0.0.0.0/0 ,表示所有网络。

2、配置ACL策略              
           想要抓取一个流量
           必须了解一个流量

            配置命令:(R2)
               ip access-list extended Deny-telnet
                     10  deny   tcp 10.10.1.0 0.0.0.255 10.10.4.0 0.0.0.255 eq telnet
                     20  deny   tcp 10.10.1.0 0.0.0.255 192.168.34.0 0.0.0.255 eq telnet
                     30  permit ip any any


或者

               ip access-list extended Deny-telnet
                     10  deny   tcp 10.10.1.1 0.0.0.0 10.10.4.4 0.0.0.0 eq telnet
                     20  deny   tcp 10.10.1.1 0.0.0.0 192.168.34.4 0.0.0.0 eq telnet
                     30  permit ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255

3、调用ACL策略
          R2:
             interface fas0/1
                ip access-group Deny-telnet in 
4、验证ACL策略
           R2: 
              show ip access-list 
              show ip interface fas0/1 
           R1:
              telnet 10.10.4.4 /source-interface loopback 0 -> no 
              telnet 192.168.34.4 /source-interface loopback 0 -> no
              其他所有地址之间的所有类型流量,都是通的。                   

注意: 
ACL不会对本地设备发起的流量起作用,仅仅对穿越流量起作用;
实验过程:
R1>en
R1#conf
R1#configure t
R1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#no shu
R1(config-if)#ip add 192.
Dec 11 20:51:01.215: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
Dec 11 20:51:02.215: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#exit
R1(config)#int l
R1(config)#int loopback 10
R1(config-if)#ip add 10.10.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#ip routing
R1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#no ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.12.2
R1(config)#exit
R1#ping 192.168.34.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.34.4, timeout is 2 seconds:
...!!
Success rate is 40 percent (2/5), round-trip min/avg/max = 88/90/92 ms
R1#ping 192.168.34.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.34.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 100/135/192 ms
R1# telnet 10.10.4.4 /source-interface loopback 10
Trying 10.10.4.4 ... 
% Connection timed out; remote host not responding

R2>
R2>en
R2#conf
R2#configure t
R2#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/1
R2(config-if)#no shu
R2(config-if)#ip add 
Dec 11 20:55:18.379: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
Dec 11 20:55:19.379: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config-if)#ip add 192.168.12.2 255.255.255.0 
R2(config-if)#exit
R2(config)#int f0/0
R2(config-if)#no shu
R2(config-if)#ip add 192.168.23.2 255.255.255.0 
R2(config-if)#exit
R2(config)#ip routing
R2(config)#ip route 192.168.34.0 255.255.255.0 192.168.23.3
R2(config)#ip route 10.10.1.0 255.255.255.0 192.168.23.3 
R2(config)#ip route 10.10.4.0 255.255.255.0 192.168.23.3
R2(config)#exit 
R2#conf
R2#configure t
R2#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip access-list extended deny-telnet(设置扩展ACL拒绝远程访问)
R2(config-ext-nacl)#10 deny tcp 10.10.1.1 0.0.0.0 10.10.4.4 0.0.0.0 eq 23 (拒绝 tcp是第7层应用层,源主机 精确位数 目标主机 精确位数 eq是等于 协议telnet或23是知名端口)
R2(config-ext-nacl)#20 deny tcp 10.10.1.1 0.0.0.0 192.168.34.0 0.0.0.255 eq$ 10.10.1.1 0.0.0.0 192.168.34.0 0.0.0.255 eq 23 
R2(config-ext-nacl)#30 permit ip any any(允许所有)
R2(config-ext-nacl)#exit
R2(config)#int fas0/1
R2(config-if)#ip acces
R2(config-if)#ip access-group deny-telnet in(对应端口)
R2(config-if)#exit
R2(config)#

R3>en
R3#conf
R3#configure t
R3#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int f0/1
R3(config-if)#no shu 
R3(config-if)#ip add 192.168.23.3 255.255.255.0 
R3(config-if)#exit
R3(config)#int f0/0
R3(config-if)#no shu
R3(config-if)#ip add 192.168.34.3 255.255.255.0
R3(config-if)#exit
R3(config)#ip routing
R3(config)#ip route 192.168.12.0 255.255.255.0 192.168.23.2
R3(config)#ip route 10.10.1.0 255.255.255.0 192.168.23.2 
R3(config)#ip route 10.10.4.0 255.255.255.0 192.168.34.4

R4>en
R4#conf
R4#configure t
R4#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int f0/0
R4(config-if)#no shu
R4(config-if)#ip add 192.168.34.4 255.255.255.0 
R4(config-if)#exit 
R4(config)#int l
R4(config)#int loopback 20 (虚拟端口,回环)
R4(config-if)#ip add 10.10.4.4 255.255.255.0
R4(config-if)#exit
R4(config)#ip routing
R4(config)#ip route 0.0.0.0 0.0.0.0 192.168.34.3
R4(config)#ena
R4(config)#enable p
R4(config)#enable password 123 
R4(config)#li
R4(config)#line vt
R4(config)#line vty 0 4 (设置远程访问)
R4(config-line)#pass
R4(config-line)#password 123456
R4(config-line)#



本文转自 linuxpp 51CTO博客,原文链接:http://blog.51cto.com/13505118/2049982,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值