Site icon Learning & Doing

Cara Install dan Configurasi Openvpn server di vps centos

Untuk persyaratan nya sbb :

1. CentOS 5 32bit OS , minimal
2. TUN / TAP perangkat diaktifkan pada VPS Anda
3. NAT iptables dukungan
4. Putty ( untuk akses ssh )
5. Winscp ( untuk download + upload file dari vps )

NB :Anda akan harus membuka tiket untuk meminta kepada IT support supaya perangkat TUN / TAP harus diaktifkan pada VPS Anda.

vzctl stop YOUR_VEID
vzctl set YOUR_VEID --devices c:10:200:rw --save
vzctl set YOUR_VEID --capability net_admin:on --save
vzctl start YOUR_VEID
vzctl exec YOUR_VEID "mkdir -p /dev/net; mknod /dev/net/tun c 10 200; chmod 600 /dev/net/tun"
# iptables support
vzctl stop YOUR_VEID

vzctl set YOUR_VEID --iptables ipt_REJECT --iptables ipt_tos --iptables
ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit
--iptables ipt_multiport --iptables iptable_filter --iptables
iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables
ipt_ttl --iptables ipt_length --iptables ipt_state --iptables
iptable_nat --iptables ip_nat_ftp --save

vzctl start YOUR_VEID

Pastikan mereka akan mengganti ‘YOUR_VEID’ dengan VEID VPS Anda dan Anda akan siap untuk roll

Langkah langkah Untuk setting openvpn sbb :

<< Connect via putty ke ssh server

<< Install openvpn server

ketikan command berikut :

wget http://vpsnoc.com/scripts/install-openvpn.sh
chmod +x install-openvpn.sh
./install-openvpn.sh

atau

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum update
yum install openvpn

 

<< Membuat Keys dan Certificate Authority

cp -R /usr/share/openvpn/easy-rsa/ /etc/openvpn

vi /etc/openvpn/easy-rsa/2.0/vars

cd /etc/openvpn/easy-rsa/2.0/
. /etc/openvpn/easy-rsa/2.0/vars
. /etc/openvpn/easy-rsa/2.0/clean-all
. /etc/openvpn/easy-rsa/2.0/build-ca

. /etc/openvpn/easy-rsa/2.0/build-key-server server

. /etc/openvpn/easy-rsa/2.0/build-key client1

. /etc/openvpn/easy-rsa/2.0/build-dh

ca.crt
client1.crt
client1.keys

ca.crt
ca.key
dh1024.pem
server.crt
server.key

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

<< Konfigurasi File Config

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

cp /usr/share/doc/openvpn-2.1.4/sample-config-files/client.conf ~/

cd ~/

vi ~/client.conf

/etc/init.d/openvpn start

chkconfig openvpn on

vi /etc/openvpn/server.conf

;push “redirect-gateway def1 bypass-dhcp”

push “redirect-gateway def1 bypass-dhcp

vi /etc/sysctl.conf

net.ipv4.ip_forward = 0

net.ipv4.ip_forward = 1

<< Konfigurasi IPtables

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -A FORWARD -m state -state RELATED,ESTABLISHED -j ACCEPT

iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT

iptables -A FORWARD -j REJECT

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT –to 46.20.xxx.xx

vi /etc/rc.local

#!/bin/sh

#

# […]

#

iptables -A FORWARD -m state -state RELATED,ESTABLISHED -j ACCEPT

iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT

iptables -A FORWARD -j REJECT

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT –to 46.20.xxx.xx

<< Install DNSmasq

yum install dnsmasq

/etc/init.d/dnsmasq start

chkconfig dnsmasq on

vi /etc/openvpn/server.conf

push “dhcp-option DNS 10.8.0.1”

/etc/init.d/openvpn restart

<< Setting PC Client

ca.crt
client1.crt
client1.keys
client.ovpn

Exit mobile version