strongswan.conf.5.tail 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. .SH LOGGER CONFIGURATION
  2. Options in
  3. .BR strongswan.conf (5)
  4. provide a much more flexible way to configure loggers for the IKE daemon charon
  5. than using the
  6. .B charondebug
  7. option in
  8. .BR ipsec.conf (5).
  9. .PP
  10. .BR Note :
  11. If any loggers are specified in strongswan.conf,
  12. .B charondebug
  13. does not have any effect.
  14. .PP
  15. There are currently two types of loggers:
  16. .TP
  17. .B File loggers
  18. Log directly to a file and are defined by specifying an arbitrarily named
  19. subsection in the
  20. .B charon.filelog
  21. section. The full path to the file is configured in the \fIpath\fR setting of
  22. that subsection, however, if it only contains characters permitted in section
  23. names, the setting may also be omitted and the path specified as name of the
  24. subsection. To log to the console the two special filenames
  25. .BR stdout " and " stderr
  26. may be used.
  27. .TP
  28. .B Syslog loggers
  29. Log into a syslog facility and are defined by specifying the facility to log to
  30. as the name of a subsection in the
  31. .B charon.syslog
  32. section. The following facilities are currently supported:
  33. .BR daemon " and " auth .
  34. .PP
  35. Multiple loggers can be defined for each type with different log verbosity for
  36. the different subsystems of the daemon.
  37. .SS Subsystems
  38. .TP
  39. .B dmn
  40. Main daemon setup/cleanup/signal handling
  41. .TP
  42. .B mgr
  43. IKE_SA manager, handling synchronization for IKE_SA access
  44. .TP
  45. .B ike
  46. IKE_SA
  47. .TP
  48. .B chd
  49. CHILD_SA
  50. .TP
  51. .B job
  52. Jobs queueing/processing and thread pool management
  53. .TP
  54. .B cfg
  55. Configuration management and plugins
  56. .TP
  57. .B knl
  58. IPsec/Networking kernel interface
  59. .TP
  60. .B net
  61. IKE network communication
  62. .TP
  63. .B asn
  64. Low-level encoding/decoding (ASN.1, X.509 etc.)
  65. .TP
  66. .B enc
  67. Packet encoding/decoding encryption/decryption operations
  68. .TP
  69. .B tls
  70. libtls library messages
  71. .TP
  72. .B esp
  73. libipsec library messages
  74. .TP
  75. .B lib
  76. libstrongwan library messages
  77. .TP
  78. .B tnc
  79. Trusted Network Connect
  80. .TP
  81. .B imc
  82. Integrity Measurement Collector
  83. .TP
  84. .B imv
  85. Integrity Measurement Verifier
  86. .TP
  87. .B pts
  88. Platform Trust Service
  89. .SS Loglevels
  90. .TP
  91. .B -1
  92. Absolutely silent
  93. .TP
  94. .B 0
  95. Very basic auditing logs, (e.g. SA up/SA down)
  96. .TP
  97. .B 1
  98. Generic control flow with errors, a good default to see what's going on
  99. .TP
  100. .B 2
  101. More detailed debugging control flow
  102. .TP
  103. .B 3
  104. Including RAW data dumps in Hex
  105. .TP
  106. .B 4
  107. Also include sensitive material in dumps, e.g. keys
  108. .SS Example
  109. .PP
  110. .EX
  111. charon {
  112. filelog {
  113. charon {
  114. path = /var/log/charon.log
  115. time_format = %b %e %T
  116. append = no
  117. default = 1
  118. }
  119. stderr {
  120. ike = 2
  121. knl = 3
  122. ike_name = yes
  123. }
  124. }
  125. syslog {
  126. # enable logging to LOG_DAEMON, use defaults
  127. daemon {
  128. }
  129. # minimalistic IKE auditing logging to LOG_AUTHPRIV
  130. auth {
  131. default = -1
  132. ike = 0
  133. }
  134. }
  135. }
  136. .EE
  137. .SH JOB PRIORITY MANAGEMENT
  138. Some operations in the IKEv2 daemon charon are currently implemented
  139. synchronously and blocking. Two examples for such operations are communication
  140. with a RADIUS server via EAP-RADIUS, or fetching CRL/OCSP information during
  141. certificate chain verification. Under high load conditions, the thread pool may
  142. run out of available threads, and some more important jobs, such as liveness
  143. checking, may not get executed in time.
  144. .PP
  145. To prevent thread starvation in such situations job priorities were introduced.
  146. The job processor will reserve some threads for higher priority jobs, these
  147. threads are not available for lower priority, locking jobs.
  148. .SS Implementation
  149. Currently 4 priorities have been defined, and they are used in charon as
  150. follows:
  151. .TP
  152. .B CRITICAL
  153. Priority for long-running dispatcher jobs.
  154. .TP
  155. .B HIGH
  156. INFORMATIONAL exchanges, as used by liveness checking (DPD).
  157. .TP
  158. .B MEDIUM
  159. Everything not HIGH/LOW, including IKE_SA_INIT processing.
  160. .TP
  161. .B LOW
  162. IKE_AUTH message processing. RADIUS and CRL fetching block here
  163. .PP
  164. Although IKE_SA_INIT processing is computationally expensive, it is explicitly
  165. assigned to the MEDIUM class. This allows charon to do the DH exchange while
  166. other threads are blocked in IKE_AUTH. To prevent the daemon from accepting more
  167. IKE_SA_INIT requests than it can handle, use IKE_SA_INIT DROPPING.
  168. .PP
  169. The thread pool processes jobs strictly by priority, meaning it will consume all
  170. higher priority jobs before looking for ones with lower priority. Further, it
  171. reserves threads for certain priorities. A priority class having reserved
  172. .I n
  173. threads will always have
  174. .I n
  175. threads available for this class (either currently processing a job, or waiting
  176. for one).
  177. .SS Configuration
  178. To ensure that there are always enough threads available for higher priority
  179. tasks, threads must be reserved for each priority class.
  180. .TP
  181. .BR charon.processor.priority_threads.critical " [0]"
  182. Threads reserved for CRITICAL priority class jobs
  183. .TP
  184. .BR charon.processor.priority_threads.high " [0]"
  185. Threads reserved for HIGH priority class jobs
  186. .TP
  187. .BR charon.processor.priority_threads.medium " [0]"
  188. Threads reserved for MEDIUM priority class jobs
  189. .TP
  190. .BR charon.processor.priority_threads.low " [0]"
  191. Threads reserved for LOW priority class jobs
  192. .PP
  193. Let's consider the following configuration:
  194. .PP
  195. .EX
  196. charon {
  197. processor {
  198. priority_threads {
  199. high = 1
  200. medium = 4
  201. }
  202. }
  203. }
  204. .EE
  205. .PP
  206. With this configuration, one thread is reserved for HIGH priority tasks. As
  207. currently only liveness checking and stroke message processing is done with
  208. high priority, one or two threads should be sufficient.
  209. .PP
  210. The MEDIUM class mostly processes non-blocking jobs. Unless your setup is
  211. experiencing many blocks in locks while accessing shared resources, threads for
  212. one or two times the number of CPU cores is fine.
  213. .PP
  214. It is usually not required to reserve threads for CRITICAL jobs. Jobs in this
  215. class rarely return and do not release their thread to the pool.
  216. .PP
  217. The remaining threads are available for LOW priority jobs. Reserving threads
  218. does not make sense (until we have an even lower priority).
  219. .SS Monitoring
  220. To see what the threads are actually doing, invoke
  221. .IR "ipsec statusall" .
  222. Under high load, something like this will show up:
  223. .PP
  224. .EX
  225. worker threads: 2 or 32 idle, 5/1/2/22 working,
  226. job queue: 0/0/1/149, scheduled: 198
  227. .EE
  228. .PP
  229. From 32 worker threads,
  230. .IP 2
  231. are currently idle.
  232. .IP 5
  233. are running CRITICAL priority jobs (dispatching from sockets, etc.).
  234. .IP 1
  235. is currently handling a HIGH priority job. This is actually the thread currently
  236. providing this information via stroke.
  237. .IP 2
  238. are handling MEDIUM priority jobs, likely IKE_SA_INIT or CREATE_CHILD_SA
  239. messages.
  240. .IP 22
  241. are handling LOW priority jobs, probably waiting for an EAP-RADIUS response
  242. while processing IKE_AUTH messages.
  243. .PP
  244. The job queue load shows how many jobs are queued for each priority, ready for
  245. execution. The single MEDIUM priority job will get executed immediately, as
  246. we have two spare threads reserved for MEDIUM class jobs.
  247. .SH IKE_SA_INIT DROPPING
  248. If a responder receives more connection requests per seconds than it can handle,
  249. it does not make sense to accept more IKE_SA_INIT messages. And if they are
  250. queued but can't get processed in time, an answer might be sent after the
  251. client has already given up and restarted its connection setup. This
  252. additionally increases the load on the responder.
  253. .PP
  254. To limit the responder load resulting from new connection attempts, the daemon
  255. can drop IKE_SA_INIT messages just after reception. There are two mechanisms to
  256. decide if this should happen, configured with the following options:
  257. .TP
  258. .BR charon.init_limit_half_open " [0]"
  259. Limit based on the number of half open IKE_SAs. Half open IKE_SAs are SAs in
  260. connecting state, but not yet established.
  261. .TP
  262. .BR charon.init_limit_job_load " [0]"
  263. Limit based on the number of jobs currently queued for processing (sum over all
  264. job priorities).
  265. .PP
  266. The second limit includes load from other jobs, such as rekeying. Choosing a
  267. good value is difficult and depends on the hardware and expected load.
  268. .PP
  269. The first limit is simpler to calculate, but includes the load from new
  270. connections only. If your responder is capable of negotiating 100 tunnels/s, you
  271. might set this limit to 1000. The daemon will then drop new connection attempts
  272. if generating a response would require more than 10 seconds. If you are
  273. allowing for a maximum response time of more than 30 seconds, consider adjusting
  274. the timeout for connecting IKE_SAs
  275. .RB ( charon.half_open_timeout ).
  276. A responder, by default, deletes an IKE_SA if the initiator does not establish
  277. it within 30 seconds. Under high load, a higher value might be required.
  278. .SH LOAD TESTS
  279. To do stability testing and performance optimizations, the IKE daemon charon
  280. provides the \fIload-tester\fR plugin. This plugin allows one to setup thousands
  281. of tunnels concurrently against the daemon itself or a remote host.
  282. .PP
  283. .B WARNING:
  284. Never enable the load-testing plugin on productive systems. It provides
  285. preconfigured credentials and allows an attacker to authenticate as any user.
  286. .PP
  287. .SS Configuration details
  288. For public key authentication, the responder uses the
  289. .B \(dqCN=srv, OU=load-test, O=strongSwan\(dq
  290. identity. For the initiator, each connection attempt uses a different identity
  291. in the form
  292. .BR "\(dqCN=c1-r1, OU=load-test, O=strongSwan\(dq" ,
  293. where the first number indicates the client number, the second the
  294. authentication round (if multiple authentication rounds are used).
  295. .PP
  296. For PSK authentication, FQDN identities are used. The server uses
  297. .BR srv.strongswan.org ,
  298. the client uses an identity in the form
  299. .BR c1-r1.strongswan.org .
  300. .PP
  301. For EAP authentication, the client uses a NAI in the form
  302. .BR 100000000010001@strongswan.org .
  303. .PP
  304. To configure multiple authentication rounds, concatenate multiple methods using,
  305. e.g.
  306. .EX
  307. initiator_auth = pubkey|psk|eap-md5|eap-aka
  308. .EE
  309. .PP
  310. The responder uses a hardcoded certificate based on a 1024-bit RSA key.
  311. This certificate additionally serves as CA certificate. A peer uses the same
  312. private key, but generates client certificates on demand signed by the CA
  313. certificate. Install the Responder/CA certificate on the remote host to
  314. authenticate all clients.
  315. .PP
  316. To speed up testing, the load tester plugin implements a special Diffie-Hellman
  317. implementation called \fImodpnull\fR. By setting
  318. .EX
  319. proposal = aes128-sha1-modpnull
  320. .EE
  321. this wicked fast DH implementation is used. It does not provide any security
  322. at all, but allows one to run tests without DH calculation overhead.
  323. .SS Examples
  324. .PP
  325. In the simplest case, the daemon initiates IKE_SAs against itself using the
  326. loopback interface. This will actually establish double the number of IKE_SAs,
  327. as the daemon is initiator and responder for each IKE_SA at the same time.
  328. Installation of IPsec SAs would fail, as each SA gets installed twice. To
  329. simulate the correct behavior, a fake kernel interface can be enabled which does
  330. not install the IPsec SAs at the kernel level.
  331. .PP
  332. A simple loopback configuration might look like this:
  333. .PP
  334. .EX
  335. charon {
  336. # create new IKE_SAs for each CHILD_SA to simulate
  337. # different clients
  338. reuse_ikesa = no
  339. # turn off denial of service protection
  340. dos_protection = no
  341. plugins {
  342. load-tester {
  343. # enable the plugin
  344. enable = yes
  345. # use 4 threads to initiate connections
  346. # simultaneously
  347. initiators = 4
  348. # each thread initiates 1000 connections
  349. iterations = 1000
  350. # delay each initiation in each thread by 20ms
  351. delay = 20
  352. # enable the fake kernel interface to
  353. # avoid SA conflicts
  354. fake_kernel = yes
  355. }
  356. }
  357. }
  358. .EE
  359. .PP
  360. This will initiate 4000 IKE_SAs within 20 seconds. You may increase the delay
  361. value if your box can not handle that much load, or decrease it to put more
  362. load on it. If the daemon starts retransmitting messages your box probably can
  363. not handle all connection attempts.
  364. .PP
  365. The plugin also allows one to test against a remote host. This might help to
  366. test against a real world configuration. A connection setup to do stress
  367. testing of a gateway might look like this:
  368. .PP
  369. .EX
  370. charon {
  371. reuse_ikesa = no
  372. threads = 32
  373. plugins {
  374. load-tester {
  375. enable = yes
  376. # 10000 connections, ten in parallel
  377. initiators = 10
  378. iterations = 1000
  379. # use a delay of 100ms, overall time is:
  380. # iterations * delay = 100s
  381. delay = 100
  382. # address of the gateway
  383. remote = 1.2.3.4
  384. # IKE-proposal to use
  385. proposal = aes128-sha1-modp1024
  386. # use faster PSK authentication instead
  387. # of 1024bit RSA
  388. initiator_auth = psk
  389. responder_auth = psk
  390. # request a virtual IP using configuration
  391. # payloads
  392. request_virtual_ip = yes
  393. # enable CHILD_SA every 60s
  394. child_rekey = 60
  395. }
  396. }
  397. }
  398. .EE
  399. .SH IKEv2 RETRANSMISSION
  400. Retransmission timeouts in the IKEv2 daemon charon can be configured globally
  401. using the three keys listed below:
  402. .PP
  403. .RS
  404. .nf
  405. .BR charon.retransmit_base " [1.8]"
  406. .BR charon.retransmit_timeout " [4.0]"
  407. .BR charon.retransmit_tries " [5]"
  408. .BR charon.retransmit_jitter " [0]"
  409. .BR charon.retransmit_limit " [0]"
  410. .fi
  411. .RE
  412. .PP
  413. The following algorithm is used to calculate the timeout:
  414. .PP
  415. .EX
  416. relative timeout = retransmit_timeout * retransmit_base ^ (n-1)
  417. .EE
  418. .PP
  419. Where
  420. .I n
  421. is the current retransmission count. The calculated timeout can't exceed the
  422. configured retransmit_limit (if any), which is useful if the number of retries
  423. is high.
  424. .PP
  425. If a jitter in percent is configured, the timeout is modified as follows:
  426. .PP
  427. .EX
  428. relative timeout -= random(0, retransmit_jitter * relative timeout)
  429. .EE
  430. .PP
  431. Using the default values, packets are retransmitted in:
  432. .TS
  433. l r r
  434. ---
  435. lB r r.
  436. Retransmission Relative Timeout Absolute Timeout
  437. 1 4s 4s
  438. 2 7s 11s
  439. 3 13s 24s
  440. 4 23s 47s
  441. 5 42s 89s
  442. giving up 76s 165s
  443. .TE
  444. .
  445. .SH VARIABLES
  446. .
  447. The variables used above are configured as follows:
  448. .nf
  449. .na
  450. ${piddir} /var/run
  451. ${prefix} /usr/local
  452. ${random_device} /dev/random
  453. ${urandom_device} /dev/urandom
  454. .ad
  455. .fi
  456. .
  457. .SH FILES
  458. .
  459. .nf
  460. .na
  461. /etc/strongswan.conf configuration file
  462. /etc/strongswan.d/ directory containing included config snippets
  463. /etc/strongswan.d/charon/ plugin specific config snippets
  464. .ad
  465. .fi
  466. .
  467. .SH SEE ALSO
  468. \fBipsec.conf\fR(5), \fBipsec.secrets\fR(5), \fBipsec\fR(8), \fBcharon-cmd\fR(8)
  469. .SH HISTORY
  470. Written for the
  471. .UR http://www.strongswan.org
  472. strongSwan project
  473. .UE
  474. by Tobias Brunner, Andreas Steffen and Martin Willi.