The swanctl command is a powerful tool in the strongSwan suite used for managing and configuring IPsec and IKEv2 connections. It allows you to load, list, initiate, terminate, and monitor VPN connections based on the configuration files in the /etc/swanctl/ directory.
Purpose
swanctl provides a command-line interface for managing the strongSwan IPsec daemon (Charon). It interacts with the configurations defined in swanctl.conf and other related files in /etc/swanctl/.
Common swanctl Commands
Loading Configuration
Load all configurations: This command reads all configurations defined in /etc/swanctl/ and loads them into the strongSwan daemon.
sudoswanctl--load-all
Listing Configurations and Status
List all connection configurations: Displays the connection profiles defined in the configuration files.
sudoswanctl--list-conns
List active security associations (SAs): Shows currently active IPsec tunnels and their status.
sudoswanctl--list-sas
List loaded pools: Lists IP address pools loaded into strongSwan.
sudoswanctl--list-pools
Managing Connections
Initiate a connection: Manually start a VPN connection based on a specific child SA name.
sudoswanctl--initiate--child<child-sa-name>
Terminate a connection: Manually stop a VPN connection based on a specific child SA name.
sudoswanctl--terminate--child<child-sa-name>
Managing Certificates and Keys
List certificates: Display all loaded certificates.
sudoswanctl--list-certs
Load a certificate: Load a specific certificate file.
sudoswanctl--load-creds
Debugging and Logging
Show active log levels: Display the current logging levels and modules.
sudoswanctl--loglevel
Example Usage of swanctl
Loading Configuration
To load all configurations, use:
Listing Connections
To list all configured connections:
Example output:
Initiating and Terminating Connections
To initiate a connection named net:
To terminate the same connection:
Configuration in /etc/swanctl/
swanctl.conf
Here is a detailed example of a swanctl.conf configuration file:
Conclusion
The swanctl command is a crucial tool for managing strongSwan's IPsec and IKEv2 VPN connections. By leveraging the configurations defined in /etc/swanctl/, administrators can easily load, initiate, and monitor secure VPN connections. Proper understanding and usage of swanctl commands ensure efficient and secure management of VPN infrastructure.