天天看点

校园网出口网关配置

论坛的小伙伴们,大家好。强叔刚刚从某著名高校开局归来,气儿还没喘匀,就为大家伏案写下这篇经典的校园网出口网关配置。墨迹未干,就此奉上~

这篇案例来源于此次开局的真实组网,是真实组网的“微缩改造”版。但这丝毫不影响这篇案例的真实性和实用性,各位准备部署校园网出口网关的小伙伴们可以尽情参考噢~

——————————本案例很长,但看完一定会有收获——————————————

【组网需求】

如图所示,防火墙(USG9560 V300R001C20版本)作为网关部署在学校网络出口。

校园网出口网关配置

学校的具体需求如下:

1、 为了保证内网用户的上网体验,学校希望去往特定目的地址的流量能够通过特定的ISP链路转发。例如,去往ISP1的服务器的流量能够通过ISP1提供的链路转发,去往ISP2的服务器的流量能够通过ISP2提供的链路转发,去往教育网服务器的流量能够通过教育网链路转发。

另外学校希望特定内网用户的流量能够通过特定的ISP链路转发。例如图书馆的上网流量能够通过教育网链路转发。

2、 学校内部署了提供对外访问的服务器,供多个ISP的用户访问。例如学校网站主页、邮件、Portal等服务器。

学校内还部署了DNS服务器为以上服务器提供域名解析。学校希望各ISP的外网用户能够解析到自己ISP的地址,从而提高访问服务器的速度。

3、 学校希望USG能够保护内部网络,防止SYN-flood攻击,并对网络入侵行为进行告警。

4、 学校希望限制P2P流量,包括每个用户的P2P流量,以及网络总体的P2P流量。

5、 学校希望能够在网管系统上查看攻击防范和入侵检测的日志,并且能够查看NAT转换前后的IP地址。

【配置步骤】

1、配置各接口的IP地址。

接口的配置我想大家都会的,所以强叔这里只给出GE1/0/0的配置了。本举例中的接口都为10GE接口。

【强叔点评】一般ISP分配给你的IP地址都是30位掩码的。建议在接口上配置描述或别名,表示接口的情况。

<USG> system-view

[USG] interface GigabitEthernet 1/0/0

[USG -GigabitEthernet1/0/0] ip address 218.1.1.1 255.255.255.252

[USG -GigabitEthernet1/0/0] description tocernet

[USG -GigabitEthernet1/0/0] quit

2、创建安全区域,并将各接口加入安全区域。

新建安全区域isp1、isp2和cernet(代表教育网),并将各接口加入对应的安全区域。

【强叔点评】当防火墙需要连接多个ISP时,一般需要为每个连接ISP的接口都创建一个新的安全区域,而且安全区域的名称最好能够代表此安全区域。

[USG] firewall zone name isp1

[USG-zone-isp1] set priority 15

[USG-zone-isp1] add interface GigabitEthernet 1/0/1

[USG-zone-isp1] quit

[USG] firewall zone name isp2

[USG-zone-isp2] set priority 20

[USG-zone-isp2] add interface GigabitEthernet 1/0/2

[USG-zone-isp2] quit

[USG] firewall zone name cernet

[USG-zone-cernet] set priority 25

[USG-zone-cernet] add interface GigabitEthernet 1/0/0

[USG-zone-cernet] quit

[USG] firewall zone trust

[USG-zone- trust] add interface GigabitEthernet 1/0/3

[USG-zone- trust] quit

3、配置IP-Link,探测各ISP提供的链路状态是否正常。

[USG] ip-link check enable

[USG] ip-link 1 destination 218.1.1.2 interface GigabitEthernet1/0/0

[USG] ip-link 2 destination 200.1.1.2 interface GigabitEthernet1/0/1

[USG] ip-link 3 destination 202.1.1.2 interface GigabitEthernet1/0/2

【强叔点评】当IP-Link监控的链路故障时,与其绑定的静态路由或策略路由失效。

4、配置静态路由,保证基础路由可达。

配置缺省路由,下一跳为教育网的地址,保证未匹配其他路由的流量都能够通过教育网转发出去。

[USG] ip route-static 0.0.0.0 0.0.0.0 218.1.1.1

配置静态路由,目的地址为内网网段,下一跳为内网交换机的地址,保证外网的流量能够到达内网。

