I've setup OpenVPN on server and configured it so it relays IP of the server for access. But I've done it so that IP is for everything. I checked with tracert and hops indeed go thorgh server and on tunel created via VPN.
Internet and connection with servers works, but it uses servers IP and resources which I want to avoid on global scale and use my own connection for anything other than SSH and MySQL ports as example.
port 1194 proto udp dev tun ca ca.crt cert server.crt key server.key # This file should be kept secret push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 184.108.40.206" push "dhcp-option DNS 220.127.116.11" keepalive 10 120 tls-auth ta.key 0 # This file is secret cipher AES-256-CBC auth SHA256 persist-key persist-tun status /var/log/openvpn/openvpn-status.log log /var/log/openvpn/openvpn.log log-append /var/log/openvpn/openvpn.log verb 3 explicit-exit-notify 1
client dev tun proto udp remote x.x.x.x 1194 resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server cipher AES-256-CBC auth SHA256 verb 3 <ca> -----BEGIN CERTIFICATE----- *ca cert* -----END CERTIFICATE----- </ca> <cert> -----BEGIN CERTIFICATE----- *cert* -----END CERTIFICATE----- </cert> <key> -----BEGIN PRIVATE KEY----- *key* -----END PRIVATE KEY----- </key> key-direction 1 <tls-auth> -----BEGIN OpenVPN Static key V1----- *tls-auth* -----END OpenVPN Static key V1----- </tls-auth>
IPtables is default and has only these rules added that allowed me internet access via VPN:
TLDR: I just want to have VPN working for either of two things:
- Using VPN towards certain ports (SSH, MySQL, WinSRV)
- Using VPN towards certain IP addresses (server IP addresses)
Thanks in advance,