Libreswan Documentation

Logo

Libreswan's Online Documentation

View the Project on GitHub libreswan/libreswan.github.io

Support
FAQ Common Error Messages
History
Implemented Standards
Kernel Support
HOWTO Additional ipsec.conf documentation
AWS Mesh
brendans Road Warrior Setup at Home
Configuration examples
Confuse !?@: github wiki
Enterprise cloud encryption
Entropy matters
EoIP shared ethernet LAN using IPsec
High Availability Fallover VPN in AWS
Host to host VPN
Host to host VPN with PSK
Libreswan as client to a Cisco ASA or VPN3000 server
Microsoft Azure configuration
Migrate from IKEv1 DPD to IKEv2 LIVENESS
Opportunistic IPsec
Opportunistic IPsec using LetsEncrypt
Pluto and DNSSEC
Read status output
Route based VPN
SElinux and Labeled IPsec VPN
Subnet extrusion
Subnet to subnet using NAT
Subnet to subnet VPN
Subnet to subnet VPN with PSK
Unauthenticated Opportunistic IPsec
Using Apache to serve PKCS
Using NSS Hardware Tokens
Using NSS with libreswan
VPN server for remote clients using IKEv2
VPN server for remote clients using IKEv2 split VPN
GSoC 2027 Code Project Ideas DRAFT
Contributor Guidance DRAFT
Completed Projects 2026 RFC 9593 Announcing Supported Authentication Methods in IKEv2
2026 Improve the ACQUIRE to IKE policy lookup
2026 Add HOST TO HOST Support on BSD
2021 RFC 8420 Add EdDSA Signature Authentication Support to IKEv2
2020 Session Resumption
2020 IKEv2 Interop testing with OpenBSD
2020 IKE Intermediate Exchange
2019 Libreswan Opportunistic IPsec using LetsEncrypt
2018 RSA PSS Support in compliance with RFC 7427 and RFC 8247
2018 RFC 7427 Add ECDSA Signature Authentication Support to IKEv2
2018 RFC 5685 Redirect Mechanism
2018 Managing Interface
2017 TCP encapsulation of IKE and IPsec
2017 RFC 7427 Add Signature Authentication Support to IKEv2
2017 Postquantum Preshared Keys
Presentations
IRC
Hacking Documentation
Git, GitHub, and Pull Requests
Merging GitHub Pull Requests
Programming Conventions
Testing Docker
KVM 1. Setup The Host
2. Configure Testing
3. Compile Libreswan
4. Test Libreswan
5. Accessing The Console
6. Maintenance and Internals
Bisecting
Debugging Pluto
Logging In Using SSH
Performance
Running A Custom Kernel
Running A Single Test
Running In The Background
Setup a Web Server
Testing Old Branches
Updating Test Results
Namespace Magic
Namespaces
Topology
Internals 3.14 X509
Benchmarking and Performance testing
Cipher suites and algorithm support
Cloud OE ideas
Compiling with AddressSanitizer
Compliance of RFC 7427 Signature Authentication in IKEv2
Coverity
Cryptographic Acceleration
Developer links strongswan android
Discouraged or forbidden C functions
IKEv2 Child SA
IKEv2 CP and EAP support
Introduction
Libreswan xfrm kernel support
Logging cleanup
New OE
Pluto
Pluto packet processing
Proposed ipsec ca command
Retransmit timings
Road Map
SAref code
Setting up system for debug logging
stf status
Testing 2017 Next Generation
Unbound
Uncrustify
Use Cases and Requirements document for ECC ECDSA support
Use Cases and Requirements document
XFRM Interface Development Notes
XFRM pCPU
XFRM pCPU RSS
Security Crypto boundary and certification
Libreswan and Heartbleed
Libreswan and TunnelCrack
Reporting a Vulnerability
Vulnerabilities
Meetups 2013 Helsinki
2014 San Francisco
2014 Toronto
2018 Toronto
Obsolete HOWTOs IKEv1 XAUTH with FreeOTP and FreeIPA
IKEv1 XAUTH with Google Authenticator One Time Passwords
Route based VPN using VTI
Testing Namespace
VPN server for remote clients using IKEv1 with L2TP
VPN server for remote clients using IKEv1 XAUTH with Certificates
VPN server for remote clients using IKEv1 XAUTH with PSK

Classic VPNs provide encryption and authentication of hosts or users based on an existing and configured relationship. This can be an enterprise VPN, or a VPN service provider.

The goal of Opportunistic IPsec is to attempt to encrypt ALL communications between any two host without requiring a trust relationship or preconfiguration. That is, the goal is to encrypt the entire internet.

QUICKSTART:

# install libreswan-3.19 or higher using apt-get, yum or dnf
cd /etc/ipsec.d
wget https://raw.githubusercontent.com/libreswan/libreswan/master/docs/examples/oe-upgrade-authnull.conf
ipsec restart
# test by pinging a known Opportunistic IPsec site:
ping oe.libreswan.org
ipsec whack --trafficstatus

How does Opportunistic IPsec work?

The IKEv2 protocol is used to negotiate the symmetric encryption keys for the IPsec subsystem in the kernel. The kernel then takes care of encrypting and decrypting the traffic between the hosts.

The IKE daemon is responsible for this negotiation. It uses encryption itself to protect the IKE communication between the hosts. Therefor, IKE communication consists roughly of two parts:

