OpenVpn部署,添加路由,实现路由流量走VPN,本地流量走本地
1. 安装
#下载安装脚本
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
#添加执行权限
chmod u+x openvpn-install.sh
#安装
./openvpn-install.sh
2. 修改配置
[root@vpn openvpn]# pwd
/etc/openvpn
[root@vpn openvpn]# cat server.conf
port 1194
proto udp
dev tun
user nobody
group nobody
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
#push "dhcp-option DNS 94.140.14.14"
#push "dhcp-option DNS 94.140.15.15"
#push "redirect-gateway def1 bypass-dhcp"
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_yYV6Fb4mDuI9Gv.crt
key server_yYV6Fb4mDu9NGv.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
verb 3
[root@vpn openvpn]# cat client-template.txt
client
proto udp
explicit-exit-notify
remote ******** 1194
dev tun
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
verify-x509-name server_yYV6Fb4mDu9NI9Gv name
auth SHA256
auth-nocache
cipher AES-128-GCM
tls-client
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
#ignore-unknown-option block-outside-dns
#setenv opt block-outside-dns # Prevent Windows 10 DNS leak
verb 3
route-nopull
route 172.31.0.0 255.255.0.0 vpn_gateway