1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| # 查看vpn 默认安装路径 查找范例配置文件 rpm -ql openvpn cp /usr/share/doc/openvpn/sample/sample-config-files/server.conf /etc/openvpn/
grep -Ev '^#|^$|^;' /etc/openvpn/server.conf #查看配置文件
port 1194 proto tcp dev tun ca /etc/openvpn/certs/ca.crt cert /etc/openvpn/certs/server.crt key /etc/openvpn/certs/server.key # This file should be kept secret dh /etc/openvpn/certs/dh.pem server 10.8.0.0 255.255.255.0 push "route 172.16.1.0 255.255.255.0" keepalive 10 120 cipher AES-256-CBC compress lz4-v2 push "compress lz4-v2" max-clients 2048 user openvpn group openvpn status /var/log/openvpn/openvpn-status.log log-append /var/log/openvpn/openvpn.log verb 3 mute 20
mkdir /var/log/openvpn chown openvpn:openvpn /var/log/openvpn/
#配置系统服务 vim /usr/lib/systemd/system/openvpn@server.service [Unit] Description=OpenVPN service After=network.target
[Service] Type=notify ExecStart=/usr/sbin/openvpn --config /etc/openvpn/server.conf ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure
[Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl enable --now openvpn@server.service
#配置用户配置文件 cp /usr/share/doc/openvpn/sample/sample-config-files/client.conf /etc/openvpn/client/bai/client.ovpn
client dev tun proto tcp remote 39.100.76.63 1194 resolv-retry infinite nobind ca ca.crt cert bai.crt key bai.key remote-cert-tls server cipher AES-256-CBC compress lz4-v2 verb 3
#客户端文件打包 zip /home/openvpn/bai.zip /etc/openvpn/client/bai/*
|