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

This is a crib-sheet for using Namespace testing.

Disclaimer

This, along with some quick hacks, and thanks to GSoC candidate feedback, were knocked up during GSoC in 2026.

Please remember that the original author of this page does not normally use namespaces.

Limitations

Hence, creating a dedicate Fedora VM is strongly encouraged.

Create a Fedora VM?

Per above, you’re encouraged to create a dedicated VM. Here’s the virsh command that was used on Debian to build a text-only VM. It was used when writing up the below:

sudo virt-install \
     --extra-args="console=ttyS0,115200 inst.notmux" \
     --graphics=none  \
     --virt-type=kvm  \
     --console=pty,target_type=serial  \
     --network=default \
     --vcpus=2 \
     --memory=4096 \
     --name=libreswan \
     --disk=path=libreswan.qcow2,size=15,bus=virtio,format=qcow2 \
     --location=Fedora-Server-dvd-x86_64-43-1.6.iso

From here on in, it’s assumed you’re logged into Fedora.

Add yourself to sudo

Some of the test scrips need to be run as root. The test environment assumes this can be done using sudo without a password vis:

sudo pwd

This is setup by adding an entry under /etc/sudoers.d/ specifying that your account does not need a password to become root:

echo "$(id -u -n) ALL=(ALL) NOPASSWD: ALL" | sudo dd of=/etc/sudoers.d/$(id -u -n)

Download and Build Libreswan

Install Build Dependencies

sudo dnf install -y cc make flex bison xmlto
sudo dnf install -y nss-devel nss-tools nss-util-devel
sudo dnf install -y libevent-devel unbound-devel audit-libs-devel pam-devel libselinux-devel libseccomp-devel ldns-devel libcurl-devel
sudo dnf install -y git

also useful:

sudo dnf install -y pretty-git-prompt

Download Libreswan

git clone --origin libreswan https://github.com/libreswan/libreswan.git
cd libreswan

Build and Install Libreswan

make -j base
sudo make install-base

base builds just the programs needed for testing (a full install includes documentation and is much slower).

Run a Test

Install Test Dependencies

Assuming a minimal install of Fedora Server:

sudo dnf install -y diffstat
sudo dnf install -y valgrind
sudo dnf install -y strongswan
sudo dnf install -y openssl
sudo dnf install -y bind bind-dnssec-utils
sudo dnf install -y python3-pexpect
sudo dnf install -y socat
sudo dnf install -y netcat
sudo dnf install -y net-tools # ifconfig route
sudo dnf install -y rsync
sudo dnf install -y ocspd
sudo dnf install -y nsd
sudo dnf install -y patch
sudo dnf install -y unbound
sudo dnf install -y fping
sudo dnf install -y jq
sudo dnf install -y checksec
sudo dnf install -y ansible-playbook
sudo dnf install -y linux-system-roles
sudo dnf install -y sshpass
sudo dnf install -y strongswan-sqlite

Generate the PKI keys and signed DNSSEC zones

Many tests expect a PKIX X.509 keys i.e., private keys and certificates. And to test DNSSEC signed zones are needed:

make -C testing/x509
./testing/dnssec/generate-dnssec.sh

The commands to generate keys can be heavily dependent on the platform they are run. This is why ./kvm runs the commands inside a Fedora VM; and why the notes say to use Fedora. Remember, the choice is an historic accident.

This needs to happen once every few weeks.

Try running a single test

cd testing/pluto/basic-pluto-01
../../utils/nsrun --ns

If you’re lucky you’ll get the final output:

nsrunner 22.01: stop testing basic-pluto-01 after 21.6 seconds
nsrunner 22.08: sanitizer output
 east Consoleoutput matched
west Consoleoutput matched
result basic-pluto-01 passed 

To check differences, either look at OUTPUT/*.diff, or run:

../../../kvm diff

Yes, using ./kvm to get the diff.

Accessing the test namespace from a terminal

This magic

NSENTER () {
    ns=$1;
    nsargs="--mount=/run/mountns/${ns} --net=/run/netns/${ns} --uts=/run/utsns/${ns}";
    NSENTER_CMD="/usr/bin/nsenter ${nsargs} ";
    sudo ${NSENTER_CMD} /bin/bash
}
NSENTER east-basic-pluto-01

from Namespace Testing (almost) works!

Just note that scripts expect a magic environment variable to be set; see scripts for details.

Run the entire Testsuite …

Run all good tests

Here’s a quick and dirty command. It extracts a list of good tests to run from TESTLIST, and then feeds them all to namespace-runner.py:

./testing/utils/namespace-runner.py $(awk '/^kvmplutotest.*good/ {print $2}' testing/pluto/TESTLIST )

The problem is that the command assumes namespaces can run all tests. Which is impossible for tests requiring BSD, say.

Run all good linux tests

This uses kvmresults.py (yes the irony) to limit things to just linux tests:

./testing/utils/namespace-runner.py $(/testing/utils/kvmresults.py --test-platform linux --result untested --test-status good  --print test-name testing/pluto/TESTLIST)

The problem, this time, is that namespaces don’t know about the hosts rise and set (and kvmresults.py isn’t the fastest) and re-runs all tests.

Run all good linux failing/untested tests

This version skips tests that have passed:

./testing/utils/namespace-runner.py $(/testing/utils/kvmresults.py --quick --test-platform linux --skip passed --test-status good  --print test-name testing/pluto/TESTLIST)

Run all modified tests

Possibly the most useful:

./testing/utils/namespace-runner.py $(/kvm modified | cut -d/ -f3)

which will run just the tests that have uncommitted modifications.

Expected results

total: 1362
total/failed: 236
total/ignored: 235
total/passed: 878
total/unresolved: 13

after some fixes things have improved:

total  tests: 1135
passed tests: 946
failed tests: 189

but still dismal (KVM can get 0 fails).