一、扩展ACL的基本命令
1.关注数据包中的源、目标ip地址
[R1]acl 3000
[R1-acl-adv-3000]rule deny ip source 192.168.1.2 0.0.0.0 destination 192.168.3.2 0.0.0.0
源ip地址 目标地址
源、目ip地址均使用使用通配符标定范围,或any代表所有;切记表格调用到接口方可生效;
2.关注数据包中的源、目标ip地址,以及目标端口号
[r1]acl 3000
[r1-acl-adv-3000]rule deny tcp source 192.168.1.2 0.0.0.0 destination 192.168.2.2 0.0.0.0 destination-port eq 23
以上规则拒绝了192.168.1.2 对192.168.2.2 的tcp下目标端口23访问-- 拒绝telnet
[r1-acl-adv-3001]rule deny icmp source 192.168.1.2 0.0.0.0 destination 192.168.2.2 0.0.0.0
拒绝192.168.1.2 对192.168.2.2的ICMP访问--拒绝ping
3.规则编写完成后,必须在接口调用后方可生效
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]traffic-filter ? 调用时一定注意方向
inbound Apply ACL to the inbound direction of the interface
outbound Apply ACL to the outbound direction of the interface
[R2-GigabitEthernet0/0/1]traffic-filter outbound acl 2001
二、实验
1.实验步骤
首先将路由器和PC端的IP地址配好,然后配AR2的路由,满足全网可达。
根据题目要求可知,应在AR1和AR2上实现远程登录。然后在AR1 的GE0/0/1口实现题目要求。
2.部分代码
部分IP配法:
[r1-GigabitEthernet0/0/1]ip address 192.168.1.1 24
[r2]ip route-static 192.168.1.0 24 192.168.2.1
远程登录:
[r1]aaa
[r1-aaa]local-user chenlanyan privilege level 15 password cipher 123456
Info: Add a new user.
[r1-aaa]local-user chenlanyan service-type telnet
[r1]user-interface vty 0 4
[r1-ui-vty0-4]authentication-mode aaa
扩展ACL:
acl number 3000
rule 5 deny icmp source 192.168.1.2 0 destination 192.168.1.1 0
rule 10 deny icmp source 192.168.1.2 0 destination 192.168.2.1 0
rule 15 deny tcp source 192.168.1.2 0 destination 192.168.2.2 0 destination-port eq telnet
rule 20 deny tcp source 192.168.1.3 0 destination 192.168.1.1 0 destination-port eq telnet
rule 25 deny tcp source 192.168.1.3 0 destination 192.168.2.1 0 destination-port eq telnet
rule 30 deny icmp source 192.168.1.3 0 destination 192.168.2.2 0
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]traffic-filter inbound acl 3000
3.验证
PC1可以登录R1,不能PING通R1
PC1可以PING通R2,不能登录R2:
PC2的验证结果就不予展示,通PC1结果相反,实验完成。