management-notes.txt 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. OpenVPN Management Interface Notes
  2. ----------------------------------
  3. The OpenVPN Management interface allows OpenVPN to
  4. be administratively controlled from an external program via
  5. a TCP or unix domain socket.
  6. The interface has been specifically designed for developers
  7. who would like to programmatically or remotely control
  8. an OpenVPN daemon, and can be used when OpenVPN is running
  9. as a client or server.
  10. The management interface is implemented using a client/server TCP
  11. connection or unix domain socket where OpenVPN will listen on a
  12. provided IP address and port for incoming management interface client
  13. connections.
  14. The management protocol is currently cleartext without an explicit
  15. security layer. For this reason, it is recommended that the
  16. management interface either listen on a unix domain socket,
  17. localhost (127.0.0.1), or on the local VPN address. It's possible
  18. to remotely connect to the management interface over the VPN itself,
  19. though some capabilities will be limited in this mode, such as the
  20. ability to provide private key passwords.
  21. The management interface is enabled in the OpenVPN
  22. configuration file using the following directive:
  23. --management
  24. See the man page for documentation on this and related
  25. directives.
  26. Once OpenVPN has started with the management layer enabled,
  27. you can telnet to the management port (make sure to use
  28. a telnet client which understands "raw" mode).
  29. Once connected to the management port, you can use
  30. the "help" command to list all commands.
  31. COMMAND -- bytecount
  32. --------------------
  33. The bytecount command is used to request real-time notification
  34. of OpenVPN bandwidth usage.
  35. Command syntax:
  36. bytecount n (where n > 0) -- set up automatic notification of
  37. bandwidth usage once every n seconds
  38. bytecount 0 -- turn off bytecount notifications
  39. If OpenVPN is running as a client, the bytecount notification
  40. will look like this:
  41. >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
  42. BYTES_IN is the number of bytes that have been received from
  43. the server and BYTES_OUT is the number of bytes that have been
  44. sent to the server.
  45. If OpenVPN is running as a server, the bytecount notification
  46. will look like this:
  47. >BYTECOUNT_CLI:{CID},{BYTES_IN},{BYTES_OUT}
  48. CID is the Client ID, BYTES_IN is the number of bytes that have
  49. been received from the client and BYTES_OUT is the number of
  50. bytes that have been sent to the client.
  51. Note that when the bytecount command is used on the server, every
  52. connected client will report its bandwidth numbers once every n
  53. seconds.
  54. When the client disconnects, the final bandwidth numbers will be
  55. placed in the 'bytes_received' and 'bytes_sent' environmental variables
  56. as included in the >CLIENT:DISCONNECT notification.
  57. COMMAND -- echo
  58. ---------------
  59. The echo capability is used to allow GUI-specific
  60. parameters to be either embedded in the OpenVPN config file
  61. or pushed to an OpenVPN client from a server.
  62. Command examples:
  63. echo on -- turn on real-time notification of echo messages
  64. echo all -- print the current echo history list
  65. echo off -- turn off real-time notification of echo messages
  66. echo on all -- atomically enable real-time notification,
  67. plus show any messages in history buffer
  68. For example, suppose you are developing a OpenVPN GUI and
  69. you want to give the OpenVPN server the ability to ask
  70. the GUI to forget any saved passwords.
  71. In the OpenVPN server config file, add:
  72. push "echo forget-passwords"
  73. When the OpenVPN client receives its pulled list of directives
  74. from the server, the "echo forget-passwords" directive will
  75. be in the list, and it will cause the management interface
  76. to save the "forget-passwords" string in its list of echo
  77. parameters.
  78. The management interface client can use "echo all" to output the full
  79. list of echoed parameters, "echo on" to turn on real-time
  80. notification of echoed parameters via the ">ECHO:" prefix,
  81. or "echo off" to turn off real-time notification.
  82. When the GUI connects to the OpenVPN management socket, it
  83. can issue an "echo all" command, which would produce output
  84. like this:
  85. 1101519562,forget-passwords
  86. END
  87. Essentially the echo command allowed us to pass parameters from
  88. the OpenVPN server to the OpenVPN client, and then to the
  89. management interface client (such as a GUI). The large integer is the
  90. unix date/time when the echo parameter was received.
  91. If the management interface client had issued the command "echo on",
  92. it would have enabled real-time notifications of echo
  93. parameters. In this case, our "forget-passwords" message
  94. would be output like this:
  95. >ECHO:1101519562,forget-passwords
  96. Like the log command, the echo command can atomically show
  97. history while simultaneously activating real-time updates:
  98. echo on all
  99. The size of the echo buffer is currently hardcoded to 100
  100. messages.
  101. COMMAND -- exit, quit
  102. ---------------------
  103. Close the management session, and resume listening on the
  104. management port for connections from other clients. Currently,
  105. the OpenVPN daemon can at most support a single management interface
  106. client any one time.
  107. COMMAND -- help
  108. ---------------
  109. Print a summary of commands.
  110. COMMAND -- hold
  111. ---------------
  112. The hold command can be used to manipulate the hold flag,
  113. or release OpenVPN from a hold state.
  114. If the hold flag is set on initial startup or
  115. restart, OpenVPN will hibernate prior to initializing
  116. the tunnel until the management interface receives
  117. a "hold release" command.
  118. The --management-hold directive of OpenVPN can be used
  119. to start OpenVPN with the hold flag set.
  120. The hold flag setting is persistent and will not
  121. be reset by restarts.
  122. OpenVPN will indicate that it is in a hold state by
  123. sending a real-time notification to the management interface
  124. client, the parameter indicates how long OpenVPN would
  125. wait without UI (as influenced by connect-retry exponential
  126. backoff). The UI needs to wait for releasing the hold if it
  127. wants similar behavior:
  128. >HOLD:Waiting for hold release:10
  129. Command examples:
  130. hold -- show current hold flag, 0=off, 1=on.
  131. hold on -- turn on hold flag so that future restarts
  132. will hold.
  133. hold off -- turn off hold flag so that future restarts will
  134. not hold.
  135. hold release -- leave hold state and start OpenVPN, but
  136. do not alter the current hold flag setting.
  137. COMMAND -- kill
  138. ---------------
  139. In server mode, kill a particlar client instance.
  140. Command examples:
  141. kill Test-Client -- kill the client instance having a
  142. common name of "Test-Client".
  143. kill 1.2.3.4:4000 -- kill the client instance having a
  144. source address and port of 1.2.3.4:4000
  145. Use the "status" command to see which clients are connected.
  146. COMMAND -- log
  147. --------------
  148. Show the OpenVPN log file. Only the most recent n lines
  149. of the log file are cached by the management interface, where
  150. n is controlled by the OpenVPN --management-log-cache directive.
  151. Command examples:
  152. log on -- Enable real-time output of log messages.
  153. log all -- Show currently cached log file history.
  154. log on all -- Atomically show all currently cached log file
  155. history then enable real-time notification of
  156. new log file messages.
  157. log off -- Turn off real-time notification of log messages.
  158. log 20 -- Show the most recent 20 lines of log file history.
  159. Real-time notification format:
  160. Real-time log messages begin with the ">LOG:" prefix followed
  161. by the following comma-separated fields:
  162. (a) unix integer date/time,
  163. (b) zero or more message flags in a single string:
  164. I -- informational
  165. F -- fatal error
  166. N -- non-fatal error
  167. W -- warning
  168. D -- debug, and
  169. (c) message text.
  170. COMMAND -- mute
  171. ---------------
  172. Change the OpenVPN --mute parameter. The mute parameter is
  173. used to silence repeating messages of the same message
  174. category.
  175. Command examples:
  176. mute 40 -- change the mute parameter to 40
  177. mute -- show the current mute setting
  178. COMMAND -- net
  179. --------------
  180. (Windows Only) Produce output equivalent to the OpenVPN
  181. --show-net directive. The output includes OpenVPN's view
  182. of the system network adapter list and routing table based
  183. on information returned by the Windows IP helper API.
  184. COMMAND -- pid
  185. --------------
  186. Shows the process ID of the current OpenVPN process.
  187. COMMAND -- password and username
  188. --------------------------------
  189. The password command is used to pass passwords to OpenVPN.
  190. If OpenVPN is run with the --management-query-passwords
  191. directive, it will query the management interface for RSA
  192. private key passwords and the --auth-user-pass
  193. username/password.
  194. When OpenVPN needs a password from the management interface,
  195. it will produce a real-time ">PASSWORD:" message.
  196. Example 1:
  197. >PASSWORD:Need 'Private Key' password
  198. OpenVPN is indicating that it needs a password of type
  199. "Private Key".
  200. The management interface client should respond as follows:
  201. password "Private Key" foo
  202. Example 2:
  203. >PASSWORD:Need 'Auth' username/password
  204. OpenVPN needs a --auth-user-pass username and password. The
  205. management interface client should respond:
  206. username "Auth" foo
  207. password "Auth" bar
  208. The username/password itself can be in quotes, and special
  209. characters such as double quote or backslash must be escaped,
  210. for example,
  211. password "Private Key" "foo\"bar"
  212. The escaping rules are the same as for the config file.
  213. See the "Command Parsing" section below for more info.
  214. The PASSWORD real-time message type can also be used to
  215. indicate password or other types of authentication failure:
  216. Example 3: The private key password is incorrect and OpenVPN
  217. is exiting:
  218. >PASSWORD:Verification Failed: 'Private Key'
  219. Example 4: The --auth-user-pass username/password failed,
  220. and OpenVPN will exit with a fatal error if '--auth-retry none'
  221. (which is the default) is in effect:
  222. >PASSWORD:Verification Failed: 'Auth'
  223. Example 5: The --auth-user-pass username/password failed,
  224. and the server provided a custom client-reason-text string
  225. using the client-deny server-side management interface command.
  226. >PASSWORD:Verification Failed: 'custom server-generated string'
  227. Example 6: If server pushes --auth-token to the client, the OpenVPN
  228. will produce a real-time PASSWORD message:
  229. >PASSWORD:Auth-Token:foobar
  230. Example 7: Static challenge/response:
  231. >PASSWORD:Need 'Auth' username/password SC:1,Please enter token PIN
  232. OpenVPN needs an --auth-user-pass username and password and the
  233. response to a challenge. The user's response to "Please enter
  234. token PIN" should be obtained and included in the management
  235. interface client's response along with the username and password
  236. formatted as described in the Challenge/Response Protocol section
  237. below.
  238. Example 8: Dynamic challenge/response:
  239. >PASSWORD:Verification Failed: ['CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN']
  240. The previous --auth-user-pass username/password failed or is not
  241. fully complete, and the server provided a custom
  242. client-reason-text string indicating that a dynamic
  243. challenge/response should occur the next time that a "Need 'Auth'
  244. username/password" message is seen.
  245. When the next "Need 'Auth' username/password" without a static
  246. challenge is seen, the user's response to "Please enter token PIN"
  247. should be obtained and included in the management interface client's
  248. response along with the username and password formatted as described
  249. in the Challenge/Response Protocol section below
  250. See the "Challenge/Response Protocol" section below for more details
  251. about examples 7 and 8, including how the management interface client
  252. should respond.
  253. COMMAND -- forget-passwords
  254. ---------------------------
  255. The forget-passwords command will cause the daemon to forget passwords
  256. entered during the session.
  257. Command example:
  258. forget-passwords -- forget passwords entered so far.
  259. COMMAND -- signal
  260. -----------------
  261. The signal command will send a signal to the OpenVPN daemon.
  262. The signal can be one of SIGHUP, SIGTERM, SIGUSR1, or SIGUSR2.
  263. Command example:
  264. signal SIGUSR1 -- send a SIGUSR1 signal to daemon
  265. COMMAND -- state
  266. ----------------
  267. Show the current OpenVPN state, show state history, or
  268. enable real-time notification of state changes.
  269. These are the OpenVPN states:
  270. CONNECTING -- OpenVPN's initial state.
  271. WAIT -- (Client only) Waiting for initial response
  272. from server.
  273. AUTH -- (Client only) Authenticating with server.
  274. GET_CONFIG -- (Client only) Downloading configuration options
  275. from server.
  276. ASSIGN_IP -- Assigning IP address to virtual network
  277. interface.
  278. ADD_ROUTES -- Adding routes to system.
  279. CONNECTED -- Initialization Sequence Completed.
  280. RECONNECTING -- A restart has occurred.
  281. EXITING -- A graceful exit is in progress.
  282. RESOLVE -- (Client only) DNS lookup
  283. TCP_CONNECT -- (Client only) Connecting to TCP server
  284. Command examples:
  285. state -- Print current OpenVPN state.
  286. state on -- Enable real-time notification of state changes.
  287. state off -- Disable real-time notification of state changes.
  288. state all -- Print current state history.
  289. state 3 -- Print the 3 most recent state transitions.
  290. state on all -- Atomically show state history while at the
  291. same time enable real-time state notification
  292. of future state transitions.
  293. The output format consists of up to 9 comma-separated parameters:
  294. (a) the integer unix date/time,
  295. (b) the state name,
  296. (c) optional descriptive string (used mostly on RECONNECTING
  297. and EXITING to show the reason for the disconnect),
  298. (d) optional TUN/TAP local IPv4 address
  299. (e) optional address of remote server,
  300. (f) optional port of remote server,
  301. (g) optional local address,
  302. (h) optional local port, and
  303. (i) optional TUN/TAP local IPv6 address.
  304. Fields (e)-(h) are shown for CONNECTED state,
  305. (d) and (i) are shown for ASSIGN_IP and CONNECTED states.
  306. (e) is available starting from OpenVPN 2.1
  307. (f)-(i) are available starting from OpenVPN 2.4
  308. Real-time state notifications will have a ">STATE:" prefix
  309. prepended to them.
  310. COMMAND -- status
  311. -----------------
  312. Show current daemon status information, in the same format as
  313. that produced by the OpenVPN --status directive.
  314. Command examples:
  315. status -- Show status information using the default status
  316. format version.
  317. status 3 -- Show status information using the format of
  318. --status-version 3.
  319. COMMAND -- username
  320. -------------------
  321. See the "password" section above.
  322. COMMAND -- verb
  323. ---------------
  324. Change the OpenVPN --verb parameter. The verb parameter
  325. controls the output verbosity, and may range from 0 (no output)
  326. to 15 (maximum output). See the OpenVPN man page for additional
  327. info on verbosity levels.
  328. Command examples:
  329. verb 4 -- change the verb parameter to 4
  330. verb -- show the current verb setting
  331. COMMAND -- version
  332. ------------------
  333. Show the current OpenVPN and Management Interface versions.
  334. COMMAND -- auth-retry
  335. ---------------------
  336. Set the --auth-retry setting to control how OpenVPN responds to
  337. username/password authentication errors. See the manual page
  338. for more info.
  339. Command examples:
  340. auth-retry interact -- Don't exit when bad username/passwords are entered.
  341. Query for new input and retry.
  342. COMMAND -- needok (OpenVPN 2.1 or higher)
  343. ------------------------------------------
  344. Confirm a ">NEED-OK" real-time notification, normally used by
  345. OpenVPN to block while waiting for a specific user action.
  346. Example:
  347. OpenVPN needs the user to insert a cryptographic token,
  348. so it sends a real-time notification:
  349. >NEED-OK:Need 'token-insertion-request' confirmation MSG:Please insert your cryptographic token
  350. The management interface client, if it is a GUI, can flash a dialog
  351. box containing the text after the "MSG:" marker to the user.
  352. When the user acknowledges the dialog box,
  353. the management interface client should issue either:
  354. needok token-insertion-request ok
  355. or
  356. needok token-insertion-request cancel
  357. COMMAND -- needstr (OpenVPN 2.1 or higher)
  358. -------------------------------------------
  359. Confirm a ">NEED-STR" real-time notification, normally used by
  360. OpenVPN to block while waiting for a specific user input.
  361. Example:
  362. OpenVPN needs the user to specify some input, so it sends a
  363. real-time notification:
  364. >NEED-STR:Need 'name' input MSG:Please specify your name
  365. The management interface client, if it is a GUI, can flash a dialog
  366. box containing the text after the "MSG:" marker to the user.
  367. When the user acknowledges the dialog box,
  368. the management interface client should issue this command:
  369. needstr name "John"
  370. COMMAND -- pkcs11-id-count (OpenVPN 2.1 or higher)
  371. ---------------------------------------------------
  372. Retrieve available number of certificates.
  373. Example:
  374. pkcs11-id-count
  375. >PKCS11ID-COUNT:5
  376. COMMAND -- pkcs11-id-get (OpenVPN 2.1 or higher)
  377. -------------------------------------------------
  378. Retrieve certificate by index, the ID string should be provided
  379. as PKCS#11 identity, the blob is a base 64 encoded certificate.
  380. Example:
  381. pkcs11-id-get 1
  382. PKCS11ID-ENTRY:'1', ID:'<snip>', BLOB:'<snip>'
  383. COMMAND -- client-auth (OpenVPN 2.1 or higher)
  384. -----------------------------------------------
  385. Authorize a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request and specify
  386. "client-connect" configuration directives in a subsequent text block.
  387. The OpenVPN server should have been started with the
  388. --management-client-auth directive so that it will ask the management
  389. interface to approve client connections.
  390. client-auth {CID} {KID}
  391. line_1
  392. line_2
  393. ...
  394. line_n
  395. END
  396. CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
  397. notification for more info.
  398. line_1 to line_n -- client-connect configuration text block, as would be
  399. returned by a --client-connect script. The text block may be null, with
  400. "END" immediately following the "client-auth" line (using a null text
  401. block is equivalent to using the client-auth-nt command).
  402. A client-connect configuration text block contains OpenVPN directives
  403. that will be applied to the client instance object representing a newly
  404. connected client.
  405. COMMAND -- client-auth-nt (OpenVPN 2.1 or higher)
  406. --------------------------------------------------
  407. Authorize a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request without specifying
  408. client-connect configuration text.
  409. The OpenVPN server should have been started with the
  410. --management-client-auth directive so that it will ask the management
  411. interface to approve client connections.
  412. client-auth-nt {CID} {KID}
  413. CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
  414. notification for more info.
  415. COMMAND -- client-deny (OpenVPN 2.1 or higher)
  416. -----------------------------------------------
  417. Deny a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request.
  418. client-deny {CID} {KID} "reason-text" ["client-reason-text"]
  419. CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
  420. notification for more info.
  421. reason-text: a human-readable message explaining why the authentication
  422. request was denied. This message will be output to the OpenVPN log
  423. file or syslog.
  424. client-reason-text: a message that will be sent to the client as
  425. part of the AUTH_FAILED message.
  426. Note that client-deny denies a specific Key ID (pertaining to a
  427. TLS renegotiation). A client-deny command issued in response to
  428. an initial TLS key negotiation (notified by ">CLIENT:CONNECT") will
  429. terminate the client session after returning "AUTH-FAILED" to the client.
  430. On the other hand, a client-deny command issued in response to
  431. a TLS renegotiation (">CLIENT:REAUTH") will invalidate the renegotiated
  432. key, however the TLS session associated with the currently active
  433. key will continue to live for up to --tran-window seconds before
  434. expiration.
  435. To immediately kill a client session, use "client-kill".
  436. COMMAND -- client-kill (OpenVPN 2.1 or higher)
  437. -----------------------------------------------
  438. Immediately kill a client instance by CID.
  439. client-kill {CID}
  440. CID -- client ID. See documentation for ">CLIENT:" notification for more
  441. info.
  442. COMMAND -- client-pf (OpenVPN 2.1 or higher)
  443. ---------------------------------------------
  444. Push a packet filter file to a specific client.
  445. The OpenVPN server should have been started with the
  446. --management-client-pf directive so that it will require that
  447. VPN tunnel packets sent or received by client instances must
  448. conform to that client's packet filter configuration.
  449. client-pf {CID}
  450. line_1
  451. line_2
  452. ...
  453. line_n
  454. END
  455. CID -- client ID. See documentation for ">CLIENT:" notification for
  456. more info.
  457. line_1 to line_n -- the packet filter configuration file for this
  458. client.
  459. Packet filter file grammar:
  460. [CLIENTS DROP|ACCEPT]
  461. {+|-}common_name1
  462. {+|-}common_name2
  463. . . .
  464. [SUBNETS DROP|ACCEPT]
  465. {+|-}subnet1
  466. {+|-}subnet2
  467. . . .
  468. [END]
  469. Subnet: IP-ADDRESS | IP-ADDRESS/NUM_NETWORK_BITS | "unknown"
  470. CLIENTS refers to the set of clients (by their common-name) which
  471. this instance is allowed ('+') to connect to, or is excluded ('-')
  472. from connecting to. Note that in the case of client-to-client
  473. connections, such communication must be allowed by the packet filter
  474. configuration files of both clients AND the --client-to-client
  475. directive must have been specified in the OpenVPN server config.
  476. SUBNETS refers to IP addresses or IP address subnets which this
  477. client instance may connect to ('+') or is excluded ('-') from
  478. connecting to, and applies to IPv4 and ARP packets. The special
  479. "unknown" tag refers to packets of unknown type, i.e. a packet that
  480. is not IPv4 or ARP.
  481. DROP or ACCEPT defines default policy when there is no explicit match
  482. for a common-name or subnet. The [END] tag must exist.
  483. Notes:
  484. * The SUBNETS section currently only supports IPv4 addresses and
  485. subnets.
  486. * A given client or subnet rule applies to both incoming and
  487. outgoing packets.
  488. * The CLIENTS list is order-invariant. Because the list is stored
  489. as a hash-table, the order of the list does not affect its function.
  490. * The SUBNETS table is scanned sequentially, and the first item to
  491. match is chosen. Therefore the SUBNETS table is NOT order-invariant.
  492. * No client-to-client communication is allowed unless the
  493. --client-to-client configuration directive is enabled AND
  494. the CLIENTS list of BOTH clients allows the communication.
  495. Example packet filter spec, as transmitted to the management interface:
  496. client-pf 42
  497. [CLIENTS ACCEPT]
  498. -accounting
  499. -enigma
  500. [SUBNETS DROP]
  501. -10.46.79.9
  502. +10.0.0.0/8
  503. [END]
  504. END
  505. The above example sets the packet filter policy for the client
  506. identified by CID=42. This client may connect to all other clients
  507. except those having a common name of "accounting" or "enigma".
  508. The client may only interact with external IP addresses in the
  509. 10.0.0.0/8 subnet, however access to 10.46.79.9 is specifically
  510. excluded.
  511. Another example packet filter spec, as transmitted to the
  512. management interface:
  513. client-pf 99
  514. [CLIENTS DENY]
  515. +public
  516. [SUBNETS ACCEPT]
  517. +10.10.0.1
  518. -10.0.0.0/8
  519. -unknown
  520. [END]
  521. END
  522. The above example sets the packet filter policy for the client
  523. identified by CID=99. This client may not connect to any other
  524. clients except those having a common name of "public". It may
  525. interact with any external IP address except those in the
  526. 10.0.0.0/8 netblock. However interaction with one address in
  527. the 10.0.0.0/8 netblock is allowed: 10.10.0.1. Also, the client
  528. may not interact with external IP addresses using an "unknown"
  529. protocol (i.e. one that is not IPv4 or ARP).
  530. COMMAND -- remote (OpenVPN AS 2.1.5/OpenVPN 2.3 or higher)
  531. --------------------------------------------
  532. Provide remote host/port in response to a >REMOTE notification
  533. (client only). Requires that the --management-query-remote
  534. directive is used.
  535. remote ACTION [HOST PORT]
  536. The "remote" command should only be given in response to a >REMOTE
  537. notification. For example, the following >REMOTE notification
  538. indicates that the client config file would ordinarily connect
  539. to vpn.example.com port 1194 (UDP):
  540. >REMOTE:vpn.example.com,1194,udp
  541. Now, suppose we want to override the host and port, connecting
  542. instead to vpn.otherexample.com port 1234. After receiving
  543. the above notification, use this command:
  544. remote MOD vpn.otherexample.com 1234
  545. To accept the same host and port as the client would ordinarily
  546. have connected to, use this command:
  547. remote ACCEPT
  548. To skip the current connection entry and advance to the next one,
  549. use this command:
  550. remote SKIP
  551. COMMAND -- proxy (OpenVPN 2.3 or higher)
  552. --------------------------------------------
  553. Provide proxy server host/port and flags in response to a >PROXY
  554. notification (client only). Requires that the --management-query-proxy
  555. directive is used.
  556. proxy TYPE HOST PORT ["nct"]
  557. The "proxy" command must only be given in response to a >PROXY
  558. notification. Use the "nct" flag if you only want to allow
  559. non-cleartext auth with the proxy server. The following >PROXY
  560. notification indicates that the client config file would ordinarily
  561. connect to the first --remote configured, vpn.example.com using TCP:
  562. >PROXY:1,TCP,vpn.example.com
  563. Now, suppose we want to connect to the remote host using the proxy server
  564. proxy.intranet port 8080 with secure authentication only, if required.
  565. After receiving the above notification, use this command:
  566. proxy HTTP proxy.intranet 8080 nct
  567. You can also use the SOCKS keyword to pass a SOCKS server address, like:
  568. proxy SOCKS fe00::1 1080
  569. To accept connecting to the host and port directly, use this command:
  570. proxy NONE
  571. COMMAND -- rsa-sig (OpenVPN 2.3 or higher)
  572. ------------------------------------------
  573. Provides support for external storage of the private key. Requires the
  574. --management-external-key option. This option can be used instead of "key"
  575. in client mode, and allows the client to run without the need to load the
  576. actual private key. When the SSL protocol needs to perform an RSA sign
  577. operation, the data to be signed will be sent to the management interface
  578. via a notification as follows:
  579. >RSA_SIGN:[BASE64_DATA]
  580. The management interface client should then create a PKCS#1 v1.5 signature of
  581. the (decoded) BASE64_DATA using the private key and return the SSL signature as
  582. follows:
  583. rsa-sig
  584. [BASE64_SIG_LINE]
  585. .
  586. .
  587. .
  588. END
  589. Base64 encoded output of RSA_private_encrypt() (OpenSSL) or mbedtls_pk_sign()
  590. (mbed TLS) will provide a correct signature.
  591. This capability is intended to allow the use of arbitrary cryptographic
  592. service providers with OpenVPN via the management interface.
  593. COMMAND -- certificate (OpenVPN 2.4 or higher)
  594. ----------------------------------------------
  595. Provides support for external storage of the certificate. Requires the
  596. --management-external-cert option. This option can be used instead of "cert"
  597. in client mode. On SSL protocol initialization a notification will be sent
  598. to the management interface with a hint as follows:
  599. >NEED-CERTIFICATE:macosx-keychain:subject:o=OpenVPN-TEST
  600. The management interface client should use the hint to obtain the specific
  601. SSL certificate and then return base 64 encoded certificate as follows:
  602. certificate
  603. [BASE64_CERT_LINE]
  604. .
  605. .
  606. .
  607. END
  608. This capability is intended to allow the use of certificates
  609. stored outside of the filesystem (e.g. in Mac OS X Keychain)
  610. with OpenVPN via the management interface.
  611. OUTPUT FORMAT
  612. -------------
  613. (1) Command success/failure indicated by "SUCCESS: [text]" or
  614. "ERROR: [text]".
  615. (2) For commands which print multiple lines of output,
  616. the last line will be "END".
  617. (3) Real-time messages will be in the form ">[source]:[text]",
  618. where source is "CLIENT", "ECHO", "FATAL", "HOLD", "INFO", "LOG",
  619. "NEED-OK", "PASSWORD", or "STATE".
  620. REAL-TIME MESSAGE FORMAT
  621. ------------------------
  622. The OpenVPN management interface produces two kinds of
  623. output: (a) output from a command, or (b) asynchronous,
  624. real-time output which can be generated at any time.
  625. Real-time messages start with a '>' character in the first
  626. column and are immediately followed by a type keyword
  627. indicating the type of real-time message. The following
  628. types are currently defined:
  629. BYTECOUNT -- Real-time bandwidth usage notification, as enabled
  630. by "bytecount" command when OpenVPN is running as
  631. a client.
  632. BYTECOUNT_CLI -- Real-time bandwidth usage notification per-client,
  633. as enabled by "bytecount" command when OpenVPN is
  634. running as a server.
  635. CLIENT -- Notification of client connections and disconnections
  636. on an OpenVPN server. Enabled when OpenVPN is started
  637. with the --management-client-auth option. CLIENT
  638. notifications may be multi-line. See "The CLIENT
  639. notification" section below for detailed info.
  640. ECHO -- Echo messages as controlled by the "echo" command.
  641. FATAL -- A fatal error which is output to the log file just
  642. prior to OpenVPN exiting.
  643. HOLD -- Used to indicate that OpenVPN is in a holding state
  644. and will not start until it receives a
  645. "hold release" command.
  646. INFO -- Informational messages such as the welcome message.
  647. LOG -- Log message output as controlled by the "log" command.
  648. NEED-OK -- OpenVPN needs the end user to do something, such as
  649. insert a cryptographic token. The "needok" command can
  650. be used to tell OpenVPN to continue.
  651. NEED-STR -- OpenVPN needs information from end, such as
  652. a certificate to use. The "needstr" command can
  653. be used to tell OpenVPN to continue.
  654. PASSWORD -- Used to tell the management interface client that OpenVPN
  655. needs a password, also to indicate password
  656. verification failure.
  657. STATE -- Shows the current OpenVPN state, as controlled
  658. by the "state" command.
  659. The CLIENT notification
  660. -----------------------
  661. The ">CLIENT:" notification is enabled by the --management-client-auth
  662. OpenVPN configuration directive that gives the management interface client
  663. the responsibility to authenticate OpenVPN clients after their client
  664. certificate has been verified. CLIENT notifications may be multi-line, and
  665. the sequentiality of a given CLIENT notification, its associated environmental
  666. variables, and the terminating ">CLIENT:ENV,END" line are guaranteed to be
  667. atomic.
  668. CLIENT notification types:
  669. (1) Notify new client connection ("CONNECT") or existing client TLS session
  670. renegotiation ("REAUTH"). Information about the client is provided
  671. by a list of environmental variables which are documented in the OpenVPN
  672. man page. The environmental variables passed are equivalent to those
  673. that would be passed to an --auth-user-pass-verify script.
  674. >CLIENT:CONNECT|REAUTH,{CID},{KID}
  675. >CLIENT:ENV,name1=val1
  676. >CLIENT:ENV,name2=val2
  677. >CLIENT:ENV,...
  678. >CLIENT:ENV,END
  679. (2) Notify successful client authentication and session initiation.
  680. Called after CONNECT.
  681. >CLIENT:ESTABLISHED,{CID}
  682. >CLIENT:ENV,name1=val1
  683. >CLIENT:ENV,name2=val2
  684. >CLIENT:ENV,...
  685. >CLIENT:ENV,END
  686. (3) Notify existing client disconnection. The environmental variables passed
  687. are equivalent to those that would be passed to a --client-disconnect
  688. script.
  689. >CLIENT:DISCONNECT,{CID}
  690. >CLIENT:ENV,name1=val1
  691. >CLIENT:ENV,name2=val2
  692. >CLIENT:ENV,...
  693. >CLIENT:ENV,END
  694. (4) Notify that a particular virtual address or subnet
  695. is now associated with a specific client.
  696. >CLIENT:ADDRESS,{CID},{ADDR},{PRI}
  697. Variables:
  698. CID -- Client ID, numerical ID for each connecting client, sequence = 0,1,2,...
  699. KID -- Key ID, numerical ID for the key associated with a given client TLS session,
  700. sequence = 0,1,2,...
  701. PRI -- Primary (1) or Secondary (0) VPN address/subnet. All clients have at least
  702. one primary IP address. Secondary address/subnets are associated with
  703. client-specific "iroute" directives.
  704. ADDR -- IPv4 address/subnet in the form 1.2.3.4 or 1.2.3.0/255.255.255.0
  705. In the unlikely scenario of an extremely long-running OpenVPN server,
  706. CID and KID should be assumed to recycle to 0 after (2^32)-1, however this
  707. recycling behavior is guaranteed to be collision-free.
  708. Command Parsing
  709. ---------------
  710. The management interface uses the same command line lexical analyzer
  711. as is used by the OpenVPN config file parser.
  712. Whitespace is a parameter separator.
  713. Double quotation or single quotation characters ("", '') can be used
  714. to enclose parameters containing whitespace.
  715. Backslash-based shell escaping is performed, using the following
  716. mappings, when not in single quotations:
  717. \\ Maps to a single backslash character (\).
  718. \" Pass a literal doublequote character ("), don't
  719. interpret it as enclosing a parameter.
  720. \[SPACE] Pass a literal space or tab character, don't
  721. interpret it as a parameter delimiter.
  722. Challenge/Response Protocol
  723. ---------------------------
  724. The OpenVPN Challenge/Response Protocol allows an OpenVPN server to
  725. generate challenge questions that are shown to the user, and to see
  726. the user's responses to those challenges. Based on the responses, the
  727. server can allow or deny access.
  728. The protocol can be used to implement multi-factor authentication
  729. because the user must enter an additional piece of information,
  730. in addition to a username and password, to successfully authenticate.
  731. In multi-factor authentication, this information is used to prove
  732. that the user possesses a certain key-like device such as
  733. cryptographic token or a particular mobile phone.
  734. Two variations on the challenge/response protocol are supported:
  735. the "static" and "dynamic" protocols:
  736. * The static protocol uses OpenVPN's "--static-challenge" option.
  737. * The dynamic protocol does not involve special OpenVPN options
  738. or actions. It is an agreement between the auth-user-pass
  739. verification process on the server and the management interface
  740. client to use custom strings that begin with "['CRV1" in
  741. "Verification Failed" messages. (The "[" character and a matching
  742. "]" character at the end of the message are added by the client
  743. OpenVPN program, and are not present in the string generated by the
  744. auth-user-pass verification process or in the string sent by the
  745. server.)
  746. Dynamic protocol:
  747. The OpenVPN dynamic challenge/response protocol works by returning
  748. a specially formatted error message after initial successful
  749. authentication. The error message has two purposes:
  750. 1. It causes OpenVPN to restart the connection attempt.
  751. 2. It contains information about the challenge, which should be used
  752. to construct the response to the next authentication request (which
  753. will occur after the restart).
  754. Notes:
  755. * '--auth-retry interact' must be in effect so that the
  756. connection is restarted and credentials are requested again.
  757. * '--auth-retry none' (which is the default) will cause
  758. OpenVPN to exit with a fatal error without retrying and the dynamic
  759. challenge/response will never happen because "Need 'Auth'
  760. username/password" will not be sent.
  761. The error message is formatted as follows:
  762. >PASSWORD:Verification Failed: 'Auth' ['CRV1:<flags>:<state_id>:<username_base64>:<challenge_text>']
  763. <flags>: a series of optional, comma-separated flags:
  764. E : echo the response when the user types it.
  765. R : a response is required.
  766. <state_id>: an opaque string that should be returned to the server
  767. along with the response.
  768. <username_base64>: the username encoded as base 64.
  769. <challenge_text>: the challenge text to be shown to the user.
  770. <state_id> may not contain colon characters (":"), but <challenge_text>
  771. may.
  772. Example challenge:
  773. CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN
  774. The next time the username and password are requested with
  775. >PASSWORD:Need 'Auth' username/password
  776. the management interface client should display the challenge text and,
  777. if the R flag is specified, get a response from the user. The management
  778. interface client should respond:
  779. username "Auth" <username>
  780. password "Auth" CRV1::<state_id>::<response_text>
  781. Where <username> is the username decoded from <username_base64>,
  782. <state_id> is taken from the challenge request, and <response_text>
  783. is what the user entered in response to the challenge, which can be an
  784. empty string. If the R flag is not present, <response_text> should
  785. be an empty string.
  786. (As in all username/password responses described in the "COMMAND --
  787. password and username" section above, the username and/or password
  788. can be in quotes, and special characters such as double quotes or
  789. backslashes must be escaped. See the "Command Parsing" section above
  790. for more info.)
  791. Example response (suppose the user enters "8675309" for the token PIN):
  792. username "Auth" cr1
  793. password "Auth" CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::8675309
  794. ("Y3Ix" is the base 64 encoding of "cr1".)
  795. Static protocol:
  796. The static protocol differs from the dynamic protocol in that the
  797. challenge question is sent to the management interface client in a
  798. a username/password request, and the username, password, and
  799. response are delivered back to the server in response to that
  800. request.
  801. OpenVPN's --static-challenge option is used to provide the
  802. challenge text to OpenVPN and indicate whether or not the response
  803. should be echoed.
  804. When credentials are needed and the --static-challenge option is
  805. used, the management interface will send:
  806. >PASSWORD:Need 'Auth' username/password SC:<ECHO>,<TEXT>
  807. ECHO: "1" if response should be echoed, "0" to not echo
  808. TEXT: challenge text that should be shown to the user to
  809. facilitate their response
  810. For example:
  811. >PASSWORD:Need 'Auth' username/password SC:1,Please enter token PIN
  812. The above notification indicates that OpenVPN needs a --auth-user-pass
  813. username and password plus a response to a static challenge ("Please
  814. enter token PIN"). The "1" after the "SC:" indicates that the response
  815. should be echoed.
  816. The management interface client in this case should add the static
  817. challenge text to the auth dialog followed by a field for the user to
  818. enter a response. Then the management interface client should pack the
  819. password and response together into an encoded password and send:
  820. username "Auth" <username>
  821. password "Auth" "SCRV1:<password_base64>:<response_base64>"
  822. Where <username> is the username entered by the user, <password_base64>
  823. is the base 64 encoding of the password entered by the user, and
  824. <response_base64> is the base 64 encoding of the response entered by
  825. the user. The <password_base64> and/or the <response_base64> can be
  826. empty strings.
  827. (As in all username/password responses described in the "COMMAND --
  828. password and username" section above, the username can be in quotes,
  829. and special characters such as double quotes or backslashes must be
  830. escaped. See the "Command Parsing" section above for more info.)
  831. For example, if user "foo" entered "bar" as the password and 8675309
  832. as the PIN, the following management interface commands should be
  833. issued:
  834. username "Auth" foo
  835. password "Auth" "SCRV1:YmFy:ODY3NTMwOQ=="
  836. ("YmFy" is the base 64 encoding of "bar" and "ODY3NTMwOQ==" is the
  837. base 64 encoding of "8675309".)