- ipsec.secrets配置文件可寫成 : PSK "psk" 會讀取ipsec.conf 的 left 和 right 配置
- type=start 可自動觸發協商
strongswan up dualistic
type=route | add 需要手動觸發協商
strongswan down dualistic
-
conn %default #定義連接項, 命名為 %default 所有連接都會繼承它 compress = yes #是否啟用壓縮, yes 表示如果支持壓縮會啟用. dpdaction = hold #當意外斷開后嘗試的操作, hold, 保持並重連直到超時. dpddelay = 30s #意外斷開后嘗試重連時長 dpdtimeout = 60s #意外斷開后超時時長, 只對 IKEv1 起作用 inactivity = 300s #閑置時長,超過后斷開連接. leftdns = 8.8.8.8,8.8.4.4 #指定服務端與客戶端的dns, 多個用","分隔 rightdns = 8.8.8.8,8.8.4.4
leftsendcert = always #是否發送服務器證書到客戶端
rightsendcert = never #客戶端不發送證書 -
conn IKEv2-EAP keyexchange=ikev2 #默認的密鑰交換算法, ike 為自動, 優先使用 IKEv2 left=%any #服務器端標識,%any表示任意 leftid= 你的服務器公網ip #服務器端ID標識,你的服務器公網ip(99.99.99.99) leftsubnet=0.0.0.0/0 #服務器端虛擬ip, 0.0.0.0/0表示通配. leftcert = server.cert.pem #服務器端證書 leftauth=pubkey #服務器校驗方式,使用證書 right=%any #客戶端標識,%any表示任意 rightsourceip = 10.1.0.0/16 #客戶端IP地址分配范圍 rightauth=eap-mschapv2 #eap-md5#客戶端校驗方式#KEv2 EAP(Username/Password) also=IKEv2-BASE eap_identity = %any #指定客戶端eap id rekey = no #不自動重置密鑰 fragmentation = yes #開啟IKE 消息分片 auto = add #當服務啟動時, 應該如何處理這個連接項. add 添加到連接表中.
-
#ipsec.secrets - strongSwan IPsec secrets file #使用證書驗證時的服務器端私鑰 #格式 : RSA <private key file> [ <passphrase> | %prompt ] : RSA server.key.pem #使用預設加密密鑰, 越長越好 #格式 [ <id selectors> ] : PSK <secret> admin : PSK "123456" #EAP 方式, 格式同 psk 相同 (用戶名/密碼 例:oneAA/oneTT) admin : EAP "123456" #XAUTH 方式, 只適用於 IKEv1 #格式 [ <servername> ] <username> : XAUTH "<password>" admin : XAUTH "123456"