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

IKEv1 is obsolete, please migrate to IKEv2

Libreswan’s IKE daemon pluto can use pam for XAUTH authentication (xauthby=pam). One Time Passwords (OTP) can be supported via pam directives. The following example is for using FreeOTP. When using the commands below, the proper pam files will be created for libreswan to use. This example is based on RHEL7 with Red Hat Identity Management using FreeIPA. It assumes the VPN server and the VPN client are part of the same FreeIPA / Kerberos domain.

Create the vpn user and set a temporary initial password. Then change the password to a permanent one:

ipa user-add player1
ipa passwd player1
kinit player1

Now kinit back to admin, and run ‘ipa user-mod’ to enable otp auth for the user:

kinit admin
ipa user-mod player1 --user-auth-type=otp

An OTP token must be created and associated with a user that will be the owner of the token. For both UI and CLI methods, a QR code is displayed when the token is created succesfully. Launch the FreeOTP app on the device and scan the QR code to enable the token.

ipa otptoken-add --type=HOTP --desc=playertoken1 --owner=player1 --algo=sha256 --digits=6

The libreswan server should first be joined to the IPA domain. Use ipa-client-install to do this. See Installing the IPA Client for more information about joining the domain. In order for libreswan to use OTP through PAM, sssd_pam authentication must be included in the PAM stack. The ipa-client-install process will do this for you by default, and there are no other modifications to PAM necessary.

Ensure that the IPA user is resolved and able to log in through SSH using their password+OTP.

getent passwd player1
ssh player1@vpnserver

The following is an example configuration of /etc/ipsec.conf for the VPN server:

config setup
    protostack=netkey
    virtual-private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:25.0.0.0/8,%v4:!192.168.2.0/24

conn vpn-clients
    # left is the server
    left=192.168.1.38
    leftsubnet=192.168.2.0/24
    leftxauthserver=yes
    leftmodecfgserver=yes
    # right is the client
    right=%any
    rightid=@groupname
    rightxauthclient=yes
    rightmodecfgclient=yes
    rightaddresspool=192.168.2.11-192.168.2.20
    modecfgpull=yes
    authby=secret
    xauthby=pam
    ikev2=no
    rekey=no
    auto=add

When using PSK instead of RSA/certificates, also add the PSK into /etc/ipsec.secrets:

@groupname %any : PSK "grouppassword"

An example client configuration for the above server would be:

conn vpnserver
    # left is the server
    left=192.168.1.38
    leftsubnet=192.168.2.0/24
    leftxauthserver=yes
    leftmodecfgserver=yes
    # right is the client
    right=%defaultroute
    rightid=@groupname
    rightxauthclient=yes
    rightmodecfgclient=yes
    rightxauthusername=player1
    # right is client-side
    modecfgpull=yes
    authby=secret
    xauthby=pam
    ikev2=no
    rekey=no
    auto=add

And for PSK create the same /etc/ipsec.secrets as the one listed above for the server.

Now you can connect using the CLI tool on the vpn client:

ipsec start
ipsec auto --up vpnserver

This will look like:

root@client ~]# ipsec auto --up privnet
002 "privnet" #1: initiating Main Mode
104 "privnet" #1: STATE_MAIN_I1: initiate
003 "privnet" #1: received Vendor ID payload [Dead Peer Detection]
003 "privnet" #1: received Vendor ID payload [FRAGMENTATION]
003 "privnet" #1: received Vendor ID payload [XAUTH]
003 "privnet" #1: received Vendor ID payload [RFC 3947]
002 "privnet" #1: enabling possible NAT-traversal with method RFC 3947 (NAT-Traversal)
002 "privnet" #1: transition from state STATE_MAIN_I1 to state STATE_MAIN_I2
106 "privnet" #1: STATE_MAIN_I2: sent MI2, expecting MR2
003 "privnet" #1: NAT-Traversal: Result using RFC 3947 (NAT-Traversal) sender port 500: no NAT detected
002 "privnet" #1: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3
108 "privnet" #1: STATE_MAIN_I3: sent MI3, expecting MR3
002 "privnet" #1: Main mode peer ID is ID_IPV4_ADDR: '192.168.1.38'
002 "privnet" #1: transition from state STATE_MAIN_I3 to state STATE_MAIN_I4
004 "privnet" #1: STATE_MAIN_I4: ISAKMP SA established {auth=PRESHARED_KEY cipher=aes_256 integ=sha group=MODP1536}
040 "privnet" #1: privnet prompt for Password:
Enter passphrase:
002 "privnet" #1: XAUTH: Answering XAUTH challenge with user='player1'
002 "privnet" #1: transition from state STATE_XAUTH_I0 to state STATE_XAUTH_I1
004 "privnet" #1: STATE_XAUTH_I1: XAUTH client - awaiting CFG_set
002 "privnet" #1: XAUTH: Successfully Authenticated
002 "privnet" #1: transition from state STATE_XAUTH_I0 to state STATE_XAUTH_I1
004 "privnet" #1: STATE_XAUTH_I1: XAUTH client - awaiting CFG_set
002 "privnet" #1: modecfg: Sending IP request (MODECFG_I1)
005 "privnet" #1: Received IPv4 address: 192.168.2.11/32
005 "privnet" #1: Received IP4 NETMASK 255.255.255.0
002 "privnet" #1: transition from state STATE_MODE_CFG_I1 to state STATE_MAIN_I4
004 "privnet" #1: STATE_MAIN_I4: ISAKMP SA established
002 "privnet" #2: initiating Quick Mode PSK+ENCRYPT+TUNNEL+PFS+DONT_REKEY+UP+XAUTH+MODECFG_PULL+IKEV1_ALLOW+SAREF_TRACK+IKE_FRAG_ALLOW {using isakmp#1 msgid:8272c01d proposal=defaults pfsgroup=OAKLEY_GROUP_MODP1536}
117 "privnet" #2: STATE_QUICK_I1: initiate
002 "privnet" #2: transition from state STATE_QUICK_I1 to state STATE_QUICK_I2
004 "privnet" #2: STATE_QUICK_I2: sent QI2, IPsec SA established tunnel mode {ESP=>0x564532aa <0x6f1f5941 xfrm=AES_128-HMAC_SHA1 NATOA=none NATD=none DPD=passive XAUTHuser=player1}
[root@client ~]#

You can confirm the tunnel as well using:

ipsec whack --trafficstatus