Created
October 8, 2016 08:40
-
-
Save athurg/2a369d309b1fa321adef9fb60af60efd to your computer and use it in GitHub Desktop.
OpenVPN服务器配置范例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#由于采用用户名密码认证 | |
#所以服务器配置只需要通过 | |
# 1. source ./vars | |
# 2. `./build-ca` 生成CA根证书(服务器客户端一致) | |
# 3. `./build-key-server servername` 生成服务器证书对(cert/key) | |
# 4. `openvpn --genkey --secret ta.key` 生成TLS私钥(服务器客户端一直) | |
# 即可,无需生成客户端的cert证书和key私钥 | |
# 设置监听IP,默认是监听所有IP | |
local x.x.x.x | |
port 1194 | |
proto tcp | |
dev tun | |
#允许同CommonName的用户多次链接 | |
duplicate-cn | |
keepalive 10 120 | |
server 10.8.2.0 255.255.255.0 | |
client-to-client | |
ifconfig-pool-persist /etc/openvpn/ipp.txt | |
verb 3 | |
comp-lzo | |
#通过PAM(MySQL)认证用户的插件 | |
#client-cert-not-required | |
username-as-common-name | |
plugin /usr/lib/openvpn/openvpn-auth-pam.so /etc/pam.d/openvpn | |
status /var/log/openvpn/openvpn-status.log | |
log-append /var/log/openvpn/openvpn.log | |
# 以下是各种证书内容的buddle | |
<ca> | |
-----BEGIN CERTIFICATE----- | |
xxxxx | |
-----END CERTIFICATE----- | |
</ca> | |
<cert> | |
-----BEGIN CERTIFICATE----- | |
xxxxx | |
-----END CERTIFICATE----- | |
</cert> | |
<key> | |
-----BEGIN PRIVATE KEY----- | |
xxxxx | |
-----END PRIVATE KEY----- | |
</key> | |
<dh> | |
-----BEGIN DH PARAMETERS----- | |
xxxxx | |
-----END DH PARAMETERS----- | |
</dh> | |
#服务器为0,客户端为1 | |
key-direction 0 | |
<tls-auth> | |
-----BEGIN OpenVPN Static key V1----- | |
xxxxx | |
-----END OpenVPN Static key V1----- | |
</tls-auth> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment