机房ISP提供了两条上联线路,分别接入ISP的两台核心交换机。 这两条线路是主备模式,同一时间只能有一条工作。 恰好等保要求,买了两台juniper srx 1500,为了节省设备,决定这两个墙既作为边界防火墙,又做路由器,将ISP分配的公网IP的网关放在本地墙上。
为实现上述功能,需要完成两个配置:
- 两台SRX 1500配置HA
- 配置rpm检测和路由切换
HA功能就是将两台防火墙组成一个逻辑设备,两台墙在用户视角就是一个设备,如果一个节点死掉,另外节点会接收工作,juniper设备分为控制平面和数据平面,因此包括nat session 等信息在两个设备间都是同步的,用户不会有任何感知。 类似cisco的IP SLA功能,juniper设备也可以通过配置各种探针探测指定的指标,然后根据探测结果执行一些动作,这个功能在juniper设备上叫rpm(real-time performance monitoring ),详细可参见参考文档2 。 常用的典型例子就是通过ping测试网络是否可达,然后根据结果切换默认路由。,
第一部分:配置HA 1.将两台srx都设置为集群模式,集群ID是1,两个节点分别为node 0和node 1,设置以后设备会自动重启。 注意,该命令是在“>”提示符状态下执行,不是配置模式。 *** 主设备上操作(node0):
set chassis cluster cluster-id 1 node 0 reboot
*** 从设备上操作 (node1):
set chassis cluster cluster-id 1 node 1 reboot
在主设备上执行接下来的配置,无需操作从设备,配置会自动同步。
2.配置两个节点的主机名 set groups node0 system host-name srx-master set groups node1 system host-name srx-slave set apply-groups "${node}" 第三条命令是配置集群必须的,该命令确保跟节点相关的命令,如配置主机名,只在对应的节点上执行。
3.配置redundancy group redundancy group指的是一组在两个节点间切换的资源,概念与linux中的HA Heartbeat配置中的资源类似,可以参考理解。 默认的redundancy group是group 0,group 0代表control plane,从group 1开始代表data plane。
set chassis cluster redundancy-group 0 node 0 priority 200 set chassis cluster redundancy-group 0 node 1 priority 100 set chassis cluster redundancy-group 1 node 0 priority 200 set chassis cluster redundancy-group 1 node 1 priority 100
4.配置集群的FABRIC LINKS,即数据平面 set interfaces fab0 fabric-options member-interfaces xe-0/0/18 set interfaces fab1 fabric-options member-interfaces xe-7/0/18
5.配置REDUNDANCY ETHERNET INTERFACES reth是一个逻辑设备,是两个节点上网络接口的叠加,概念类似linux的bounding,可以参考理解。 将对应的物理接口加入reth组中,给reth接口配置公网IP地址,该地址即内部其他服务器的网关。
set chassis cluster reth-count 1 set interfaces reth0 redundant-ether-options redundancy-group 1 set interfaces ge-0/0/0 gigether-options redundant-parent reth0 set interfaces ge-7/0/0 gigether-options redundant-parent reth0 set interfaces reth0 unit 0 family inet address 111.111.111.1/24
到这,HA就算配置完毕了,我们可以手工触发ha切换测试 request chassis cluster failover redundancy-group 1 node 1
通过命令查看,可以看到Redundancy group: 1 发生了切换
show chassis cluster status
Cluster ID: 1 Node Priority Status Preempt Manual Monitor-failures
Redundancy group: 0 , Failover count: 1
node0 200 primary no no None
node1 100 secondary no no None
Redundancy group: 1 , Failover count: 2
node0 200 secondary no no None
node1 100 primary no no None
测试之后要清空手工ha状态 request chassis cluster failover reset redundancy-group 1
【可选配置】配置Cluster Interface Monitoring 我们可以监控一个端口状态,如果端口状态发生改变,会自动发生redundancy-group的角色切换。
set chassis cluster redundancy-group 1 interface-monitor ge-0/0/3 weight 255 set chassis cluster redundancy-group 1 interface-monitor ge-7/0/3 weight 255
第二部分:配置rpm检测和路由切换
1.配置上连ISP接口的互联地址 set interfaces ge-0/0/3 unit 0 family inet address 10.1.0.90/30 set interfaces ge-7/0/3 unit 0 family inet address 10.1.0.94/30
2.配置默认路由 set routing-options static route 0.0.0.0/0 next-hop 10.1.0.89
3.配置rpm检测,探测ISP对端的互联地址 每1秒发起一次探测,每次探测发送10个包,每个包之间的间隔为1s,在一次探测中,如果有5个包不通,则判定为链路失效,链路失效以后将默认路由修改为备线地址。探测使用接口ge-0/0/3.0
set services rpm probe ping-check-mainline test icmp-test target address 10.1.0.89 set services rpm probe ping-check-mainline test icmp-test probe-count 10 set services rpm probe ping-check-mainline test icmp-test probe-interval 1 set services rpm probe ping-check-mainline test icmp-test test-interval 1 set services rpm probe ping-check-mainline test icmp-test thresholds successive-loss 5 set services rpm probe ping-check-mainline test icmp-test destination-interface ge-0/0/3.0 set services rpm probe ping-check-mainline test icmp-test next-hop 10.1.0.89 set services ip-monitoring policy mainline-is-down match rpm-probe ping-check-mainline set services ip-monitoring policy mainline-is-down then preferred-route route 0.0.0.0/0 next-hop 10.1.0.93
参考文档: 1.https://www.juniper.net/documentation/en_US/junos/topics/concept/security-rpm-overview.html 2.https://kb.juniper.net/InfoCenter/index?page=content&id=KB25052&actp=METADATA 3.http://www.skullbox.net/junipersrxcluster.php 4.https://blog.bravi.org/?p=555 5.http://netfixpro.com/deep-dive-of-chassis-cluster-configuration-on-juniper-srx-1500-firewalls/ https://www.juniper.net/documentation/en_US/junos/topics/example/chassis-cluster-redundancy-group-interface-monitoring-configuring-cli.html