[USG] ip route-static 10.1.0.0 255.255.0.0 172.16.1.2

【强叔点评】当在网关上配置静态路由时,既要有出方向的路由,也要有入方向的路由。一般情况下,出方向都会至少配置一条缺省路由。

5、 配置ISP选路,保证去往特定目的地址的流量能够通过特定链路(接口)转发。

1) 从各ISP获取最新的目的地址明细。

2) 按如下格式分别编辑各ISP的csv文件。

校园网出口网关配置

3) 导入所有ISP的csv文件。

4) 执行以下命令,分部加载各ISP的csv文件,并指定下一跳。

[USG] isp set filename csnet.csv GigabitEthernet 1/0/0 next-hop 218.1.1.2 track ip-link 1

[USG] isp set filename isp1.csv GigabitEthernet 1/0/1 next-hop 200.1.1.2 track ip-link 2

[USG] isp set filename isp2.csv GigabitEthernet 1/0/2 next-hop 202.1.1.2 track ip-link 3

【强叔点评】ISP选路功能其实就是批量下发明细路由,目的地址为ISP文件中的地址,下一跳为配置命令指定的地址。ISP选路能够实现去往特定ISP目的地址的流量都通过对应的ISP链路转发。

各位小伙伴注意,ISP选路功能是USG9000系列V300R001C20版本的新功能噢。

6、配置策略路由,保证特定内网用户(IP)的流量能够通过特定链路(接口)转发。

【强叔点评】策略路由的作用是基于源IP地址的选路(当然通过高级ACL也能实现基于目的地址的选路)。例如图书管的上网用户(10.1.2.0/24网段)只能通过教育网访问Internet。策略路由的配置方式是华为经典的CB对(classifier和behavior配对)配置方式。

[USG] acl number 2000

[USG-acl-basic-2000] rule permit source 10.1.2.0 0.0.0.255

[USG-acl-basic-2000] quit

[USG] traffic classifier classlb

[USG-classifier-classlb] if-match acl 2000

[USG-classifier-classlb] quit

[USG] traffic behavior behaviorlb

[USG-behavior-behaviorlb] redirect ip-nexthop 218.1.1.2 interface GigabitEthernet 1/0/0 track ip-link 1

[USG-behavior-behaviorlb] quit

[USG] traffic policy policylb

[USG-trafficpolicy-policylb] classifier classlb behavior behaviorlb

[USG-trafficpolicy-policylb] quit

[USG] interface GigabitEthernet 1/0/3

[USG-GigabitEthernet1/0/3] traffic-policy policylb inbound

[USG-GigabitEthernet1/0/3] quit

7、配置安全策略和IPS,保证流量能够正常转发的同时,进行入侵行为检测。

开启trust与isp1、isp2、csnet间的安全策略,并引用缺省的配置文件ids,进行入侵行为检测。下面仅以trust与isp1间的安全策略配置为例。

[USG] policy interzone trust isp1 outbound

[USG-policy-interzone-trust-isp1-outbound] policy 0

[USG-policy-interzone-trust-isp1-outbound-0] action permit

[USG-policy-interzone-trust-isp1-outbound-0] profile ips ids

[USG-policy-interzone-trust-isp1-outbound-0] quit

[USG] policy interzone trust isp1 inbound

[USG-policy-interzone-trust-isp1- inbound] policy 0

[USG-policy-interzone-trust-isp1- inbound -0] action permit

[USG-policy-interzone-trust-isp1- inbound -0] profile ips ids

[USG-policy-interzone-trust-isp1- inbound -0] quit

启用IPS功能,并配置特征库定时在线升级。

[USG] ips enable

[USG] update schedule ips-sdb enable

[USG] update schedule weekly sun 02:00

[USG] update schedule sa-sdb enable

[USG] update schedule weekly sun 03:00

[USG] undo update confirm ips-sdb enable

[USG] undo update confirm sa-sdb enable

【强叔点评】当防火墙作网关且网络对安全性要求不高时,可以配置域间的安全策略动作为允许。通过在安全策略上引用入侵防御配置文件可以实现安全区域间流量的入侵防御。USG缺省存在配置文件default和ids。配置文件default用于入侵行为检测并阻断,配置文件ids用于入侵行为检测并告警(不阻断)。

8、配置源NAT,保证多个内网用户能够同时访问外网。

