1.实验要求:用ACL实现下图的要求
2.配置图中设备:
<R1>dis curr
[V200R003C00]
#
sysname R1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
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-por
t eq telnet
rule 20 deny tcp source 192.168.1.3 0 destination 192.168.1.1 0 destination-por
t eq telnet
rule 25 deny tcp source 192.168.1.3 0 destination 192.168.2.1 0 destination-por
t eq telnet
rule 30 deny icmp source 192.168.1.3 0 destination 192.168.2.2 0
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$oq#-,JXWRBF=}iQ2\q.@^(s/%$%$
local-user admin privilege level 15
local-user admin service-type telnet
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.1.1 255.255.255.0
traffic-filter inbound acl 3000
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
authentication-mode aaa
user-interface vty 16 20
#
wlan ac
#
return
<R2>dis curr
[V200R003C00]
#
sysname R2
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$_qA|D!n'sKMN89RkTbUK^),;%$%$
local-user admin privilege level 15
local-user admin service-type telnet
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 192.168.2.2 255.255.255.0
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 192.168.2.1
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
authentication-mode aaa
user-interface vty 16 20
#
wlan ac
#
return
[PC1]int g0/0/0
#
interface GigabitEthernet0/0/0
ip address 192.168.1.2 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
[PC2]int g0/0/0
#
interface GigabitEthernet0/0/0
ip address 192.168.1.3 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
注:华为默认最后一条是允许所有流量通过,而Cisco默认最后一条是拒绝所有流量通过
3.测试
PC2测试方法类似
ACL扩展知识:
1.标准ACL——因为只匹配流量中的源IP地址,故调用时为避免误删,尽量靠近目标
2.扩展ACL——因为扩展ACL可以清楚地标记目标,故调用时建议尽量的靠近源
* ACL使用的是通配符,ospf使用的是反掩码;两者区别在于通配符可以0、1穿插着写
* ACL在定制完成后,必须到接口上进行调用才能生效
ACL最好写法有两种,如果一条允许一条拒绝的写,这样会增加匹配时间,无形中造成流量在进或者出的时候排队,增加网络延时
第一种:前面写要求允许通过的流量,最后写一条拒绝所有流量通过
第二种:前面写要求拒绝通过的流量,最后写一条允许所有流量通过(本实验用的是第二种)
*华为默认最后一条是允许所有流量通过,而Cisco默认最后一条是拒绝所有流量通过