应用高级ACL配置流分类示例
组网需求
如图3-6所示,公司企业网通过Switch实现各部门之间的互连。要求正确配置ACL,禁止研发部门和市场部门在上班时间(8:00至17:30)访问工资查询服务器(IP地址为10.164.9.9),而总裁办公室不受限制,可以随时访问。
操作步骤
- 配置接口加入VLAN,并配置VLANIF接口的IP地址
# 规划10GE1/0/1~10GE1/0/3分别加入VLAN10、20、30,10GE2/0/1加入VLAN100。VLANIF接口的地址取所在网段的第一个IP地址。下面配置以10GE1/0/1和VLANIF 10接口为例,接口10GE1/0/2、10GE1/0/3和10GE2/0/1的配置与10GE1/0/1接口类似,接口VLANIF 20、VLANIF 30和VLANIF 100的配置与接口VLANIF 10类似,不再赘述。
<HUAWEI> system-view [~HUAWEI] sysname Switch [*HUAWEI] commit [~Switch] vlan batch 10 20 30 100 [*Switch] interface 10ge 1/0/1 [*Switch-10GE1/0/1] port link-type access [*Switch-10GE1/0/1] port default vlan 10 [*Switch-10GE1/0/1] commit [~Switch-10GE1/0/1] quit [~Switch] interface vlanif 10 [*Switch-Vlanif10] ip address 10.164.1.1 255.255.255.0 [*Switch-Vlanif10] quit
- 配置时间段
# 配置8:00至17:30的周期时间段。
[*Switch] time-range satime 8:00 to 17:30 working-day
- 配置ACL
# 配置市场部门到工资查询服务器的访问规则。
[*Switch] acl 3002 [*Switch-acl4-advance-3002] rule permit ip source 10.164.2.0 0.0.0.255 destination 10.164.9.9 0.0.0.0 time-range satime [*Switch-acl4-advance-3002] commit [~Switch-acl4-advance-3002] quit
# 配置研发部门到工资查询服务器的访问规则。
[~Switch] acl 3003 [*Switch-acl4-advance-3003] rule permit ip source 10.164.3.0 0.0.0.255 destination 10.164.9.9 0.0.0.0 time-range satime [*Switch-acl4-advance-3003] commit [~Switch-acl4-advance-3003] quit
- 配置基于ACL的流分类
# 配置流分类c_market,对匹配ACL 3002的报文进行分类。
[~Switch] traffic classifier c_market [*Switch-classifier-c_market] if-match acl 3002 [*Switch-classifier-c_market] commit [~Switch-classifier-c_market] quit
# 配置流分类c_rd,对匹配ACL 3003的报文进行分类。
[~Switch] traffic classifier c_rd [*Switch-classifier-c_rd] if-match acl 3003 [*Switch-classifier-c_rd] commit [~Switch-classifier-c_rd] quit
- 配置流行为
# 配置流行为b_market,动作为拒绝报文通过。
[~Switch] traffic behavior b_market [*Switch-behavior-b_market] deny [*Switch-behavior-b_market] commit [~Switch-behavior-b_market] quit
# 配置流行为b_rd,动作为拒绝报文通过。
[~Switch] traffic behavior b_rd [*Switch-behavior-b_rd] deny [*Switch-behavior-b_rd] commit [~Switch-behavior-b_rd] quit
- 配置流策略
# 配置流策略p_market,将流分类c_market与流行为b_market关联。
[~Switch] traffic policy p_market [*Switch-trafficpolicy-p_market] classifier c_market behavior b_market [*Switch-trafficpolicy-p_market] commit [~Switch-trafficpolicy-p_market] quit
# 配置流策略p_rd,将流分类c_rd与流行为b_rd关联。
[~Switch] traffic policy p_rd [*Switch-trafficpolicy-p_rd] classifier c_rd behavior b_rd [*Switch-trafficpolicy-p_rd] commit [~Switch-trafficpolicy-p_rd] quit
- 应用流策略
# 将流策略p_market应用到10GE1/0/2接口。
[~Switch] interface 10ge 1/0/2 [~Switch-10GE1/0/2] traffic-policy p_market inbound [*Switch-10GE1/0/2] commit [~Switch-10GE1/0/2] quit
# 将流策略p_rd应用到10GE1/0/3接口。
[~Switch] interface 10ge 1/0/3 [~Switch-10GE1/0/3] traffic-policy p_rd inbound [*Switch-10GE1/0/3] commit [~Switch-10GE1/0/3] quit
- 验证配置结果
# 查看ACL规则的配置信息。
[~Switch] display acl all Total nonempty ACL number is 2 Advanced ACL 3002, 1 rule ACL's step is 5 rule 5 permit ip source 10.164.2.0 0.0.0.255 destination 10.164.9.9 0 time-range satime(Inactive) (0 times matched) Advanced ACL 3003, 1 rule ACL's step is 5 rule 5 permit ip source 10.164.3.0 0.0.0.255 destination 10.164.9.9 0 time-range satime(Inactive) (0 times matched)
# 查看流分类的配置信息。
[~Switch] display traffic classifier Traffic Classifier Information: Classifier: c_market Type: OR Rule(s): if-match acl 3002 Classifier: c_rd Type:OR Rule(s): if-match acl 3003 Total classifier number is 2
# 查看流策略的配置信息。
[~Switch] display traffic policy Traffic Policy Information: Policy: p_market Classifier: c_market Type: OR Behavior: b_market Deny Policy: p_rd Classifier: c_rd Type: OR Behavior: b_rd Deny Total policy number is 2
[~Switch] display traffic-policy applied-record Total records : 2 ------------------------------------------------------------------------------- Policy Type/Name Apply Parameter Slot State ------------------------------------------------------------------------------- p_market 10GE1/0/2(IN) 1 success ------------------------------------------------------------------------------- p_rd 10GE1/0/3(IN) 1 success -------------------------------------------------------------------------------
配置文件
# Switch的配置文件
# sysname Switch # vlan batch 10 20 30 100 # time-range satime 08:00 to 17:30 working-day # acl number 3002 rule 5 permit ip source 10.164.2.0 0.0.0.255 destination 10.164.9.9 0 time-range satime # acl number 3003 rule 5 permit ip source 10.164.3.0 0.0.0.255 destination 10.164.9.9 0 time-range satime # traffic classifier c_market type or if-match acl 3002 # traffic classifier c_rd type or if-match acl 3003 # traffic behavior b_market deny # traffic behavior b_rd deny # traffic policy p_market classifier c_market behavior b_market precedence 5 # traffic policy p_rd classifier c_rd behavior b_rd precedence 5 # interface Vlanif10 ip address 10.164.1.1 255.255.255.0 # interface Vlanif20 ip address 10.164.2.1 255.255.255.0 # interface Vlanif30 ip address 10.164.3.1 255.255.255.0 # interface Vlanif100 ip address 10.164.9.1 255.255.255.0 # interface 10GE1/0/1 port default vlan 10 # interface 10GE1/0/2 port default vlan 20 traffic-policy p_market inbound # interface 10GE1/0/3 port default vlan 30 traffic-policy p_rd inbound # interface 10GE2/0/1 port default vlan 100 # return