Cara Install OpenVPN di CentOS 5 VPS

 Others, VPN

Cara Install OpenVPN di CentOS 5 VPS

Tutorial Cara Install OpenVPN server di vps CentOS 5 32bit

  1. Cek dan pastikan tun/tap aktif

    cat /dev/net/tun

    Jika output seperti dibawah ini dev tun sudah aktif

    cat: /dev/net/tun: File descriptor in bad state

    Cara Install OpenVPN di CentOS 5 VPS 1

  2. LZO RPM

    wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

    Cara Install OpenVPN di CentOS 5 VPS 2

  3. RPMForge Repo
    Untuk CentOS 5 32 bit:

    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

    Untuk CentOS 5 64 bit

    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

  4. Install and build packages

    yum install gcc make rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel

  5. Build paket RPM

    rpmbuild –rebuild lzo-1.08-4.rf.src.rpm
    rpm -Uvh lzo-*.rpm
    rpm -Uvh rpmforge-release*

  6. Install OpenVPN

    yum install openvpn

    Cara Install OpenVPN di CentOS 5 VPS 3

  7. Download easy-rsa

    wget https://github.com/downloads/OpenVPN/easy-rsa/easy-rsa-2.2.0_master.tar.gz

    Extract easy-rsa

    tar -zxvf easy-rsa-2.2.0_master.tar.gz

    Copy easy-rsa ke folder OpenVPN

    cp -R easy-rsa-2.2.0_master/easy-rsa/ /etc/openvpn/

  8. Membuat certificate

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

  9. Build CA

    ./build-ca

    ‘Common Name’ wajib diisi
    yang lain optional boleh diisi atau tidak
    Cara Install OpenVPN di CentOS 5 VPS 4

  10. Build key server

    ./build-key-server server

    ‘Common Name’ diisi server
    Cara Install OpenVPN di CentOS 5 VPS 5

  11. Build Diffie Hellman

    ./build-dh

    Cara Install OpenVPN di CentOS 5 VPS 6

  12. Membuat config file server

    nano /etc/openvpn/server.conf

    Paste berikut ini di file server.conf tadi

    local x.x.x.x #–ganti x.x.x.x dengan IP Server
    port 1194 #– ganti port sesuai selera
    proto udp #– pilih tcp or udp sesuai selera
    dev tun
    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
    server 10.9.0.0 255.255.255.0
    ifconfig-pool-persist ipp.txt
    push “redirect-gateway def1”
    push “dhcp-option DNS 8.8.8.8”
    push “dhcp-option DNS 4.2.2.1”
    keepalive 5 30
    comp-lzo
    persist-key
    persist-tun
    status server-tcp.log
    verb 3

    Cara Install OpenVPN di CentOS 5 VPS 7
    Simpan dan exit

  13. Start OpenVPN server

    service openvpn start

    Cara Install OpenVPN di CentOS 5 VPS 8

  14. Enabling forwarding packet for redirect gateway

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

  15. Edit NAT table for MASQUERADING
    • Untuk OpenVZ:

      iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -j SNAT –to x.x.x.x

      Ganti x.x.x.x dengan IP server

    • Untuk XEN / Dedicate:

      iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE

  16. Build certificate untuk client

    ./build-key jadoeldotinfo

  17. Membuat config (.ovpn) untuk client

    nano jadoeldotinfo.ovpn

    Paste berikut ini:

    client
    dev tun
    proto tcp
    remote 1.2.3.4 1194 #– Ganti 1.2.3.4 dengan ip server dan samakan port dengan server.conf
    resolv-retry infinite
    nobind
    tun-mtu 1500
    tun-mtu-extra 32
    mssfix 1450
    persist-key
    persist-tun
    ca ca.crt
    cert jadoeldotinfo.crt
    key jadoeldotinfo.key
    ;auth-user-pass
    comp-lzo
    verb 3

    Ganti jadoeldotinfo dengan nama client yang dibuat
    Simpan dan exit

  18. Download dan install openvn di PC client
  19. Download ca.crt, jadoeldotinfo.crt and jadoeldotinfo.key jadoeldotinfo.ovpn ke komputer (C:\program files\openvpn\config\ OpenVPN)
    Cara Install OpenVPN di CentOS 5 VPS