SRX AutoVPN / PSK with Linux strongSwan¶
An example of SRX AutoVPN functionality with Pre-Shared Keys in 3rd party mode; specifically with Linux/strongSwan spokes.
While PKI-based AutoVPN in proprietary and interoperable modes has been prevalent in large-scale IPSEC VPN deployments, the PKI prerequisite can be challenging for smaller scenarios. Finally, Junos 23.4 addresses a significant drawback of PSK-based AutoVPN by eliminating the potential imminent need to change PSKs across the entire deployment.
Introduction¶
TL;DR¶
AutoVPN is essentially an IPSEC VPN approach, initially known as Zero Touch Hub, where dynamically addressed spokes (initiators) can establish tunnels as long as the spoke IKE-ID matches the configured common part on the hub (responder). In PKI mode, the spoke must possess a certificate signed by a trusted CA for mutual certificate authentication (implying a match of the IKE-ID to the appropriate certificate attribute). In a scenario with Juniper spokes, dynamic routing is typically engaged, allowing Auto-Discovery VPN extension for spoke-to-spoke on-demand shortcut tunnels. To achieve a large tunnel scale, with or without Juniper spokes, AutoVPN can leverage Traffic Selectors (TS) from remote spokes for Reverse Route Injection -- routes matching remote TS are typically exported to a dynamic routing protocol.
Since the introduction of AutoVPN, the common challenge has been the PKI infrastructure and the required level of knowledge to implement. That has been somewhat alleviated by Junos 22.4 support of ACME protocol and Let's Encrypt, making PKI partially instant, but not addressing all scenarios. The Junos 21.2 AutoVPN PSK support -- either common or spoke-specific (seeded) -- did not cover scenarios where the spoke PSK could potentially be compromised (e.g., physical device loss). Those specific IKE-IDs can still establish connections even in the seeded PSK mode. The only complete solution was to change PSKs throughout, incurring a cost for the initially easy setup. In the PKI scenario, the administrator would revoke the specific spoke certificate. Finally, as part of Junos 23.4 IKE DoS/DDoS handling improvements, administrators can block certain IKE-ID(s) from establishing tunnels. This makes the PSK-based AutoVPN in seeded mode appealing, especially for VPNs with 3rd party equipment where the protection of the PKI material may not be assured. Therefore, let's look at an example of strongSwan, the comprehensive multi-platform OSS IKE protocols implementation, establishing IPSEC tunnel to SRX PSK based AutoVPN hub (IKED enabled vSRX instance, generally any platforms supporting IKED). For completeness, a slightly modified configuration covering PKI-based configuration is described in Appendix 1.
The Demo Setup¶
The Demo setup consists of two Debian Linux 12 instances and a single vSRX Junos 23.4 AutoVPN hub. For demo purposes, Linux is the remote endpoint itself by utilizing a trick with a dummy interface and iproute2 features - all traffic directed towards remote TS prefixes is sourced from the dummy interface IP 172.16.0.x (effectively local TS), as illustrated below by using 'src' argument with 'ip route' commands. That triggers Linux side tunneling based on routing settings while routing on the SRX hub side is constructed based on the received TS. Otherwise, a route-based VPN on Linux would present 0/0 as remote and local TS.

