---- 标准型IP访问列表的格式如下:
---- access-list[list number][permit|deny][source address]
---- [address][wildcard mask][log]
---- 下面解释一下标准型IP访问列表的关键字和参数。首先,在access和list这2个
---- (2)允许/拒绝数据包通过
---- 在标准型IP访问列表中,使用permit语句可以使得和访问列表项目匹配的数据包
---- 为了更好地了解IP地址和通配符掩码的作用,这里举一个例子。假设您的公司有
---- access-list 1 permit 192.46.28.0 0.0.0.255
---- 注意,通配符掩码是子网掩码的补充。因此,如果您是网络高手,您可以先确定
---- (3)指定地址
---- 如果您想要指定一个特定的主机,可以增加一个通配符掩码0.0.0.0。例如,为
---- Access-list 1 permit 192.46.27.7 0.0.0.0
---- 在Cisco的访问列表中,用户除了使用上述的通配符掩码0.0.0.0来指定特定的主
---- Access-list 1 permit host 192.46.27.7
---- 除了可以利用关键字"host"来代表通配符掩码0.0.0.0外,关键字"any"可以作为
---- Access-list 1 deny host 192.46.27.8
---- Access-list 1 permit any
---- 注意上述2条访问列表语句的次序。第1条语句把来自源地址为192.46.27.8的数
---- Access-list 1 permit any
---- 的话,那么来自任何源地址的数据包都会通过接口。
---- (4)拒绝的奥秘
---- 在默认情况下,除非明确规定允许通过,访问列表总是阻止或拒绝一切数据包的
---- access-list 1 deny host 192.46.27.8
---- access-list 1 permit any
---- access-list 1 deny any
---- 在上述例子里面,由于访问列表中第2条语句明确允许任何数据包都通过,所以
---- access-list 1 permit host 192.46.27.8
---- access-list 1 permit host 192.46.27.12
---- 注意,因为所有的访问列表会自动在最后包括该语句.
---- 顺便讨论一下标准型IP访问列表的参数"log",它起日志的作用。一旦访问列表
扩展型IP访问列表
---- 扩展型IP访问列表在数据包的过滤方面增加了不少功能和灵活性。除了可以基于
---- access-list[list number][permit|deny]
---- [protocol|protocol key word]
---- [source address source-wildcard mask][source port]
---- [destination address destination-wildcard mask]
---- [destination port][log options]
---- 和标准型IP访问列表类似,"list number"标志了访问列表的类型。数字100~
---- 如果我们回顾一下数据包是如何形成的,我们就会了解为什么协议会影响数据包
---- 为了更好地说明,下面列举2个扩展型IP访问列表的语句来说明。假设我们希望
---- access-list 101 permit host 192.78.46.8
---- access-list 101 deny host 192.78.46.12
---- 回答是否定的。第一条语句允许所有的IP流量、同时包括TCP流量通过指定的主
反向访问列表
有5个VLAN,分别为 管理(63)、办公(48)、业务(49)、财务(50)、家庭(51)。
要求: 管理可以访问其它,而其它不能访问管理,并且其它VLAN之间不能互相访问!
其它的应用不受影响,例如通过上连进行INTERNET的访问
方法一: 只在管理VLAN的接口上配置,其它VLAN接口不用配置。
在入方向放置reflect
ip access-list extended infilter
permit ip any any reflect cciepass
!
在出方向放置evaluate
ip access-list extended outfilter
evaluate cciepass
deny ip 10.54.48.0 0.0.0.255 any
deny ip 10.54.49.0.0.0.0.255 any
deny ip 10.54.50.0 0.0.0.255 any
deny ip 10.54.51.0 0.0.0.255 any
permit ip any any
!应用到管理接口
int vlan 63
ip access-group infilter in
ip access-group outfilter out
方法二:在管理VLAN接口上不放置任何访问列表,而是在其它VLAN接口都放。
以办公VLAN为例:
在出方向放置reflect
ip access-list extended outfilter
permit ip any any reflect cciepass
!
在入方向放置evaluate
ip access-list extended infilter
deny ip 10.54.48.0 0.0.0.255 10.54.49.0 0.0.0.255
deny ip 10.54.48.0 0.0.0.255 10.54.50.0 0.0.0.255
deny ip 10.54.48.0 0.0.0.255 10.54.51.0 0.0.0.255
deny ip 10.54.48.0 0.0.0.255 10.54.63.0 0.0.0.255
evaluate cciepass
permit ip any any
!
应用到办公VLAN接口:
int vlan 48
ip access-group infilter in
ip access-group outfilter out
总结:
1) Reflect放置在允许的方向上(可进可出)
2) 放在管理VLAN上配置简单,但是不如放在所有其它VLAN上直接。
3) 如果在内网口上放置: 在入上设置Reflect
如果在外网口上放置: 在出口上放置Reflect
LAN WAN
-
inbound outbound
4)reflect不对本地路由器上的数据包跟踪,所以对待进入的数据包时注意,要允许一些
从IOS12.0开始,CISCO路由器新增加了一种基于时间的访问列表。通过它,可以根据一天
一、使用方法
这种基于时间的访问列表就是在原来的标准访问列表和扩展访问列表中加入有效的时
二、使用规则
用time-range 命令来指定时间范围的名称,然后用absolute命令或者一个或多个
IOS命令格式为:
time-range time-range-name absolute [start time date] [end time date]
我们分别来介绍下每个命令和参数的详细情况
time-range : 用来定义时间范围的命令
time-range-name:时间范围名称,用来标识时间范围,以便于在后面的访问列表中引
absolute: 该命令用来指定绝对时间范围。它后面紧跟这start和 end两个关键字。
怎么样,看明白了吗?上面讲的就是命令和基本参数为了便于理解,我们看两个例子
1、如果要表示每天的早8点到晚8点就可以用这样的语句:
absolute start 8:00 end 20:00
2、再如,我们要使一个访问列表从2006年10月1日早5点开始起作用,直到2006年10月
absolute start 5:00 1 December 2000 end 24:00 31 December 2000
这样一来,我们就可以用这种基于时间的访问列表来实现,而不用半夜跑到办公室去
periodic:主要是以星期为参数来定义时间范围的一个命令。它的参数主要有宾
示例一: 带Established选项的扩展访问列表
带有Established的扩展访问列表允许内部用户访问外部网络,而拒绝外部网络访问内部网
这个示例首先用OSPF来使全网互联.
*Mar 1 00:25:17.275: %SYS-5-CONFIG_I: Configured from console by console
Building configuration...
!
version 12.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r1
!
logging queue-limit 100
!
ip subnet-zero
!
!
!
ip audit notify log
ip audit po max-events 100
mpls ldp logging neighbor-changes
!
!
!
!
!
!
!
!
!
!
!
!
no voice hpi capture buffer
no voice hpi capture destination
!
!
mta receive maximum-recipients 0
!
!
!
!
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial2/0
ip address 12.1.1.1 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-point
serial restart_delay 0
frame-relay map ip 12.1.1.2 102 broadcast
no frame-relay inverse-arp
!
interface Serial2/1
ip address 13.1.1.1 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-point
serial restart_delay 0
frame-relay map ip 13.1.1.3 113 broadcast
!
interface Serial2/2
no ip address
shutdown
serial restart_delay 0
!
interface Serial2/3
no ip address
shutdown
serial restart_delay 0
!
router ospf 10
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
call rsvp-sync
!
!
mgcp profile default
!
!
!
dial-peer cor custom
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
no login
!
!
end
R2:
Building configuration...
Current configuration : 1298 bytes
!
version 12.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r2
!
logging queue-limit 100
!
ip subnet-zero
!
!
!
ip audit notify log
ip audit po max-events 100
mpls ldp logging neighbor-changes
!
!
!
!
!
!
!
!
!
!
!
!
no voice hpi capture buffer
no voice hpi capture destination
!
!
mta receive maximum-recipients 0
!
!
!
!
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial2/0
ip address 12.1.1.2 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-point
serial restart_delay 0
frame-relay map ip 12.1.1.1 201 broadcast
no frame-relay inverse-arp
!
interface Serial2/1
no ip address
shutdown
serial restart_delay 0
!
interface Serial2/2
no ip address
shutdown
serial restart_delay 0
!
interface Serial2/3
no ip address
shutdown
serial restart_delay 0
!
router ospf 10
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
call rsvp-sync
!
!
mgcp profile default
!
!
!
dial-peer cor custom
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
no login
!
!
end
Building configuration...
!
version 12.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname r3
!
logging queue-limit 100
!
ip subnet-zero
!
!
!
ip audit notify log
ip audit po max-events 100
mpls ldp logging neighbor-changes
!
!
!
!
!
!
!
!
!
!
!
!
no voice hpi capture buffer
no voice hpi capture destination
!
!
mta receive maximum-recipients 0
!
!
!
!
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial2/0
no ip address
shutdown
serial restart_delay 0
!
interface Serial2/1
ip address 13.1.1.3 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-point
serial restart_delay 0
frame-relay map ip 13.1.1.1 311 broadcast
no frame-relay inverse-arp
!
interface Serial2/2
no ip address
shutdown
serial restart_delay 0
!
interface Serial2/3
no ip address
shutdown
serial restart_delay 0
!
router ospf 10
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
ip http server
no ip http secure-server
ip classless
!
!
!
!
!
call rsvp-sync
!
!
mgcp profile default
!
!
!
dial-peer cor custom
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
no login
!
!
end
监视和测试配置:
R1(configure)access-list 101 permit ospf any any
R1(configure)access-list 101 deny ip any any log-input
R1(configure)int s2/1
R1(configure-if)ip access-group 101 in
r1#telnet 3.3.3.3
Trying 3.3.3.3 ... Open
*Mar 1 00:55:53.003: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.003: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 44,
*Mar 1 00:55:53.007: TCP src=11001, dst=23, seq=2398697781, ack=0, win=4128 SYN
*Mar 1 00:55:53.179: %SEC-6-IPACCESSLOGP: list 101 permitted tcp 3.3.3.3(23)
*Mar 1 00:55:53.183: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.183: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 44,
*Mar 1 00:55:53.187: TCP src=23, dst=11001, seq=949632690, ack=2398697782,
*Mar 1 00:55:53.187: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.191: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 40,
*Mar 1 00:55:53.191: TCP src=11001, dst=23, seq=2398697782, ack=949632691,
*Mar 1 00:55:53.199: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.203: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 49,
*Mar 1 00:55:53.203: TCP src=11001, dst=23, seq=2398697782, ack=949632691,
*Mar 1 00:55:53.207: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.211: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 40,
*Mar 1 00:55:53.215: TCP src=11001, dst=23, seq=2398697791, ack=949632691,
*Mar 1 00:55:53.455: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.455: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 52,
*Mar 1 00:55:53.459: TCP src=23, dst=11001, seq=949632691, ack=2398697791,
*Mar 1 00:55:53.459: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.463: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 45,
*Mar 1 00:55:53.467: TCP src=23, dst=11001, seq=949632703, ack=2398697791,
*Mar 1 00:55:53.467: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.471: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 43,
*Mar 1 00:55:53.471: TCP src=23, dst=11001, seq=949632708, ack=2398697791,
*Mar 1 00:55:53.475: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.479: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 46,
*Mar 1 00:55:53.479: TCP src=23, dst=11001, seq=949632711, ack=2398697791,
*Mar 1 00:55:53.483: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.487: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 43,
*Mar 1 00:55:53.487: TCP src=11001, dst=23, seq=2398697791, ack=949632717,
*Mar 1 00:55:53.491: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.495: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 43,
*Mar 1 00:55:53.495: TCP src=11001, dst=23, seq=2398697794, ack=949632717,
*Mar 1 00:55:53.499: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.503: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 49,
*Mar 1 00:55:53.503: TCP src=11001, dst=23, seq=2398697797, ack=949632717,
*Mar 1 00:55:53.659: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.663: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 43,
*Mar 1 00:55:53.663: TCP src=23, dst=11001, seq=949632717, ack=2398697797,
*Mar 1 00:55:53.867: IP: tableid=0, s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1),
*Mar 1 00:55:53.867: IP: s=13.1.1.1 (local), d=3.3.3.3 (Serial2/1), len 40,
*Mar 1 00:55:53.871: TCP src=11001, dst=23, seq=2398697806, ack=949632720,
*Mar 1 00:55:53.963: IP: tableid=0, s=3.3.3.3 (Serial2/1), d=13.1.1.1
*Mar 1 00:55:53.967: IP: s=3.3.3.3 (Serial2/1), d=13.1.1.1 (Serial2/1), len 40,
*Mar 1 00:55:53.967: TCP src=23, dst=11001, seq=949632720, ack=2398697806,
注意R3返回R2的数据报文得以通过,接下来我们测试从R3发起访问R2的情况
r3#telnet 2.2.2.2
Trying 2.2.2.2 ...
% Destination unreachable; gateway or host down
r1#
*Mar 1 01:02:22.779: %SEC-6-IPACCESSLOGP: list 101 denied tcp 13.1.1.3(11002)
*Mar 1 01:02:22.783: IP: s=13.1.1.3 (Serial2/1), d=2.2.2.2, len 44, access
*Mar 1 01:02:22.783: IP: tableid=0, s=13.1.1.1 (local), d=13.1.1.3 (Serial2/1),
*Mar 1 01:02:22.787: IP: s=13.1.1.1 (local), d=13.1.1.3 (Serial2/1), len 56,
*Mar 1 01:02:24.139: IP: s=12.1.1.2 (Serial2/0), d=224.0.0.5, len 80, rcvd 0
*Mar 1 01:02:24.315: IP: s=13.1.1.1 (local), d=224.0.0.5 (Serial2/1), len 80,
*Mar 1 01:02:25.139: IP: s=12.1.1.1 (local), d=224.0.0.5 (Serial2/0), len 80,
reflect+evalute实现单向访问控制列表的最新实验结果
ip address 10.147.18.92 255.255.255.240
ip access-group in-filter in
ip access-group out-filter out
ip helper-address 10.147.17.193
no ip redirects
standby 12 ip 10.147.18.94
standby 12 priority 150
standby 12 preempt
ip access-list extended in-filter
evaluate abcd
deny ip any any
ip access-list extended out-filter
permit ip any any reflect abcd
结果从VLAN12上的客户机ping其它VLAN的机器,提示:
Reply from 10.147.18.92: Destination net unreachable.
将上面的访问控制列表改为:
ip access-list extended in-filter
permit ip any any reflect abcd
ip access-list extended out-filter
evaluate abcd
deny ip any any
结果从VLAN12的客户机可以ping通其它vlan的机器,但其它vlan的机器ping不通vlan12的机
观察发现,我从vlan12的客户机上ping 其它vlan里面的任何一台机器的话,就会自动生成一
记录如下:
Reflexive IP access list abcd
permit icmp host 10.147.17.251 host 10.147.18.90 (8 matches) (time left 297)
permit udp host 202.96.170.163 eq 8000 host 10.147.18.90 eq 4000 (6 matches)
permit udp host 224.0.0.2 eq 1985 host 10.147.18.93 eq 1985 (155 matches) (time
Extended IP access list in-filter
permit ip any any reflect abcd
Extended IP access list out-filter
evaluate abcd
deny ip any any (289 matches)
将访问控制列表改为:
ip access-list extended in-filter
permit ip any any reflect abcd
ip access-list extended out-filter
evaluate abcd
permit ip 10.147.16.0 0.0.0.128 any
deny ip any any
结果一开始几分钟内,除了定义的VLAN2(10.147.16.0/255.255.255.128)外,其它vlan的机
后来就全部PING
不通,和第二次开发步的结果相同
我用你的方法在cisco3560交换机上测试,应用acl后,双方向都不通了。分析一下怎么回
4号口划分到vlan3,48号口划分到vlan2
Building configuration...
Current configuration : 2724 bytes
!
version 12.2
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Switch
!
!
no aaa new-model
ip subnet-zero
ip routing
!
!
!
!
no file verify auto
spanning-tree mode pvst
spanning-tree portfast default
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
interface GigabitEthernet0/4
switchport access vlan 3
!
...........
interface GigabitEthernet0/48
switchport access vlan 2
!
...........
!
interface Vlan1
no ip address
!
interface Vlan2
ip address 10.10.10.1 255.255.255.0
!
interface Vlan3
ip address 192.9.200.253 255.255.255.0
ip access-group in-control in
ip access-group out-control out
!
ip classless
ip http server
!
ip access-list extended in-control
permit ip any any reflect test
ip access-list extended out-control
evaluate test
deny ip 10.10.10.0 0.0.0.255 any
permit ip any any
!
!
control-plane
!
!
line con 0
line vty 0 4
no login
line vty 5 15
no login
!
end