Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Route-Based IPsec VPNs

A route-based VPN is a configuration in which an IPsec VPN tunnel created between two end points is referenced by a route that determines which traffic is sent through the tunnel based on a destination IP address.

Understanding Route-Based IPsec VPNs

With route-based VPNs, you can configure dozens of security policies to regulate traffic flowing through a single VPN tunnel between two sites, and there is just one set of IKE and IPsec SAs at work. Unlike policy-based VPNs, for route-based VPNs, a policy refers to a destination address, not a VPN tunnel. When Junos OS looks up a route to find the interface to use to send traffic to the packet’s destination address, it finds a route through a secure tunnel interface (st0.x). The tunnel interface is bound to a specific VPN tunnel, and the traffic is routed to the tunnel if the policy action is permit.

A secure tunnel (st0) interface supports only one IPv4 address and one IPv6 address at the same time. This applies to all route-based VPNs. The disable option is not supported on st0 interfaces.

Examples of where route-based VPNs can be used:

  • There are overlapping subnets or IP addresses between the two LANs.

  • A hub-and-spoke VPN topology is used in the network, and spoke-to-spoke traffic is required.

  • Primary and backup VPNs are required.

  • A dynamic routing protocol (for example, OSPF, RIP, or BGP) is running across the VPN.

    Configuring RIP demand circuits over point-to-multipoint VPN interfaces is not supported.

We recommend that you use route-based VPN when you want to configure VPN between multiple remote sites. Route-based VPN allows for routing between the spokes between multiple remote sites; it is easier to configure, monitor, and troubleshoot.

Example: Configuring a Route-Based VPN

This example shows how to configure a route-based IPsec VPN to allow data to be securely transferred between two sites.

Requirements

This example uses the following hardware:

  • Any SRX Series device

    • Updated and revalidated using vSRX on Junos OS Release 20.4R1.
Note:

Are you interested in getting hands-on experience with the topics and operations covered in this guide? Visit the IPsec Route-Based VPN demonstration in Juniper Networks Virtual Labs and reserve your free sandbox today! You’ll find the IPsec VPN Route-Based sandbox in the Security category.

Before you begin, read IPsec Overview.

Overview

In this example, you configure a route-based VPN on SRX1 and SRX2. Host1 and Host2 use the VPN to send traffic securely over the Internet between both hosts.

Figure 1 shows an example of a route-based VPN topology.

Figure 1: Route-Based VPN Topology Route-Based VPN Topology

In this example, you configure interfaces, an IPv4 default route, and security zones. Then you configure IKE, IPsec, security policy, and TCP-MSS parameters. See Table 1 through Table 5 for specific configuration parameters used in this example.

Table 1: Interface, Static Route, Security Zone, and Security Policy Information for SRX1

Feature

Name

Configuration Parameters

Interfaces

ge-0/0/0.0

10.100.11.1/24

 

ge-0/0/1.0

172.16.13.1/24

 

st0.0 (tunnel interface)

10.100.200.1/24

Static routes

10.100.22.0/24

0.0.0.0/0

The next hop is st0.0.

The next hop is 172.16.13.2.

Security zones

trust

  • The ge-0/0/0.0 interface is bound to this zone.

 

untrust

  • The ge-0/0/1.0 interface is bound to this zone.

 

vpn

  • The st0.0 interface is bound to this zone.

Table 2: IKE Configuration Parameters

Feature

Name

Configuration Parameters

Proposal

standard

  • Authentication method: pre-shared-keys

Policy

IKE-POL

  • Mode: main

  • Proposal reference: standard

  • IKE policy authentication method: pre-shared-keys

Gateway

IKE-GW

  • IKE policy reference: IKE-POL

  • External interface: ge-0/0/1

  • Gateway address: 172.16.23.1

Table 3: IPsec Configuration Parameters

Feature

Name

Configuration Parameters

Proposal

standard

  • Using default configuration

Policy

IPSEC-POL

  • Proposal reference: standard

VPN

VPN-to-Host2

  • IKE gateway reference: IKE-GW

  • IPsec policy reference: IPSEC-POL

  • Bind to interface: st0.0

  • establish-tunnels immediately