To setup a secure channel, the IKE protocol first performs a DiffieHellman Key Exchange. Then the peers authenticate each other. Once authenticated, symmetric keys for the kernel are derived.

The IKE daemon can also tell the kernel which traffic it wants to be notified for, so it can initiate IKE. For Opportunistic IPsec, the libreswan IKE daemon basically tells the kernel it is interested in all traffic. Once traffic for a new IP is received or ready to be sent, the kernel will inform the IKE daemon. The IKE daemon will attempt to setup an IPsec tunnel. If that is not possible, for instance because the other end does not support Opportunistic IPsec, the IKE daemon tells the kernel to let that traffic go unencrypted. The IKE daemon manages the established tunnels and cleartext passes. It will keep active IPsec tunnels alive and terminate idle IPsec tunnels. It also expires the cleartext passes to try and upgrade those to IPsec tunnels as well.

The biggest issue is how to authenticate someone you never communicated with before. And IKE/IPsec in the past required both parties to identify itself. However, as of IKEv2 and specifically since [https://tools.ietf.org/html/rfc7619 RFC-7619[, the IKE protocol allows a special NULL authentication. We use this to provide different levels of authentication and protection

Opportunistic IPsec is always host-to-host, meaning IPsec tunnels are only setup for the hosts themselves. Since there is no method to securely convey ownership of a certain IP address, an Opportunistic IPsec host can never be trusted to talk on another IP’s behalf.

Types of Opportunistic Encryption

Work is being done to implement all three types of Opportunistic IPsec. As of version 3.16, libreswan supports unauthenticated encryption.

Configuring Opportunistic unauthenticated IPsec

To configure libreswan, simply download the configuration file oe-upgrade-authnull.conf and place it in the /etc/ipsec.d directory.

You can tune for which IP ranges you want to try Opportunistic IPsec. You can configure these ranges to be passive or active. Passive means the system will respond and accept IKE requests for IPsec, but it will never attempt to initiate it. This can be used on busy servers where it is expected that only few clients connecting to it will support Opportunistic IPsec. Active means that the system will always attempt to initiate IKE.

The passive IP ranges are configured in /etc/ipsec.d/policies/clear-or-private

The active IP ranges are configuref in /etc/ipsec.d/private-or-clear.

Per default, 0.0.0.0/0 is places in the active range.

Simply restart libreswan and Opportunistic IPsec will be enabled.

Monitoring the sytem for IPsec tunnels

There are three important commands to get information about IPsec tunnels and Shunts. Shunts are placed in the kernel to allow cleartext, once the IKE daemon determined it cannot setup IPsec.

This will show the active IPsec tunnels

This will show the active shunts. The ones labeled “acquire” are currently in an IKE negotiation. The ones labeled “oe-failing” are shunts installed due to IKE failures.

This will give a lot of developer specific internal status of the IKE daemon.

Test hosts

If you want to test Opportunistic IPsec, you can do so by sending traffic to any *.libreswan.org or *.nohats.ca host. If you browse to oe.libreswan.org it will inform you whether or not your connection has been encrypted with Opportunistic IPsec.

Below follows an example output from the commandline:

[root@oe1 ~]# ipsec whack --trafficstatus
000
006 #3225: "private-or-clear#193.110.157.0/24"[2] ...193.110.157.124, type=ESP,  add_time=1450417506, inBytes=252, outBytes=252, id='ID_NULL'
006 #3229: "private-or-clear#193.110.157.0/24"[4] ...193.110.157.131, type=ESP,  add_time=1450417537, inBytes=252, outBytes=252, id='ID_NULL'
006 #3234: "private-or-clear#193.110.157.0/24"[774] ...193.110.157.130, type=ESP,  add_time=1450417774, inBytes=0, outBytes=0, id='ID_NULL'
000
[root@oe1 ~]# ping -c 2 libreswan.org
PING libreswan.org (188.127.201.229) 56(84) bytes of data.
64 bytes from libreswan.org (188.127.201.229): icmp_seq=2 ttl=64 time=25.1 ms
64 bytes from libreswan.org (188.127.201.229): icmp_seq=3 ttl=64 time=25.2 ms
--- libreswan.org ping statistics ---
4 packets transmitted, 2 received, 50% packet loss, time 3002ms
rtt min/avg/max/mdev = 25.161/25.185/25.210/0.160 ms
[root@oe1 ~]# ipsec whack --trafficstatus
000
006 #3238: "clear-or-private#0.0.0.0/0"[2] ...188.127.201.229, type=ESP,  add_time=1450417921, inBytes=252, outBytes=252, id='ID_NULL'
006 #3225: "private-or-clear#193.110.157.0/24"[2] ...193.110.157.124, type=ESP,  add_time=1450417506, inBytes=252, outBytes=252, id='ID_NULL'
006 #3229: "private-or-clear#193.110.157.0/24"[4] ...193.110.157.131, type=ESP,  add_time=1450417537, inBytes=252, outBytes=252, id='ID_NULL'
006 #3236: "private-or-clear#193.110.157.0/24"[775] ...193.110.157.130, type=ESP,  add_time=1450417894, inBytes=0, outBytes=0, id='ID_NULL'
000

[root@oe1 ~]# ipsec whack --shuntstatus
000 Bare Shunt list:
000
000 193.110.157.129/32:0 -0-> 193.110.157.123/32:0 => %pass 0    oe-failing