You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial provides information and examples of configuring Juniper Networks SRX Series Firewalls with Magic WAN.
6
+
This tutorial provides information and examples of how to configure Juniper Networks SRX Series Firewalls with Magic WAN.
7
7
8
8
The configuration settings in this document are based on JUNOS 23.4R2.13.
9
9
10
10
## Prerequisites
11
11
12
-
Confirm that you have the two Cloudflare anycast IPs allocated to your account. You will establish IPsec tunnels to the two anycast IPs irrespective of the location of your Juniper SRX devices (hereon in "endpoint") - traffic will be naturally attracted to the closest Cloudflare colocation facility via BGP anycast.
12
+
Confirm that you have two Cloudflare anycast IPs allocated to your account. You will establish IPsec tunnels to the two anycast IPs irrespective of the location of your Juniper SRX devices (from now on referred to as endpoint) — traffic will be naturally attracted to the closest Cloudflare colocation facility via BGP anycast.
13
13
14
-
Cloudflare recommends customers configure two IPsec tunnels (one to each of the two anycast IPs allocated to you Cloudflare account) per Internet Service Provider per endpoint. This provides tunnel redundancy diversity.
14
+
Cloudflare recommends that customers configure two IPsec tunnels (one to each of the two anycast IPs allocated to you Cloudflare account) per Internet service provider per endpoint. This provides tunnel redundancy.
15
15
16
-
Equal Cost Multipath Routing (ECMP) ensures traffic is load-balanced across the tunnels, and you can control traffic steering across the tunnels through route prioritization.
16
+
Equal-cost multi-path routing (ECMP) ensures traffic is load-balanced across the tunnels, and you can control traffic steering across the tunnels through route prioritization.
17
17
18
-
Cloudflare supports Route-Based site-to-site IPsec tunnels, which require the creation of Virtual Tunnel Interfaces (VTIs). We recommend you select one subnet per Magic IPsec Tunnel with either a /30 or /31 netmask.
18
+
Cloudflare supports route-based site-to-site IPsec tunnels, which require the creation of virtual tunnel interfaces (VTIs). We recommend you select one subnet per Magic IPsec tunnel with either a `/30` or `/31` netmask.
19
19
20
-
Using a /31 netmask makes more efficient use of IP addresses as it doubles the number of available subnets as it is unnecessary to reserve IPs for the subnet and broadcast addreses as there would be if you opt to use a /30 netmask. Additional details can be found in [RFC3021 - Using 31-Bit Prefixes on IPv4 Point-to-Point Links](https://datatracker.ietf.org/doc/html/rfc3021).
20
+
Using a `/31` netmask is a more efficient use of IP addresses as it doubles the number of available subnets compared to a `/30`netmask. This is possible because with a `/31`netmask there is no need to reserve IP addresses for the subnet and broadcast addresses, as there would be if you opt to use a `/30` netmask. Additional details can be found in [RFC 3021 - Using 31-Bit Prefixes on IPv4 Point-to-Point Links](https://datatracker.ietf.org/doc/html/rfc3021).
21
21
22
22
## Cloudflare Magic WAN configuration
23
23
24
24
This section of the document will cover the configuration of:
25
25
26
-
- Magic IPsec Tunnels
27
-
- Magic Static Routes
26
+
- Magic IPsec tunnels
27
+
- Magic static routes
28
28
29
-
### Magic WAN Topology
29
+
### Magic WAN topology
30
30
31
31
This documentation assumes there are two locations connected via Magic WAN:
2. Select **Add IPsec Tunnel** and fill in the values for the second tunnel to the same Juniper SRX:
48
-
- Ensure you use a unique RFC1918 IP address for the Interface Address (`/31` or `/30`).
48
+
- Ensure you use a unique RFC 1918 IP address for the Interface Address (`/31` or `/30`).
49
49
- Once again, specify the Internet IP address on the untrust side of the SRX firewall for the **Customer Endpoint**.
50
50
- The **Cloudflare Endpoint** for the second tunnel will be the second Cloudflare anycast IP provisioned for your account.
51
51
3. Select **Add Tunnels**. We also recommend selecting **Test Tunnels** to ensure that the settings do not conflict with any other tunnels defined in your account and that you specified the correct anycast IP addresses.
@@ -62,15 +62,15 @@ This documentation assumes there are two locations connected via Magic WAN:
62
62
The **Tunnel ID** and **FQDN ID** values are unique per tunnel and remain unchanged unless you delete and recreate the tunnel. Generating a new Pre-Shared Key will not change the values.
63
63
:::
64
64
65
-
### Magic Static Routes
65
+
### Magic static routes
66
66
67
67
Refer to the Magic WAN Topology section above for more details on the IP subnet scheme.
68
68
69
-
[Magic Static Routes](/magic-wan/configuration/manually/how-to/configure-static-routes/) effectively tell Magic WAN which tunnels to route traffic destined for a given Magic WAN site.
69
+
[Magic static routes](/magic-wan/configuration/manually/how-to/configure-static-routes/) effectively tell Magic WAN which tunnels to route traffic destined for a given Magic WAN site.
70
70
71
71
Since two tunnels are configured to each endpoint, it is necessary to configure two static routes.
72
72
73
-
Cloudflare leverages [Equal-Cost Multi-Path](/magic-wan/reference/traffic-steering/) routing to control traffic steering across the tunnels. The default priority for each route is 100 — traffic will be load-balanced across the two tunnels equally via ECMP. You can modify the priorities as needed, however best practices dictate leaving the default values in place.
73
+
Cloudflare leverages [equal-cost multi-path](/magic-wan/reference/traffic-steering/) routing to control traffic steering across the tunnels. The default priority for each route is 100 — traffic will be load-balanced across the two tunnels equally via ECMP. You can modify the priorities as needed, however best practices dictate leaving the default values in place.
74
74
75
75
1. Create a static route with the following values. Make sure you select the first tunnel in **Tunnel/Next hop**:
76
76
-**Description:** The description for the static route assigned to your first tunnel.
3. Select **Test Routes** to ensure the settings are accepted, then select **Add Routes**.
83
83
4. Confirm the routes were added correctly in **Magic WAN** > **Configuration** > **Static Routes**.
84
84
85
-
## Juniper SRX Configuration
85
+
## Juniper SRX configuration
86
86
87
-
There may be some differences in the syntax of the commands in the version on your SRX devices; however, the principles are the same. Please refer to the Juniper product documentation for more information.
87
+
There may be some differences in the syntax of the commands in the version on your SRX devices. However, the principles are the same. Refer to the Juniper product documentation for more information.
88
88
89
-
The interface naming convention for VTI interfaces (aka Secure Tunnel Interfaces) in Junos is st0.x.
89
+
The interface naming convention for VTI interfaces (also known as Secure Tunnel Interfaces) in Junos is `st0.x`.
90
90
91
91
[Secure Tunnel Interface in a Virtual Router - Juniper IPsec VPN User Guide](https://www.juniper.net/documentation/us/en/software/junos/vpn-ipsec/topics/topic-map/security-secure-tunnel-interface-in-a-virtual-router.html)
92
92
93
93
The following elements will be configured on the Juniper SRX firewall(s):
94
94
95
-
- Ensure the LAN interface is in the `trust` zone ()
96
-
- Add Virtual Tunnel Interfaces (`st0.0` and `st0.1`)
95
+
- Ensure the LAN interface is in the `trust` zone
96
+
- Add virtual tunnel Interfaces (`st0.0` and `st0.1`)
97
97
- Assign tunnel interfaces to the `cloudflare` security zone
98
98
- Allow required protocols to both the tunnel and untrust security zones
99
99
- IKE configuration
100
100
- IPsec configuration
101
-
- Policy-Based Routing (Filter-Based Forwarding)
101
+
- Policy-based routing (filter-based forwarding)
102
102
- Security policies
103
103
104
104
### Tunnel interfaces
@@ -167,7 +167,7 @@ interfaces {
167
167
168
168
### Security zone (untrust) - `host-inbound-traffic`
169
169
170
-
Add ping and ike to the security zone containing the external interface used to establish the IPsec tunnels to Cloudflare.
170
+
Add `ping` and `ike` to the security zone containing the external interface used to establish the IPsec tunnels to Cloudflare.
171
171
172
172
```txt
173
173
set security zones security-zone untrust interfaces ge-0/0/0.0 host-inbound-traffic system-services ike
The SRX platform provides policy-based routing functionality, which Juniper refers to as [filter-based forwarding](https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/concept/firewall-filter-option-filter-based-forwarding-overview.html).
403
401
404
402
Filter-based forwarding is implemented by configuring the following:
405
403
406
-
1. Routing Instance: Specify the routing table(s) to which a packet is forwarded and the destination to which the packet is forwarded at the [edit routing-instances] hierarchy level.
407
-
2. Firewall Filter: Use a stateless firewall filter to specify the source and destination addresses in conjunction with a routing instance that forwards traffic across the Magic IPsec Tunnels, then bind the firewall filter to the ingress interface (trust zone).
408
-
3. RIB Group: Share interface routes with the forwarding routing instances used in filter-based forwarding (FBF).
404
+
1.**Routing Instance**: Specify the routing table(s) to which a packet is forwarded and the destination to which the packet is forwarded at the [edit routing-instances] hierarchy level.
405
+
2.**Firewall Filter**: Use a stateless firewall filter to specify the source and destination addresses in conjunction with a routing instance that forwards traffic across the Magic IPsec tunnels, then bind the firewall filter to the ingress interface (trust zone).
406
+
3.**RIB Group**: Share interface routes with the forwarding routing instances used in filter-based forwarding (FBF).
409
407
410
-
Note: Firewall filters must incorporate at least two terms:
408
+
:::note
409
+
Firewall filters must incorporate at least two terms:
411
410
412
-
1. Term 1: Classify the traffic to forward to Magic WAN
413
-
2. Term 2: Permit all other traffic - otherwise, the firewall filters will discard any traffic not intended for Magic WAN destinations.
411
+
-**Term 1**: Classify the traffic to forward to Magic WAN
412
+
-**Term 2**: Permit all other traffic — otherwise, the firewall filters will discard any traffic not intended for Magic WAN destinations.
413
+
:::
414
414
415
-
This configuration only factors in one local site (10.1.20.0/24). In this example, we assume devices in the trust zone must route traffic to a remote subnet at another Magic WAN-protected site (10.1.100.0/24).
415
+
This configuration only factors in one local site (`10.1.20.0/24`). In this example, we assume devices in the trust zone must route traffic to a remote subnet at another Magic WAN-protected site (`10.1.100.0/24`).
416
416
417
-
Define a static route on the SRX to route traffic to 10.1.100.0/24 with redundant routes referencing each of the two tunnels.
417
+
Define a static route on the SRX to route traffic to `10.1.100.0/24` with redundant routes referencing each of the two tunnels.
418
418
419
419
**Routing Instance:**
420
420
@@ -424,9 +424,9 @@ As mentioned earlier, any traffic destined for other Magic WAN protected sites m
424
424
425
425
The example includes two static routes - one to each of the two VTIs on the Cloudflare side of the Magic IPsec Tunnels (`10.252.2.20` and `10.252.2.22`).
426
426
427
-
While it is possible to be more prescriptive in terms of the destination subnets, we simply use 0.0.0.0/0 as the Firewall Filter ensures only traffic destined for 10.1.100.0/24 will be forwarded to the Routing Instance. Any other traffic not destined for 10.1.100.0/24 will continue to the Primary Routing Table (`inet.0`) as it falls outside the scope of the Firewall Filter configured in the next section below.
427
+
While it is possible to be more prescriptive in terms of the destination subnets, we simply use `0.0.0.0/0` as the firewall filter ensures only traffic destined for `10.1.100.0/24` will be forwarded to the routing instance. Any other traffic not destined for `10.1.100.0/24` will continue to the primary routing table (`inet.0`) as it falls outside the scope of the firewall filter configured in the next section below.
428
428
429
-
Leaving the destination subnet as 0.0.0.0/0 eases some administrative burden as you only need to modify the Firewall Filter to specify which traffic is destined for Magic WAN.
429
+
Leaving the destination subnet as `0.0.0.0/0` eases some administrative burden as you only need to modify the firewall filter to specify which traffic is destined for Magic WAN.
430
430
431
431
```txt
432
432
set routing-instances MAGIC_WAN_RI instance-type forwarding
@@ -450,11 +450,10 @@ MAGIC_WAN_RI {
450
450
451
451
**Firewall Filter:**
452
452
453
-
In this step, we create a stateless firewall filter to ensure only packets from 10.1.20.0/24 destined for 10.1.100.0/24 are sent to the `MAGIC_WAN_RI` Routing Instance.
454
-
455
-
- Term 1 - `MAGIC_WAN_NETS` ensures only packets from 10.1.20.0/24 destined for 10.1.100.0/24 are sent to the `MAGIC_WAN_RI` Routing Instance. Take note of the `count` statement defined in this term. [Count](https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/example/firewall-filter-stateless-example-act-on-sampling.html) allows you to view how many packets are processed by this term in the Firewall Filter. An example of how to view the Counter is included below.
453
+
In this step, we create a stateless firewall filter to ensure only packets from `10.1.20.0/24` destined for `10.1.100.0/24` are sent to the `MAGIC_WAN_RI` routing instance.
456
454
457
-
- Term 2 - `ALLOW_EVERYTHING_ELSE` ensures all other traffic continues to the Primary Routing Table (`inet.0`).
455
+
-**Term 1** - `MAGIC_WAN_NETS` ensures only packets from `10.1.20.0/24` destined for `10.1.100.0/24` are sent to the `MAGIC_WAN_RI` routing instance. Take note of the `count` statement defined in this term. [Count](https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/example/firewall-filter-stateless-example-act-on-sampling.html) allows you to view how many packets are processed by this term in the firewall filter. An example of how to view the Counter is included below.
456
+
-**Term 2** - `ALLOW_EVERYTHING_ELSE` ensures all other traffic continues to the primary routing table (`inet.0`).
458
457
459
458
```txt
460
459
set firewall family inet filter MAGIC_WAN_FBF term MAGIC_WAN_NETS from source-address 10.1.20.0/24
@@ -528,7 +527,7 @@ family inet {
528
527
529
528
**RIB Group:**
530
529
531
-
RIB Groups allow you to concatenate the contents of multiple routing tables into a Routing Table Group.
530
+
RIB Groups allow you to concatenate the contents of multiple routing tables into a routing table group.
532
531
533
532
The primary routing table in the RIB group should be `inet.0` followed by the secondary routing table `MAGIC_WAN_RI.inet.0` which is the `MAGIC_WAN_RI` routing-instance created above.
There are several diagnostic commands available to view the status of IPsec tunnels.
630
629
631
-
#### **Ping Across Virtual Tunnel Interfaces**
630
+
#### Ping across virtual tunnel interfaces
632
631
633
-
Use ping to test connectivity from the SRX side of the tunnel to the Cloudflare side of the tunnel. Ensure you use the source option to specify the IP address associated with tunnel interfaces st0.0 and st0.1, respectively:
632
+
Use ping to test connectivity from the SRX side of the tunnel to the Cloudflare side of the tunnel. Ensure you use the source option to specify the IP address associated with tunnel interfaces `st0.0` and `st0.1`, respectively:
634
633
635
-
Tunnel 1 - `st0.0 - 10.252.2.21`
634
+
**Tunnel 1** - `st0.0 - 10.252.2.21`
636
635
637
636
```txt
638
637
admin@srx300> ping source 10.252.2.21 10.252.2.20
@@ -646,7 +645,7 @@ PING 10.252.2.20 (10.252.2.20): 56 data bytes
646
645
64 bytes from 10.252.2.20: icmp_seq=4 ttl=64 time=3.811 ms
Refer to [traceoptions (Security IPsec)](https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/statement/security-edit-traceoptions-ipsec.html) for more information on this topic.
760
759
761
-
#### **Enable IPsec****traceoptions**
760
+
#### Enable IPsec`traceoptions`
762
761
763
762
```txt
764
763
set security ipsec traceoptions file ipsec-debug.log
@@ -768,29 +767,29 @@ set security ipsec traceoptions file world-readable
768
767
set security ipsec traceoptions flag all
769
768
```
770
769
771
-
The log file can be viewed by doing the following:
770
+
To view the log file:
772
771
773
-
1. From an operational mode, run **start shell**.
772
+
1. From an operational mode, run `start shell`.
774
773
2. Use the tail command to view the contents of the log file in real time:
775
774
`tail -f /var/log/ipsec-debug.log`
776
-
3. Press CTRL + C when finished.
777
-
4. Type exit to return to the operational mode prompt.
775
+
3. Press `CTRL + C` when finished.
776
+
4. Type `exit` to return to the operational mode prompt.
778
777
779
-
Either deactivate traceoptions or delete traceoptions once debugging is complete.
778
+
Either deactivate `traceoptions` or delete `traceoptions` once debugging is complete.
780
779
781
-
#### **Delete IPsec****traceoptions**
780
+
#### Delete IPsec`traceoptions`
782
781
783
782
```txt
784
783
delete security ipsec traceoptions
785
784
```
786
785
787
-
#### **Deactivate IPsec****traceoptions**
786
+
#### Deactivate IPsec`traceoptions`
788
787
789
788
```txt
790
789
deactivate security ipsec traceoptions
791
790
```
792
791
793
-
Confirm traceoptions is deactivated:
792
+
Confirm `traceoptions` is deactivated:
794
793
795
794
```txt
796
795
admin@srx300> show configuration security ipsec traceoptions
0 commit comments