How to install OpenVPN server on my Centos 6 - UDP and TCP

I followed this instructions in order to install OpenVPN on my server but i got it installed only with UDP protocol, i want use both of them (TCP and UDP).

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm

yum install openvpn -y

cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn

nano -w /etc/openvpn/server.conf

push "redirect-gateway def1 bypass-dhcp"

push "dhcp-option DNS"
push "dhcp-option DNS"

user nobody
group nobody

mkdir -p /etc/openvpn/easy-rsa/keys
cp -rf /usr/share/openvpn/easy-rsa/2.0/* /etc/openvpn/easy-rsa

nano -w /etc/openvpn/easy-rsa/vars

export KEY_CITY="New York"
export KEY_ORG="Organization Name"
export KEY_EMAIL="[email protected]"
export KEY_CN=droplet.example.com
export KEY_NAME=server
export KEY_OU=server

cp /etc/openvpn/easy-rsa/openssl-1.0.0.cnf /etc/openvpn/easy-rsa/openssl.cnf

cd /etc/openvpn/easy-rsa
source ./vars

./build-key-server server

cd /etc/openvpn/easy-rsa/keys
cp dh1024.pem ca.crt server.crt server.key /etc/openvpn

cd /etc/openvpn/easy-rsa
./build-key client

iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE
service iptables save

nano -w /etc/sysctl.conf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

sysctl -p
service openvpn start
chkconfig openvpn on

Source: https://www.digitalocean.com/community/tutorials/how-to-setup-and-configure-an-openvpn-server-on-centos-6

How to get it work in both protocols UDP and TCP ?

Leave answer

Question already answered, Thanks for All :)

Answers (2) - Hidden answers (0)


11 months ago

Please stop your openvpn server:

service openvpn stop

Go to: /etc/openvpn/ and rename server.conf to server-udp.conf (If you have only UDP working).

And then create the same file with same content as (server-udp.conf) in the same directory and name it: server-tcp.conf.

Now open the new file (server-tcp.conf):

vi server-tcp.conf

You will find something like this:

local $server_ip #- your_server_ip goes here
port 1194 #- port
proto udp #- protocol
dev tun

Change the line proto udp #- protocol to proto tcp #- protocol and save it. (Escape and then :wq)

Now start openvpn and this one will automatically detect the two config files.

service openvpn start

please choose my answer if this worked for you.