sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn
sudo gunzip /etc/openvpn/server.conf.gz
port 8000 # openvpn监听端口,默认1194,我修改成8000
proto tcp # 默认udp,我这里使用TCP
dev tun
ca ca.crt
cert avstel.crt
key avstel.key # This file should be kept secret
dh dh1024.pem
server 172.16.210.0 255.255.255.0 # 这是我使用的VPN网段
ifconfig-pool-persist ipp.txt
push "route 192.168.1.0 255.255.255.0" # 添加192.168.1.0网段路由
keepalive 10 120
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log
log /var/log/openvpn.log
verb 3
cd /usr/share/doc/openvpn/examples/easy-rsa/2.0/
export KEY_COUNTRY="CN"
export KEY_PROVINCE="SH"
export KEY_CITY="Shanghai"
export KEY_ORG="HOME"
export KEY_EMAIL="me@localhost"
export KEY_EMAIL=mail@localhost
export KEY_CN=example.org
export KEY_NAME=HOME Use
export KEY_OU=example.org
export PKCS11_MODULE_PATH=None
export PKCS11_PIN=1234
source ./vars
./cleanup-all
./build-ca
./build-dh
./build-key-server server
./build-key client
cd /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys
cp ca.crt server.crt server.key dh1024.pem /etc/openvpn
/etc/init.d/openvpn start
client
dev tun
proto tcp
remote example.org 8000 # 请将example.org修改成你自己的服务器外网IP
resolv-retry infinite
nobind
persist-key
persist-tun
ca "C:\\Program Files\\OpenVPN\\easy-rsa\\keys\\ca.crt"
cert "C:\\Program Files\\OpenVPN\\easy-rsa\\keys\\client.crt"
key "C:\\Program Files\\OpenVPN\\easy-rsa\\keys\\client.key"
remote-cert-tls server
comp-lzo
verb 3
net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 172.16.210.0/24 -j SNAT --to 192.168.1.110
iptables-save > /etc/network/iptables
up iptables-restore < /etc/network/iptables
手机版 | Archiver | 万博网页版登陆页派论坛 ( 粤ICP备15075382号-1 )