Table 4: Security Policy Configuration Parameters

Purpose

Name

Configuration Parameters

The security policy permits traffic from the trust zone to the VPN zone.

VPN-OUT

  • Match criteria:

    • source-address Host1-Net

    • destination-address Host2-Net

    • application any

  • Action: permit

The security policy permits traffic from the VPN zone to the trust zone.

VPN-IN

  • Match criteria:

    • source-address Host2-Net

    • destination-address Host1-Net

    • application any

  • Action: permit

Table 5: TCP-MSS Configuration Parameters

Purpose

Configuration Parameters

TCP-MSS is negotiated as part of the TCP three-way handshake and limits the maximum size of a TCP segment to better fit the MTU limits on a network. For VPN traffic, the IPsec encapsulation overhead, along with the IP and the frame overhead, can cause the resulting ESP packet to exceed the MTU of the physical interface, which causes fragmentation. Fragmentation increases bandwidth and the device resources.

We recommend a value of 1350 as the starting point for most Ethernet-based networks with an MTU of 1500 or greater. You might need to experiment with different TCP-MSS values to obtain optimal performance. For example, you might need to change the value if any device in the path has a lower MTU, or if there is any additional overhead such as PPP or Frame Relay.

MSS value: 1350

Configuration

Configure Basic Network and Security Zone Information

CLI Quick Configuration

To quickly configure this section of the example for SRX1, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see the CLI User Guide.

To configure interface, static route, and security zone information:

  1. Configure the interfaces.

  2. Configure the static routes.

  3. Assign the Internet facing interface to the untrust security zone.

  4. Specify the allowed system services for the untrust security zone.

  5. Assign the Host1 facing interface to the trust security zone.

  6. Specify the allowed system services for the trust security zone.

  7. Assign the secure tunnel interface to the VPN security zone.

  8. Specify the allowed system services for the VPN security zone.

Results

From configuration mode, confirm your configuration by entering the show interfaces, show routing-options, and show security zones commands. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

Configuring IKE

CLI Quick Configuration

To quickly configure this section of the example for SRX1, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see CLI User Guide.

To configure IKE:

  1. Create the IKE proposal.

  2. Define the IKE proposal authentication method.

  3. Create an IKE policy.

  4. Set the IKE policy mode.

  5. Specify a reference to the IKE proposal.

  6. Define the IKE policy authentication method.

  7. Create an IKE gateway and define its external interface.

  8. Define the IKE policy reference.

  9. Define the IKE gateway address.

Results

From configuration mode, confirm your configuration by entering the show security ike command. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

Configuring IPsec

CLI Quick Configuration

To quickly configure this section of the example for SRX1, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see the CLI User Guide.

To configure IPsec:

  1. Create an IPsec proposal.

  2. Create the IPsec policy.

  3. Specify the IPsec proposal reference.

  4. Specify the IKE gateway.

  5. Specify the IPsec policy.

  6. Specify the interface to bind.

  7. Configure the tunnel to establish immediately.

Results

From configuration mode, confirm your configuration by entering the show security ipsec command. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

Configuring Security Policies

CLI Quick Configuration

To quickly configure security policies for SRX1, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see the CLI User Guide.

To configure security policies:

  1. Create address book entries for the networks that will be used in the security policies.

  2. Create a security policy to permit traffic from the trust zone to the untrust zone for traffic to the Internet.

  3. Create a security policy to permit traffic from Host1 in the trust zone destined to Host2 in the VPN zone.

  4. Create a security policy to permit traffic from Host2 in the VPN zone to Host1 in the trust zone.

Results

From configuration mode, confirm your configuration by entering the show security address-book and show security policies commands. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

Configuring TCP-MSS

CLI Quick Configuration

To quickly configure the TCP MSS for SRX1, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see the CLI User Guide.

To configure TCP-MSS information:

  1. Configure the TCP-MSS information.

Results

From configuration mode, confirm your configuration by entering the show security flow command. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

If you are done configuring the device, enter commit from configuration mode.

Configuring SRX2

CLI Quick Configuration

For reference, the configuration for the SRX2 is provided.

To quickly configure this section of the example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Verification

