Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

etc_openvpn_server.conf.j2 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. #################################################
  2. # Sample OpenVPN 2.0 config file for #
  3. # multi-client server. #
  4. # #
  5. # This file is for the server side #
  6. # of a many-clients <-> one-server #
  7. # OpenVPN configuration. #
  8. # #
  9. # OpenVPN also supports #
  10. # single-machine <-> single-machine #
  11. # configurations (See the Examples page #
  12. # on the web site for more info). #
  13. # #
  14. # This config should work on Windows #
  15. # or Linux/BSD systems. Remember on #
  16. # Windows to quote pathnames and use #
  17. # double backslashes, e.g.: #
  18. # "C:\\Program Files\\OpenVPN\\config\\foo.key" #
  19. # #
  20. # Comments are preceded with '#' or ';' #
  21. #################################################
  22. # Which local IP address should OpenVPN
  23. # listen on? (optional)
  24. ;local a.b.c.d
  25. # Which TCP/UDP port should OpenVPN listen on?
  26. # If you want to run multiple OpenVPN instances
  27. # on the same machine, use a different port
  28. # number for each one. You will need to
  29. # open up this port on your firewall.
  30. port {{ openvpn_port }}
  31. # Uncomment the following line if you wish to enable PAM support for 2FA
  32. ;plugin /usr/lib/openvpn/openvpn-auth-pam.so openvpn
  33. # TCP or UDP server?
  34. ;proto tcp
  35. proto {{ openvpn_protocol }}
  36. # "dev tun" will create a routed IP tunnel,
  37. # "dev tap" will create an ethernet tunnel.
  38. # Use "dev tap0" if you are ethernet bridging
  39. # and have precreated a tap0 virtual interface
  40. # and bridged it with your ethernet interface.
  41. # If you want to control access policies
  42. # over the VPN, you must create firewall
  43. # rules for the the TUN/TAP interface.
  44. # On non-Windows systems, you can give
  45. # an explicit unit number, such as tun0.
  46. # On Windows, use "dev-node" for this.
  47. # On most systems, the VPN will not function
  48. # unless you partially or fully disable
  49. # the firewall for the TUN/TAP interface.
  50. ;dev tap
  51. dev tun
  52. # Windows needs the TAP-Win32 adapter name
  53. # from the Network Connections panel if you
  54. # have more than one. On XP SP2 or higher,
  55. # you may need to selectively disable the
  56. # Windows firewall for the TAP adapter.
  57. # Non-Windows systems usually don't need this.
  58. ;dev-node MyTap
  59. # SSL/TLS root certificate (ca), certificate
  60. # (cert), and private key (key). Each client
  61. # and the server must have their own cert and
  62. # key file. The server and all clients will
  63. # use the same ca file.
  64. #
  65. # See the "easy-rsa" directory for a series
  66. # of scripts for generating RSA certificates
  67. # and private keys. Remember to use
  68. # a unique Common Name for the server
  69. # and each of the client certificates.
  70. #
  71. # Any X509 key management system can be used.
  72. # OpenVPN can also use a PKCS #12 formatted key file
  73. # (see "pkcs12" directive in man page).
  74. ca ca.crt
  75. cert server.crt
  76. key server.key # This file should be kept secret
  77. # Diffie hellman parameters.
  78. # Generate your own with:
  79. # openssl dhparam -out dh1024.pem 1024
  80. # Substitute 2048 for 1024 if you are using
  81. # 2048 bit keys.
  82. dh dh{{ openvpn_key_size }}.pem
  83. # Configure server mode and supply a VPN subnet
  84. # for OpenVPN to draw client addresses from.
  85. # The server will take 10.8.0.1 for itself,
  86. # the rest will be made available to clients.
  87. # Each client will be able to reach the server
  88. # on 10.8.0.1. Comment this line out if you are
  89. # ethernet bridging. See the man page for more info.
  90. {% if openvpn_enable_sub_routing == 1 %}
  91. mode server
  92. tls-server
  93. topology "subnet"
  94. push "topology subnet"
  95. ifconfig {{ openvpn_ip_start }}.1 255.255.255.0
  96. push "route-gateway {{ openvpn_ip_start }}.1"
  97. ifconfig-pool {{ openvpn_ip_start }}.50 {{ openvpn_ip_start }}.250 255.255.255.0
  98. client-config-dir /etc/openvpn/ccd
  99. route {{ openvpn_sub_routing_network }} 255.255.255.0
  100. {% else %}
  101. server {{ openvpn_ip_start }}.0 255.255.255.0
  102. {% endif %}
  103. # Maintain a record of client <-> virtual IP address
  104. # associations in this file. If OpenVPN goes down or
  105. # is restarted, reconnecting clients can be assigned
  106. # the same virtual IP address from the pool that was
  107. # previously assigned.
  108. ifconfig-pool-persist ipp.txt
  109. # Configure server mode for ethernet bridging.
  110. # You must first use your OS's bridging capability
  111. # to bridge the TAP interface with the ethernet
  112. # NIC interface. Then you must manually set the
  113. # IP/netmask on the bridge interface, here we
  114. # assume 10.8.0.4/255.255.255.0. Finally we
  115. # must set aside an IP range in this subnet
  116. # (start=10.8.0.50 end=10.8.0.100) to allocate
  117. # to connecting clients. Leave this line commented
  118. # out unless you are ethernet bridging.
  119. ;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
  120. # Configure server mode for ethernet bridging
  121. # using a DHCP-proxy, where clients talk
  122. # to the OpenVPN server-side DHCP server
  123. # to receive their IP address allocation
  124. # and DNS server addresses. You must first use
  125. # your OS's bridging capability to bridge the TAP
  126. # interface with the ethernet NIC interface.
  127. # Note: this mode only works on clients (such as
  128. # Windows), where the client-side TAP adapter is
  129. # bound to a DHCP client.
  130. ;server-bridge
  131. # Push routes to the client to allow it
  132. # to reach other private subnets behind
  133. # the server. Remember that these
  134. # private subnets will also need
  135. # to know to route the OpenVPN client
  136. # address pool (10.8.0.0/255.255.255.0)
  137. # back to the OpenVPN server.
  138. ;push "route 192.168.10.0 255.255.255.0"
  139. ;push "route 192.168.20.0 255.255.255.0"
  140. # To assign specific IP addresses to specific
  141. # clients or if a connecting client has a private
  142. # subnet behind it that should also have VPN access,
  143. # use the subdirectory "ccd" for client-specific
  144. # configuration files (see man page for more info).
  145. # EXAMPLE: Suppose the client
  146. # having the certificate common name "Thelonious"
  147. # also has a small subnet behind his connecting
  148. # machine, such as 192.168.40.128/255.255.255.248.
  149. # First, uncomment out these lines:
  150. ;client-config-dir ccd
  151. ;route 192.168.40.128 255.255.255.248
  152. # Then create a file ccd/Thelonious with this line:
  153. # iroute 192.168.40.128 255.255.255.248
  154. # This will allow Thelonious' private subnet to
  155. # access the VPN. This example will only work
  156. # if you are routing, not bridging, i.e. you are
  157. # using "dev tun" and "server" directives.
  158. # EXAMPLE: Suppose you want to give
  159. # Thelonious a fixed VPN IP address of 10.9.0.1.
  160. # First uncomment out these lines:
  161. ;client-config-dir ccd
  162. ;route 10.9.0.0 255.255.255.252
  163. # Then add this line to ccd/Thelonious:
  164. # ifconfig-push 10.9.0.1 10.9.0.2
  165. # Suppose that you want to enable different
  166. # firewall access policies for different groups
  167. # of clients. There are two methods:
  168. # (1) Run multiple OpenVPN daemons, one for each
  169. # group, and firewall the TUN/TAP interface
  170. # for each group/daemon appropriately.
  171. # (2) (Advanced) Create a script to dynamically
  172. # modify the firewall in response to access
  173. # from different clients. See man
  174. # page for more info on learn-address script.
  175. ;learn-address ./script
  176. # If enabled, this directive will configure
  177. # all clients to redirect their default
  178. # network gateway through the VPN, causing
  179. # all IP traffic such as web browsing and
  180. # and DNS lookups to go through the VPN
  181. # (The OpenVPN server machine may need to NAT
  182. # or bridge the TUN/TAP interface to the internet
  183. # in order for this to work properly).
  184. push "redirect-gateway def1"
  185. {% if openvpn_enable_custom_dns == 1 %}
  186. push "dhcp-option DNS {{ openvpn_custom_dns }}"
  187. {% else %}
  188. push "dhcp-option DNS {{ openvpn_ip_start }}.1"
  189. {% endif %}
  190. # Certain Windows-specific network settings
  191. # can be pushed to clients, such as DNS
  192. # or WINS server addresses. CAVEAT:
  193. # http://openvpn.net/faq.html#dhcpcaveats
  194. # The addresses below refer to the public
  195. # DNS servers provided by opendns.com.
  196. ;push "dhcp-option DNS 208.67.222.222"
  197. ;push "dhcp-option DNS 208.67.220.220"
  198. # Uncomment this directive to allow different
  199. # clients to be able to "see" each other.
  200. # By default, clients will only see the server.
  201. # To force clients to only see the server, you
  202. # will also need to appropriately firewall the
  203. # server's TUN/TAP interface.
  204. client-to-client
  205. # Uncomment this directive if multiple clients
  206. # might connect with the same certificate/key
  207. # files or common names. This is recommended
  208. # only for testing purposes. For production use,
  209. # each client should have its own certificate/key
  210. # pair.
  211. #
  212. # IF YOU HAVE NOT GENERATED INDIVIDUAL
  213. # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
  214. # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
  215. # UNCOMMENT THIS LINE OUT.
  216. ;duplicate-cn
  217. # The keepalive directive causes ping-like
  218. # messages to be sent back and forth over
  219. # the link so that each side knows when
  220. # the other side has gone down.
  221. # Ping every 10 seconds, assume that remote
  222. # peer is down if no ping received during
  223. # a 120 second time period.
  224. keepalive 10 120
  225. # For extra security beyond that provided
  226. # by SSL/TLS, create an "HMAC firewall"
  227. # to help block DoS attacks and UDP port flooding.
  228. #
  229. # Generate with:
  230. # openvpn --genkey --secret ta.key
  231. #
  232. # The server and each client must have
  233. # a copy of this key.
  234. # The second parameter should be '0'
  235. # on the server and '1' on the clients.
  236. tls-auth ta.key 0 # This file is secret
  237. # Select a cryptographic cipher.
  238. # This config item must be copied to
  239. # the client config file as well.
  240. ;cipher BF-CBC # Blowfish (default)
  241. ;cipher AES-128-CBC # AES
  242. ;cipher DES-EDE3-CBC # Triple-DES
  243. cipher {{ openvpn_cipher }}
  244. auth {{ openvpn_auth_digest }}
  245. # Enable compression on the VPN link.
  246. # If you enable it here, you must also
  247. # enable it in the client config file.
  248. comp-lzo
  249. # The maximum number of concurrently connected
  250. # clients we want to allow.
  251. ;max-clients 100
  252. # It's a good idea to reduce the OpenVPN
  253. # daemon's privileges after initialization.
  254. #
  255. # You can uncomment this out on
  256. # non-Windows systems.
  257. #user nobody
  258. #group nogroup
  259. # The persist options will try to avoid
  260. # accessing certain resources on restart
  261. # that may no longer be accessible because
  262. # of the privilege downgrade.
  263. persist-key
  264. persist-tun
  265. # Output a short status file showing
  266. # current connections, truncated
  267. # and rewritten every minute.
  268. ;status openvpn-status.log
  269. # By default, log messages will go to the syslog (or
  270. # on Windows, if running as a service, they will go to
  271. # the "\Program Files\OpenVPN\log" directory).
  272. # Use log or log-append to override this default.
  273. # "log" will truncate the log file on OpenVPN startup,
  274. # while "log-append" will append to it. Use one
  275. # or the other (but not both).
  276. ;log openvpn.log
  277. ;log-append openvpn.log
  278. # Set the appropriate level of log
  279. # file verbosity.
  280. #
  281. # 0 is silent, except for fatal errors
  282. # 4 is reasonable for general usage
  283. # 5 and 6 can help to debug connection problems
  284. # 9 is extremely verbose
  285. verb {{ openvpn_verb }}
  286. # Silence repeating messages. At most 20
  287. # sequential messages of the same message
  288. # category will be output to the log.
  289. ;mute 20
  290. # Openvpn changes length of network packets
  291. # in a way which depends on cipher and hash-sum
  292. # algorithms. This can be used for fingerprinting.
  293. # Mask your settings by using a lower mtu.
  294. # Check your settings here: witch.valdikss.org.ru
  295. tun-mtu {{ openvpn_mtu }}
  296. # Set TLS settings
  297. # Only for openvpn 2.3.3 and >2.3.4
  298. {{ openvpn_tls_version_min }}
  299. {{ openvpn_tls_cipher }}
  300. # Change default network buffer size
  301. # Should increase tcp tunnel speed for openvpn < 2.3.9
  302. # https://community.openvpn.net/openvpn/ticket/461
  303. sndbuf 0
  304. rcvbuf 0
  305. push "sndbuf 393216"
  306. push "rcvbuf 393216"