在ubuntu20.04上 ,strongSwan安装有两种途径:
1、下载源码编译安装
当前最新版本v5.9.6
安装依赖
apt install gperf
apt install gmp10
apt install libgmp-dev
配置(安装到默认目录)
./configure
举个栗子:
./configure --enable-eap-identity --enable-eap-md5 --enable-eap-mschapv2 --enable-eap-tls --enable-eap-ttls --enable-eap-peap --enable-eap-tnc --enable-eap-dynamic --enable-xauth-eap --enable-dhcp --enable-openssl --enable-addrblock --enable-unity --enable-certexpire --enable-radattr --enable-charon --enable-systemd --enable-vici --enable-swanctl
--enable-systemd:使能systemd管理服务 strongswan.service
编译
make
安装
make install
目录分布
配置文件默认安装在/ usr / local / etc:
- strongswan.conf --------对strongswan运行以及加载做的基本设定
- ipsec.conf -------VPN策略的配置
- ipsec.secrets -------机密秘密
- strongswan.d/ --------Strongswan插件配置
- ipsec.d/ --------用于存放认证证书等文件
- swanctl/
扩展说明
1、通用的配置文件为strongswan.conf,及strongswan.d目录下文件;
2、Used by swanctl and the preferred vici plugin: //推荐使用
需要配置swanctl目录下的文件。主要是swanctl目录下的swanctl.conf文件,如果你保持安装状态的swanctl.conf文件,则需要在swanctl/conf.d目录下增加新的配置文件,默认的swanctl/swanctl.conf文件会包含你新增的配置文件。
3、Used by starter and the deprecated stroke plugin: //过期,不推荐
1)配置ipsec.conf。
2)配置ipsec.secrets。
3)配置ipsec.d下的配置文件。
特别说明:当使用swanctl和starter工具时,需要的配置文件是完全不同的。1的配置是必须,而2和3的配置你可以选择其中之一。为什么要讲这一点,是因为你百度出来的东西很多都是基于各种各样的版本,这个概念没搞清,你的配置无论如何都不会生效。
2、使用 图形界面安装
在packages中,搜索strongswan,即可看到相关软件包
配置
包括2部分:
- 通用配置
- 网络拓扑配置
通用配置主要是配置文件路径、日志信息等等。
网络拓扑配置需要参考官方的例子。在StrongSwan的官网上,我们可以在左侧找到TestScenarios。
日志配置
vim /usr/local/etc/strongswan.d/charon-logging.conf
charon {
# two defined file loggers
filelog {
charon {
# path to the log file, specify this as section name in versions prior to 5.7.0
path = /var/log/charon.log
# add a timestamp prefix
time_format = %b %e %T
# prepend connection name, simplifies grepping
ike_name = yes
# overwrite existing files
append = no
# increase default loglevel for all daemon subsystems
default = 2
# flush each line to disk
flush_line = yes
}
stderr {
# more detailed loglevel for a specific subsystem, overriding the
# default loglevel.
ike = 2
knl = 3
}
}
}
日志等级参考:
-1: Absolutely silent
0: Very basic auditing logs, (e.g. SA up/SA down)
1: Generic control flow with errors, a good default to see whats going on
2: More detailed debugging control flow
3: Including RAW data dumps in hex
4: Also include sensitive material in dumps, e.g. keys
日志文件用来排查建立隧道时出现的问题,是调试strongswan的有效手段:
查看日志信息:tail -f /var/log/charon.log