Note: the use of two prefixes in remote TS config within single CHILD-SA. That's supported with Junos 21.1 on IKED enabled platforms.
SRX Configuration¶
As a pre-requisite IKED must be deployed, vSRX 23.4 has by default older KMD IKE control daemon.
Note: platforms like SRX1600/2300/4300 and SPC3 have already IKED installed, branch SRX doesn't support IKED. Corresponding command on vSRX:
Then, skeleton SRX sample configuration with seeded-pre-shared key, match on common part of remote IKE-ID (hostname type), 0/0 TS for narrowing, and policy permitting all traffic between VPNs and trust zone:
Linux Networking Configuration¶
The first thing to configure is the network interfaces, settings are typically located on Debian Linux in the /etc/network/interfaces file. Lines with 'up' are executed after bringing up the ens7 interface, effectively configuring the dummy interface and routing for use with IPSEC. Below is an example for spoke-01; spoke-02 would simply reflect other IP addresses for the ens7 and dummy0 interfaces.
Upon 'ifup ens7' or rebooting, the following routes are supposed to be present among others:
Note: best practice is to ensure no forwarding to remote prefixes without tunneling and properly protect the Linux side using firewall (nftables or legacy iptables syntax).
Linux strongSwan Configuration¶
Minimal strongSwan packages on Debian Linux 12, handy for copy/pasting as list of packages to apt install (brings in necessary dependencies):
Next step is to generate spoke-01 specific (seeded) PSK on the SRX:
Then, on corresponding Linux /etc/swanctl/swanctl.conf IKEv2 VPN example settings, most notable are sections with indefinite connection attempts and two remote TS within one CHILD-SA. It is advisable to disable MOBIKE, otherwise traffic would be NAT-T UDP encapsulated even without NAT in the path. NAT-T will still engage when needed. Settings for spoke-02 would just reflect another local TS and IKE-ID.
Finally, restart strongSwan:
Verification¶
IKE and CHILD-SA listing on the Linux side:
IKE peers and CHILD-SAs on the SRX:
SRX TS narrowed from locally configured 0/0 to spoke proposed TS:
SRX ARI (Auto Route Insertion, AKA RRI -- Reverse Route Injection) routes:
Note: both route metric and preference can be configured per traffic selector under [ security ipsec vpn vpn-name traffic-selector ]
Finally, traffic verification on Linux spoke-01:
And corresponding session listing on the SRX:
Note: an important factor for VPNs is proper MTU handling. Normally the SRX configuration also contains MSS override for VPN traffic.
Blocking Certain IKE-ID on the SRX¶
AutoVPN is designed to accommodate dynamic endpoints, therefore, policy in the junos-host zone context narrowing down VPN peers by IP addresses does not guarantee a mapping between permitted VPN peers and IKE-IDs. This is where Junos 23.4 introduces an enhancement, allowing certain IKE-ID patterns to be blocked. For demonstration purposes, let's consider a scenario where, spoke-01 (identified by the spoke-01.autovpn-01.domain hostname IKE-ID) can no longer be trusted.
SRX configuration stanzas blocking spoke-01:
Corresponding SRX logs upon clearing IKE SA and spoke-01 trying to re-establish VPN:
SRX blocked peer listing and statistics:
Unless the PSK (and its seeded derivates) are changed everywhere, a re-introduced spoke-01 would need to use different IKE-ID (e.g., spoke-01-2.autovpn-01.domain) to prevent compromised IKE-ID/PSK combination from establishing a VPN. That process would have been easier in a PKI setup (configuration notes in Appendix 1 (LINK) ) where the administrator could revoke and issue a new spoke-01 certificate, and the IKE-ID could be re-used. In PSK mode, the blocklist matching compromised IKE-ID can be removed, and IKE-ID re-used after a complete refresh of PSKs.
Appendix 1 -- strongSwan SRX AutoVPN with PKI¶
For completeness of this TechPost, here are sample configuration snippets for PKI-based AutoVPN for both Linux and SRX. The ability to block certain IKE-IDs also applies to PKI scenarios, where, unlike irreversible revocation, the blocklist can serve as a temporary measure, including covering the time before certificate revocation.
swanctl.conf highlighting changed parts on spoke-01:
strongSwan PKI-related directory structure:
Sample spoke-01 certificate in a terse format, in real life certificate would contain also CDP URI/URL (OCSP/CRL) attributes. Subject Alternative Name must match presented IKE-ID and type.
SRX side IKE config and PKI addition, request security pki commands would be used to setup PKI:
SRX certificate matching presented IKE-ID (remote ID from Linux spoke perspective):
Useful links¶
- https://www.juniper.net/documentation/us/en/software/vsrx/vsrx-kvm/topics/concept/security-vsrx-kvm-understanding.html
- https://www.juniper.net/documentation/us/en/software/junos/vpn-ipsec/topics/topic-map/security-autovpn-on-hub-and-spoke-devices.html
- https://www.juniper.net/documentation/us/en/software/junos/vpn-ipsec/topics/topic-map/security-ipsec-vpn-acme-protocol.html
- https://www.juniper.net/documentation/us/en/software/junos/vpn-ipsec/topics/topic-map/security-ipsecvpns-for-ikev2.html#id-understanding-ike-protection-from-ddos-attacks
- https://www.juniper.net/documentation/us/en/software/junos/vpn-ipsec/topics/topic-map/security-digital-certificates-with-pki-overview.html
- https://www.debian.org/distrib/
- https://strongswan.org/
- https://wiki.nftables.org/wiki-nftables/index.php/Main_Page
Glossary¶
- ACME: Automatic Certificate Management Environment
- ARI: Auto Route Insertion
- CDP: CRL Distribution Point
- CRL: Certificate Revocation List
- DPD: Dear Peer Detection
- ESP: Encapsulating Security Payload
- IKE: Internet Key Exchange
- IKE-ID: IKE Identifier
- IPSEC: Internet Protocol Security
- MOBIKE: Mobility and Multihoming Protocol
- OCSP: Online Certificate Status Protocol
- OSS: Open-Source Software
- PKI: Public Key Infrastructure
- PSK: Pre-Shared Key
- RRI: Reverse Route Injection
- SA: Security Association
- SAN: Subject Alternative Name
- TS: Traffic Selector
- URI: Uniform Resource Locator
- VPN: Virtual Private Network
Acknowledgements¶
All the brilliant people I have the pleasure to work closely with -- Mark Barrett, Kelly Brazil, Tim Carlens, Steven Jacques, Matthijs Nagel, and others from team JNPR! Of course, there is no way to make things happen without all the brilliant Open-Source Software. Finally, vSRX/SRX dev and product teams for the security and networking Swiss Army knife they delivered.