需要分别在trust与isp1、isp2、csnet间配置源NAT,下面仅以trust与isp1间的源NAT配置为例。NAT地址池中的地址是从ISP获取的。

[USG] nat address-group isp1

[USG-address-group- isp1] mode pat

[USG-address-group- isp1] section 200.1.1.10 200.1.1.12

[USG-address-group- isp1] quit

[USG] nat-policy interzone trust isp1 outbound

[USG-nat-policy-interzone-trust-isp1-outbound] policy 0

[USG-nat-policy-interzone-trust-isp1-outbound-0] action source-nat

[USG-nat-policy-interzone-trust-isp1-outbound-0] address-group isp1

[USG] ip route-static 200.1.1.10 32 NULL 0

[USG] ip route-static 200.1.1.11 32 NULL 0

[USG] ip route-static 200.1.1.12 32 NULL 0

【强叔点评】源NAT和NAT Server都必须配置黑洞路由。

9、配置基于zone的NAT Server,使外网用户能够访问内网服务器。

一般情况下一台服务器的私网IP会映射成多个ISP的公网地址,供各个ISP的用户访问。

下面以其中一台图书馆服务器10.1.10.10为例配置基于zone的NAT Server。

[USG] nat server 1 zone isp1 global 200.1.10.10 inside 10.1.10.10 description lb-isp1

[USG] nat server 1 zone isp2 global 202.1.10.10 inside 10.1.10.10 description lb-isp2

[USG] nat server 1 zone csnet global 218.1.10.10 inside 10.1.10.10 description csnet

[USG] ip route-static 218.1.10.10 32 NULL 0

10、配置智能DNS,使各个ISP的外网用户都能够使用自己所在的ISP地址访问内网服务器。

智能DNS的作用是确保各个ISP的用户访问学校的服务器时,都能够解析到自己ISP的地址,从而提高访问速度。例如ISP1的用户通过域名访问图书馆服务器10.1.10.10时,会解析到服务器的ISP1地址200.1.10.10。

【强叔点评】使用智能DNS的前提是内网部署了DNS服务器(本案例仅以10.1.10.20为例)。

智能DNS将分配给每个ISP的服务器地址与连接ISP的出接口绑定。

各位小伙伴注意,智能DNS功能是USG9000系列V300R001C20版本的新功能噢~

[USG] dns resolve

[USG] dns server 10.1.10.20

[USG] dns-smart enable

[USG] dns-smart group 1 type single

[USG-dns-smart-group-1] description lb

[USG-dns-smart-group-1] real-server-ip 10.1.10.10

[USG-dns-smart-group-1] out-interface GigabitEthernet 1/0/0 map 218.1.10.10

[USG-dns-smart-group-1] out-interface GigabitEthernet 1/0/1 map 200.1.10.10

[USG-dns-smart-group-1] out-interface GigabitEthernet 1/0/2 map 202.1.10.10

11、配置攻击防范,保护内部网络安全。

[USG] firewall defend land enable

[USG] firewall defend smurf enable

[USG] firewall defend fraggle enable

[USG] firewall defend winnuke enable

[USG] firewall defend source-route enable

[USG] firewall defend route-record enable

[USG] firewall defend time-stamp enable

[USG] firewall defend ping-of-death enable

[USG] firewall defend syn-flood enable

[USG] firewall defend syn-flood interface GigabitEthernet1/0/0 max-rate 24000 tcp-proxy auto

[USG] firewall defend syn-flood interface GigabitEthernet1/0/1 max-rate 24000 tcp-proxy auto

[USG] firewall defend syn-flood interface GigabitEthernet1/0/2 max-rate 24000 tcp-proxy auto

【强叔点评】一般情况下,如果对网络安全没有特殊要求,开启以上攻击防范即可。

对于syn flood攻击防范,建议10GE接口阈值取值16000pps。本案例的接口都是10GE接口,之所以取值为24000pps,也是实际试验的结果。因为实际经验往往是配置较大的阈值,然后一边观察一边调小阈值,直到调整到合适的范围(既很好的限制了攻击,又不影响正常业务)。

12、配置带宽管理,限制网络的P2P流量。

【强叔点评】带宽管理的配置方法是先创建带宽通道(也就是指定各种限流动作),然后在带宽策略中引用带宽通道。需要特别注意的是上传、下载的方向与outbound、inbound的关系。另外一般情况下建议限制P2P流量到网络总流量的20%到30%。

