Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

etc_openvpn_server.conf.j2 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. server 10.8.0.0 255.255.255.0
  91. # Maintain a record of client <-> virtual IP address
  92. # associations in this file. If OpenVPN goes down or
  93. # is restarted, reconnecting clients can be assigned
  94. # the same virtual IP address from the pool that was
  95. # previously assigned.
  96. ifconfig-pool-persist ipp.txt
  97. # Configure server mode for ethernet bridging.
  98. # You must first use your OS's bridging capability
  99. # to bridge the TAP interface with the ethernet
  100. # NIC interface. Then you must manually set the
  101. # IP/netmask on the bridge interface, here we
  102. # assume 10.8.0.4/255.255.255.0. Finally we
  103. # must set aside an IP range in this subnet
  104. # (start=10.8.0.50 end=10.8.0.100) to allocate
  105. # to connecting clients. Leave this line commented
  106. # out unless you are ethernet bridging.
  107. ;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
  108. # Configure server mode for ethernet bridging
  109. # using a DHCP-proxy, where clients talk
  110. # to the OpenVPN server-side DHCP server
  111. # to receive their IP address allocation
  112. # and DNS server addresses. You must first use
  113. # your OS's bridging capability to bridge the TAP
  114. # interface with the ethernet NIC interface.
  115. # Note: this mode only works on clients (such as
  116. # Windows), where the client-side TAP adapter is
  117. # bound to a DHCP client.
  118. ;server-bridge
  119. # Push routes to the client to allow it
  120. # to reach other private subnets behind
  121. # the server. Remember that these
  122. # private subnets will also need
  123. # to know to route the OpenVPN client
  124. # address pool (10.8.0.0/255.255.255.0)
  125. # back to the OpenVPN server.
  126. ;push "route 192.168.10.0 255.255.255.0"
  127. ;push "route 192.168.20.0 255.255.255.0"
  128. # To assign specific IP addresses to specific
  129. # clients or if a connecting client has a private
  130. # subnet behind it that should also have VPN access,
  131. # use the subdirectory "ccd" for client-specific
  132. # configuration files (see man page for more info).
  133. # EXAMPLE: Suppose the client
  134. # having the certificate common name "Thelonious"
  135. # also has a small subnet behind his connecting
  136. # machine, such as 192.168.40.128/255.255.255.248.
  137. # First, uncomment out these lines:
  138. ;client-config-dir ccd
  139. ;route 192.168.40.128 255.255.255.248
  140. # Then create a file ccd/Thelonious with this line:
  141. # iroute 192.168.40.128 255.255.255.248
  142. # This will allow Thelonious' private subnet to
  143. # access the VPN. This example will only work
  144. # if you are routing, not bridging, i.e. you are
  145. # using "dev tun" and "server" directives.
  146. # EXAMPLE: Suppose you want to give
  147. # Thelonious a fixed VPN IP address of 10.9.0.1.
  148. # First uncomment out these lines:
  149. ;client-config-dir ccd
  150. ;route 10.9.0.0 255.255.255.252
  151. # Then add this line to ccd/Thelonious:
  152. # ifconfig-push 10.9.0.1 10.9.0.2
  153. # Suppose that you want to enable different
  154. # firewall access policies for different groups
  155. # of clients. There are two methods:
  156. # (1) Run multiple OpenVPN daemons, one for each
  157. # group, and firewall the TUN/TAP interface
  158. # for each group/daemon appropriately.
  159. # (2) (Advanced) Create a script to dynamically
  160. # modify the firewall in response to access
  161. # from different clients. See man
  162. # page for more info on learn-address script.
  163. ;learn-address ./script
  164. # If enabled, this directive will configure
  165. # all clients to redirect their default
  166. # network gateway through the VPN, causing
  167. # all IP traffic such as web browsing and
  168. # and DNS lookups to go through the VPN
  169. # (The OpenVPN server machine may need to NAT
  170. # or bridge the TUN/TAP interface to the internet
  171. # in order for this to work properly).
  172. ;push "redirect-gateway def1 bypass-dhcp"
  173. push "redirect-gateway def1"
  174. push "dhcp-option DNS 10.8.0.1"
  175. # Certain Windows-specific network settings
  176. # can be pushed to clients, such as DNS
  177. # or WINS server addresses. CAVEAT:
  178. # http://openvpn.net/faq.html#dhcpcaveats
  179. # The addresses below refer to the public
  180. # DNS servers provided by opendns.com.
  181. ;push "dhcp-option DNS 208.67.222.222"
  182. ;push "dhcp-option DNS 208.67.220.220"
  183. # Uncomment this directive to allow different
  184. # clients to be able to "see" each other.
  185. # By default, clients will only see the server.
  186. # To force clients to only see the server, you
  187. # will also need to appropriately firewall the
  188. # server's TUN/TAP interface.
  189. client-to-client
  190. # Uncomment this directive if multiple clients
  191. # might connect with the same certificate/key
  192. # files or common names. This is recommended
  193. # only for testing purposes. For production use,
  194. # each client should have its own certificate/key
  195. # pair.
  196. #
  197. # IF YOU HAVE NOT GENERATED INDIVIDUAL
  198. # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
  199. # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
  200. # UNCOMMENT THIS LINE OUT.
  201. ;duplicate-cn
  202. # The keepalive directive causes ping-like
  203. # messages to be sent back and forth over
  204. # the link so that each side knows when
  205. # the other side has gone down.
  206. # Ping every 10 seconds, assume that remote
  207. # peer is down if no ping received during
  208. # a 120 second time period.
  209. keepalive 10 120
  210. # For extra security beyond that provided
  211. # by SSL/TLS, create an "HMAC firewall"
  212. # to help block DoS attacks and UDP port flooding.
  213. #
  214. # Generate with:
  215. # openvpn --genkey --secret ta.key
  216. #
  217. # The server and each client must have
  218. # a copy of this key.
  219. # The second parameter should be '0'
  220. # on the server and '1' on the clients.
  221. tls-auth ta.key 0 # This file is secret
  222. # Select a cryptographic cipher.
  223. # This config item must be copied to
  224. # the client config file as well.
  225. ;cipher BF-CBC # Blowfish (default)
  226. ;cipher AES-128-CBC # AES
  227. ;cipher DES-EDE3-CBC # Triple-DES
  228. cipher {{ openvpn_cipher }}
  229. auth {{ openvpn_auth_digest }}
  230. # Enable compression on the VPN link.
  231. # If you enable it here, you must also
  232. # enable it in the client config file.
  233. comp-lzo
  234. # The maximum number of concurrently connected
  235. # clients we want to allow.
  236. ;max-clients 100
  237. # It's a good idea to reduce the OpenVPN
  238. # daemon's privileges after initialization.
  239. #
  240. # You can uncomment this out on
  241. # non-Windows systems.
  242. user nobody
  243. group nogroup
  244. # The persist options will try to avoid
  245. # accessing certain resources on restart
  246. # that may no longer be accessible because
  247. # of the privilege downgrade.
  248. persist-key
  249. persist-tun
  250. # Output a short status file showing
  251. # current connections, truncated
  252. # and rewritten every minute.
  253. status openvpn-status.log
  254. # By default, log messages will go to the syslog (or
  255. # on Windows, if running as a service, they will go to
  256. # the "\Program Files\OpenVPN\log" directory).
  257. # Use log or log-append to override this default.
  258. # "log" will truncate the log file on OpenVPN startup,
  259. # while "log-append" will append to it. Use one
  260. # or the other (but not both).
  261. ;log openvpn.log
  262. ;log-append openvpn.log
  263. # Set the appropriate level of log
  264. # file verbosity.
  265. #
  266. # 0 is silent, except for fatal errors
  267. # 4 is reasonable for general usage
  268. # 5 and 6 can help to debug connection problems
  269. # 9 is extremely verbose
  270. verb 3
  271. # Silence repeating messages. At most 20
  272. # sequential messages of the same message
  273. # category will be output to the log.
  274. ;mute 20