V P N S C R I P T

In order to be able to add TCP connection support to your vpn service, please follow the steps below.

1- Authenticate to your server over SSH (putty)

2- Add the firewall rules

iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -j SNAT --to-source 123.123.123.123
Don’t forget to change “123.123.123.123"with your server ip

3- Save and restart iptables service

service iptables save
service iptables restart

4- Create a new configuration for TCP

nano /etc/openvpn/tcp.conf

5- Enter the configuration as below

port 443
proto tcp
dev tun
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
plugin /etc/openvpn/openvpn-auth-pam.so /etc/pam.d/login
client-cert-not-required
username-as-common-name
server 10.9.0.0 255.255.255.0 #- must be different with tcp config
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "block-outside-dns"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3 #- change to 0 if you want disable logging

6- Save it once done. (Control+O then Control+X)

7- Restart your OpenVPN service and that’s it!

service openvpn restart

Related Post

No Comments

Leave a Comment