Perform these tasks to confirm that the configuration is working properly:

Verify the IKE Status

Purpose

Verify the IKE status.

Action

From operational mode, enter the show security ike security-associations command. After obtaining an index number from the command, use the show security ike security-associations index index_number detail command.

Meaning

The show security ike security-associations command lists all active IKE SAs. If no SAs are listed, there was a problem with IKE establishment. Check the IKE policy parameters and external interface settings in your configuration.

If SAs are listed, review the following information:

  • Index—This value is unique for each IKE SA, which you can use in the show security ike security-associations index detail command to get more information about the SA.

  • Remote Address—Verify that the remote IP address is correct.

  • State

    • UP—The IKE SA has been established.

    • DOWN—There was a problem establishing the IKE SA.

  • Mode—Verify that the correct mode is being used.

Verify that the following are correct in your configuration:

  • External interfaces (the interface must be the one that receives IKE packets)

  • IKE policy parameters

  • Preshared key information

  • Proposal parameters (must match on both peers)

The show security ike security-associations index 1859340 detail command lists additional information about the security association with an index number of 1859340:

  • Authentication and encryption algorithms used

  • lifetime

  • Traffic statistics (can be used to verify that traffic is flowing properly in both directions)

  • Role information

    Troubleshooting is best performed on the peer using the responder role.

  • Initiator and responder information

  • Number of IPsec SAs created

  • Number of negotiations in progress

Verify the IPsec Status

Purpose

Verify the IPsec status.

Action

From operational mode, enter the show security ipsec security-associations command. After obtaining an index number from the command, use the show security ipsec security-associations index index_number detail command.

Meaning

The output from the show security ipsec security-associations command lists the following information:

  • The ID number is 131074. Use this value with the show security ipsec security-associations index command to get more information about this particular SA.

  • There is one IPsec SA pair using port 500, which indicates that no NAT-traversal is implemented. (NAT-traversal uses port 4500 or another random high-number port.)

  • The SPIs, lifetime (in seconds), and usage limits (or lifesize in KB) are shown for both directions. The 3403/ unlim value indicates that the lifetime expires in 3403 seconds, and that no lifesize has been specified, which indicates that it is unlimited. Lifetime can differ from lifetime, as IPsec is not dependent on IKE after the VPN is up.

  • VPN monitoring is not enabled for this SA, as indicated by a hyphen in the Mon column. If VPN monitoring is enabled, U indicates that monitoring is up, and D indicates that monitoring is down.

  • The virtual system (vsys) is the root system, and it always lists 0.

The output from the show security ipsec security-associations index 131074 detail command lists the following information:

  • The local identity and remote identity make up the proxy ID for the SA.

    A proxy ID mismatch is one of the most common causes for a IPsec failure. If no IPsec SA is listed, confirm that IPsec proposals, including the proxy ID settings, are correct for both peers. For route-based VPNs, the default proxy ID is local=0.0.0.0/0, remote=0.0.0.0/0, and service=any. Issues can occur with multiple route-based VPNs from the same peer IP. In this case, a unique proxy ID for each IPsec SA must be specified. For some third-party vendors, the proxy ID must be manually entered to match.

  • Another common reason for IPsec failure is not specifying the ST interface binding. If IPsec cannot complete, check the kmd log or set trace options.

Test Traffic Flow Across the VPN

Purpose

Verify the traffic flow across the VPN.

Action

Use the ping command from the Host1 device to test traffic flow to Host2.

Meaning

If the ping command fails from Host1, there might be a problem with the routing, security policies, end host, or encryption and decryption of ESP packets.

Review Statistics and Errors for an IPsec Security Association

Purpose

Review ESP and authentication header counters and errors for an IPsec security association.

Action

From operational mode, enter the show security ipsec statistics index index_number command, using the index number of the VPN for which you want to see statistics.

You can also use the show security ipsec statistics command to review statistics and errors for all SAs.

To clear all IPsec statistics, use the clear security ipsec statistics command.

Meaning

If you see packet loss issues across a VPN, run the show security ipsec statistics or show security ipsec statistics detail command several times to confirm if the encrypted and decrypted packet counters are incrementing. Look in the command output for any incrementing error counters.