各位小伙伴注意,带宽管理功能是USG9000系列V300R001C20版本的新功能噢~

[USG] car-class p2p_all_download

[USG-car-class-p2p_all_download] car-mode per-ip

[USG-car-class-p2p_all_download] cir 100000

[USG-car-class-p2p_all_download] cir 4000000 total

[USG-car-class-p2p_all_download] quit

[USG] car-class p2p_all_upload

[USG-car-class-p2p_all_upload] car-mode per-ip

[USG-car-class-p2p_all_upload] cir 100000

[USG-car-class-p2p_all_upload] cir 4000000 total

[USG-car-class-p2p_all_upload] quit

[USG] car-policy zone trust inbound

[USG-car-policy-zone-trust-inbound] policy 0

[USG-car-policy-zone-trust-inbound-0] policy application category p2p 

[USG-car-policy-zone-trust-inbound-0] action car

[USG-car-policy-zone-trust-inbound-0] car-class p2p_all_download

[USG-car-policy-zone-trust-inbound-0] description p2p_limit_download

[USG-car-policy-zone-trust-inbound-0] quit

[USG] car-policy zone trust outbound

[USG-car-policy-zone-trust-outbound] policy 0

[USG-car-policy-zone-trust-outbound-0] policy application category p2p 

[USG-car-policy-zone-trust-outbound-0] action car

[USG-car-policy-zone-trust-outbound-0] car-class p2p_all_upload

[USG-car-policy-zone-trust-outbound-0] description p2p_limit_upload

[USG-car-policy-zone-trust-outbound-0] quit

13、配置日志和NAT溯源功能,在网管系统eSight上查看日志。

配置USG向日志主机(10.1.10.30)发送系统日志(本案例发送IPS日志和攻击防范日志)。

[USG] info-center enable

[USG] engine log ips enable

[USG] info-center source ips channel loghost log level emergencies

[USG] info-center source ANTIATTACK channel loghost

[USG] info-center loghost 10.1.10.30

配置USG向日志主机(10.1.10.30)发送会话日志(端口9002)。这里需要在trust与isp、isp2、csnet间的双方向都配置审计策略。本案例仅以trust与isp1间的outbound方向的审计策略为例。

[USG] firewall log source 172.16.1.1 9002

[USG] firewall log host 2 10.1.10.30 9002

[USG] audit-policy interzone trust isp1 outbound

[USG- audit-policy -interzone-trust-isp1-outbound] policy 0

[USG- audit-policy -interzone-trust-isp1-outbound-0] action audit

本案例中日志主机(10.1.10.30)上安装了网管系统eSight。如果希望在eSight上查看日志,需要在USG上配置SNMP,使USG与eSight对接。eSight上的SNMP参数需要与USG上保持一致。

[USG] snmp-agent sys-info v3

[USG] snmp-agent group v3 NMS1 privacy

[USG] snmp-agent usm-user v3 admin1 NMS1 authentication-mode md5 Admin@123 privacy-mode aes256 Admin@123

eSight配置完成后,在eSight上选择“业务 > 安全业务 > LogCenter > 日志分析 > 会话分析 > IPv4会话日志”,可以查看会话日志。(此图仅为示意,后续专门带来真实数据的防火墙与esight对接案例)

校园网出口网关配置

【拍案惊奇】

1、此案例的惊奇之处在于几乎囊括了防火墙的所有经典特性:安全策略、NAT、ASPF、攻击防范、IPS、带宽管理(基于应用的带宽限制、基于每IP的带宽限制)。防火墙功能繁多,如果小伙伴们不知道如何选择,那么参考此样板案例就八九不离十啦~

2、此案例的另一惊奇之处在于展现了防火墙作网关的能力。网关最重要的特性之一就是出口选路。防火墙通过ISP选路功能实现基于目的地址的选路,通过策略路由功能实现基于源地址的选路,通过智能DNS功能实现外网用户访问内网服务器的选路(选择最适合的服务器)。

另外与路由器作网关相比,防火墙作网关的优势在于更强大的NAT、更强大的安全性。

3、此案例的又一惊奇之处在于展现了防火墙的NAT溯源功能(防火墙上配置审计策略后,会将会话日志发送给网管系统,客户在网管系统上能够查看到NAT前后的地址)。这个功能最近很火,是应对上级和相关部门检查的利器噢~