Instalasi Virtual Private Network dengan OpenVPN

Filed Under (Networking, Operating System, Tutorial) by Nurdiansyah on Sunday, 12 April 2009

Tagged Under : , , , , , , ,

Logo OpenVPN

Logo OpenVPN

OpenVPN adalah aplikasi open source untuk Virtual Private Network (VPN), di mana aplikasi tersebut dapat membuat koneksi point-to-point tunnel yang telah terenkripsi.

OpenVPN menggunakan private keys, certificate, atau username/password untuk melakukan otentikasi dalam membangun koneksi. Di mana untuk enkripsinya menggunakan OpenSSL.

Pada posting kali ini saya ingin menerangkan langkah-langkah untuk instalasi VPN menggunakan OpenVPN. Untuk VPN Server saya menggunakan Linux Ubuntu 8.0.4, dan untuk client saya menggunakan Windows XP SP2 dan Linux Ubuntu 8.0.4.

Berikut step untuk instalasi dan konfigurasi di sisi SERVER:

  1. Instalasi paket OpenVPN
    apt-get install openvpn
  2. Membuat soft link (optional)
    ln -s /usr/share/doc/openvpn/examples/easy-rsa/2.0/ /vpn
    cd /vpn
  3. Mengkonfigurasi file vars
    vim vars

    Lalu edit bagian akhir dari file, isi sesuai keinginan anda

    60
    61
    62
    63
    64
    
    export KEY_COUNTRY="ID"
    export KEY_PROVINCE="DKI"
    export KEY_CITY="South-Jakarta"
    export KEY_ORG="Eresha-Technologies"
    export KEY_EMAIL="nurdiansyah@eresha.net.id"

    Save dan keluar dari editor.

  4. Mempersiapkan Certificate Authority dan Key menggunakan tool easy-rsa
    source vars
    ./clean-all
    ./build-ca

    Command “clean-all” akan membuat folder keys, dan 2 file di dalamnya yaitu index.txt dan serial, jika sebelumnya sudah pernah dibuat bisa dilewatkan saja. Sedangkan command “build-ca” akan men-generate RSA Private Key Certificate Authority, dan menghasilkan file ca.crt dan ca.key. Command “build-ca” akan menampilkan beberapa pertanyaan, isi value-nya seperti data di bawah ini atau bisa dikosongkan saja.

    – Country Name : ID
    – State or Province : DKI
    – Locality Name : South-Jakarta
    – Organization Name : Eresha-Technologies
    – Organization Unit : EreshaNet
    – Common Name : eresha.net.id
    – Email : nurdiansyah@eresha.net.id
  5. Membuat Certificate dan Key untuk VPN Server
    Untuk membuat certificate dan key di sisi server dapat dilakukan dengan command:

    ./build-key-server server

    ServerVPN Akan tampil beberapa pertanyaan yang mirip dengan pertanyaan sebelumnya. Untuk password dan optional company kosongkan saja, sedangkan pada pertanyaan “Sign the certificate? [y/n]:” dan “1 out of 1 certificate requests certified, commit? [y/n]“, ketik y dan enter.
    Command di atas akan menghasilkan 3 buah file: server.crt, server.csr, dan server.key.

  6. Membuat Certificate dan Key untuk VPN Client
    Untuk membuat certificate dan key yang akan digunakan oleh VPN Client nantinya dapat dilakukan dengan command:

    ./build-key jakarta
    ./build-key surabaya

    Pada contoh di sini saya membuat key untuk client dari jakarta (Ubuntu) dan surabaya (XP SP2). 2 command di atas akan menghasilkan file: jakarta.crt, jakarta.csr, jakarta.key, dan juga file: surabaya.crt, surabaya.csr, surabaya.key.

  7. Membuat parameter dari Diffie Hellman
    Parameter Diffie Hellman digunakan untuk melakukan pertukaran key rahasia, untuk membuatnya jalankan command berikut ini:

    ./build-dh

    Command tersebut akan membuat file dengan nama dhxxxx.pem di dalam folder keys. “xxxx” adalah jumlah enkripsi yang digunakan, tapi umumnya nama file yang dihasilkan adalah dh1024.pem.

  8. Pemindahan Certificate dan Keys
    Command-command yang telah dijalankan di atas telah membuat folder “keys” berikut isinya sebagai berikut:

    - ca.crt
    - ca.key
    - dh1024.pem
    - index.txt
    - serial
    - server.crt
    - server.csr
    - server.key
    - jakarta.crt
    - jakarta.csr
    - jakarta.key
    - surabaya.crt
    - surabaya.csr
    - surabaya.key

    jakarta.* dan surabaya.* adalah certificate dan key yang akan digunakan oleh client nantinya.
    Copy semua file selain jakarta.* dan surabaya.* ke dalam folder /etc/openvpn/.

    cd keys/
    cp -R *.pem ca.* index.* seri* server.* /etc/openvpn/
  9. Membuat konfigurasi untuk OpenVPN
    Konfigurasi di sisi VPN Server menggunakan server.conf sedangkan di sisi Client mengunakan client.conf. Contoh 2 file konfigurasi bisa diambil dari /usr/share/doc/openvpn/examples/sample-config-files/ hasil instalasi pertama kali.
    Copy file konfigurasi untuk server ke dalam folder /etc/openvpn/, dengan cara:

    gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz > /etc/openvpn/server.conf

    Edit file server.conf yang telah di-extract tersebut.

    vim /etc/openvpn/server.conf

    Kemudian uncomment / hilangkan tanda komentar (;) di depan “client-to-client”. Ini optional, jika anda memiliki beberapa client dan menginnginkan supaya mereka dapat saling melihat dan behubungan.
    Terakhir restart service-nya.

    /etc/init.d/openvpn restart
STEP berikutnya adalah instalasi dan konfigurasi OpenVPN pada sisi CLIENT Linux Ubuntu:
  1. Instalasi paket OpenVPN
    apt-get install openvpn
  2. Copy file Certificate dan Keys dari server yang telah di-generate sebelumnya.
    Anda bisa menyalin file-file tersebut dengan mendownloadnya atau dengan menyalinnya langsung dengan menggunakan command “scp”.
    KEMBALI ke VPN Server. Dari server saya akan menyalin file langsung ke dalam folder /etc/openvpn/ di client, service sftp atau ssh harus running terlebih dahulu.

    cd /vpn/keys/
    scp -r ca.* root@116.68.x.x:/etc/openvpn/
    scp -r jakarta.* root@116.68.x.x:/etc/openvpn/

    Ganti IP 116.68.x.x dengan IP CLIENT milik anda.

    KEMBALI lagi ke client. Copy juga file konfigurasi untuk client hasil dari instalasi ke dalam folder /etc/openvpn/, kemudian edit file tersebut.

    cp /usr/share/doc/openvpn/examples/sample-config-file/client.conf /etc/openvpn/
    vim /etc/openvpn/client.conf

    Cari baris “remote my-server-1 1194″, ubah dengan IP dan port milik VPN Server

    42
    
    remote 116.68.x.x yyyy

    Sesuaikan IP 116.68.x.x dan port yyyy dengan SERVER milik anda.

    Ubah juga baris-baris di bawah ini, sesuai dengan key yang telah di-generate di server, sebelumnya saya telah men-generate key jakarta (untuk client Ubuntu) dan key surabaya (untuk client XP SP2).

    88
    89
    90
    
    ca ca.crt
    cert jakarta.crt
    key jakarta.key

    Terakhir restart service openvpn.

    /etc/init.d/openvpn restart
Device TUN:

Pada Server dan Client setelah konfigurasi sempurna, akan muncul perangkat baru. Perangkat tersebut dapat dicek dengan perintah:

ifconfig

Hasilnya seperti di bawah:

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
     inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
     UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
     RX packets:0 errors:0 dropped:0 overruns:0 frame:0
     TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:100
     RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Tampilan di atas berarti konfigurasi telah sukses dan tunnel VPN telah berhasil terbentuk.

Cobalah untuk melakukan ping atau login via ssh dari VPN Client ke IP VPN Server.

ping 10.8.0.1
ssh 10.8.0.1

Semua command di atas dapat juga digunakan pada semua distribusi linux, kecuali command “apt-get”. Namun pada distro Debian maupun turunannya saya rasa tidak ada masalah. Untuk instalasi dan konfigurasi OpenVPN pada Client Windows akan saya paparkan pada posting berikutnya.

baca berita di lintas berita

Comments:

  1. 4Avatars v0.3.1 v0.3.1

    Nur……emang elo hebat…nulisan elo menarik

  2. 4Avatars v0.3.1 v0.3.1

    Hehehe gaya nulisnya biasa aja boss.. daripada disimpen sendiri, mending gw share selagi ada waktu dan mood bwat nulis :D

  3. 4Avatars v0.3.1 v0.3.1

    saya kok belum mudeng ya mas apa saya yang masih gaptek he he salam kenal mas

  4. 4Avatars v0.3.1 v0.3.1

    kalau.. pada sisi server harus menggunakan ubuntu server edition ya…. ??

  5. 4Avatars v0.3.1 v0.3.1

    saya tunggu mas pembahasan cliet windowsnya ..

  6. 4Avatars v0.3.1 v0.3.1

    Tidak harus menggunakan server edition mas, untuk desktop-pun bisa asalkan paketan OpenVPN-nya sudah terinstall.
    Untuk client windows nanti yah, sorry dah kelamaan nih kayanya gak posting artikel lg ;)

  7. 4Avatars v0.3.1 v0.3.1

    Bos gw positive dech ne ada di materi CCNP.
    Tapi gw blomliat isinya c, baru ngintip judul doank
    Whehehehe

  8. 4Avatars v0.3.1 v0.3.1

    Oyee..?? Berarti gw dah berhak make gelar CCNP nih yah hahahaa.. CCNA aja blom ujian.. :D

  9. 4Avatars v0.3.1 v0.3.1

    bos Q msh bingung pas step di client… bs tolong d perjelas…

    thanks

  10. 4Avatars v0.3.1 v0.3.1

    I think i’ve seen this somewhere before…but it’s not bad at all

  11. 4Avatars v0.3.1 v0.3.1

    wew… hebat oe… ga ngerti aku yang kaya ginian

  12. 4Avatars v0.3.1 v0.3.1

    wew… hebat oe… ga ngerti aku yang kaya ginian !!!

    ariosaja´s last blog ..Ibu Prita Sementara Dapat Bernafas Lega

  13. 4Avatars v0.3.1 v0.3.1

    mas, klo clientnya windows di network connectionya akan terdapat LAN baru.
    settingan IPnya gimana tuh?

    togum´s last blog… KP-iForte

  14. 4Avatars v0.3.1 v0.3.1

    @ Derekp:
    Thanks dude…

    @ Ariosaja:
    Sama, masih terus belajar kalo ada waktu luang kok mas… :)

    @ Togum:
    Mau di Windows atau Linux sama deh, kalo tunnel sudah terbentuk dan antara server dan client terhubung, sudah pasti akan muncul IP /koneksi baru, pada kasus di atas IP server adalah 10.8.0.1, client bisa 2,3,4,5, dst…

  15. 4Avatars v0.3.1 v0.3.1

    To start earning money with your blog, initially use Google Adsense but gradually as your traffic increases, keep adding more and more money making programs to your site.

  16. 4Avatars v0.3.1 v0.3.1

    good..
    good..
    good..
    good..
    good..
    .-= Ahmad´s last blog… QuickTime Alternative 2.9.0 =-.

  17. 4Avatars v0.3.1 v0.3.1

    You obviously put a lot of work into that post and it’s very interesting to see the thought process that you went through to come up with those conclusion. Really interesting and informative article, keep posting. Nice work, thanks for such information.Thank you very much for sharing your views with us

  18. 4Avatars v0.3.1 v0.3.1

    This reminds me of something funny that my grandmother pretty much always said…
    Then it is probably inappropriate right this moment…

  19. 4Avatars v0.3.1 v0.3.1

    This brings back to mind something my sister would always say…
    Obviously it’s totally inappropriate just now…

  20. 4Avatars v0.3.1 v0.3.1

    some very interesting points… but i think your research and bias leaves a lot to be desired… then of course, that’s just my opinion…
    have a great day… definitely a thought-provoking post!

  21. 4Avatars v0.3.1 v0.3.1

    I keep listening to the news speak about getting free online grant applications so I have been looking around for the best site to get one.

  22. 4Avatars v0.3.1 v0.3.1

    Have you been to the iaps security store to see their vpn combo specials? You can get up to a 10 country VPN combo special from all different kinds of countries. Thats prime security. See it here: https://www .intl-alliance.com/store/index.php?main_page=index&cPath=1

  23. 4Avatars v0.3.1 v0.3.1

    Mantap bro tulisannya :) di tunggu updatean share ilmunya lagi ni :) bravo for u :)

  24. 4Avatars v0.3.1 v0.3.1

    @ Proxis… Oke, thanks for your advice :wink:

    @ Ahmad… Thanks

    @ Amy Hewitt, Stephen Parker, Joan Williams, Lifestyle… Thanks for your comments guys

    @ Plakeno… Thanks for your opinion

    @ Martin… Nice info dude, thanks

    @ Demank… Thanks support-nya bro, sebisa mungkin akan selalu gw update :D

    .-= Nurdiansyah´s last blog… Strategi Pemasaran Dengan Memanfaatkan Media Internet =-.

  25. 4Avatars v0.3.1 v0.3.1

    very informative article… I would like to use a piece of this on my blog, is that feasible?

  26. 4Avatars v0.3.1 v0.3.1

    Very nice! ;) . I enjoy studying your website..

  27. 4Avatars v0.3.1 v0.3.1

    Makasih….

  28. 4Avatars v0.3.1 v0.3.1

    Mas bkn yang tutorial client windows nya donk.. thx ya.. :D
    .-= Rizky Pranata´s last blog… Acer Aspire One AOD150 Netbook – The Best Priced Netbook =-.

  29. 4Avatars v0.3.1 v0.3.1

    mas setting client di windows n da di posting lom?
    thanx,

  30. 4Avatars v0.3.1 v0.3.1

    kalo configurasi buat windows xp bagaimana???terutama set username dan password…kalo bisa seperti contoh bos biar jelas maklum gaptek

  31. 4Avatars v0.3.1 v0.3.1

    kalo untuk windows xp bagaimana??terutama username dan password karna setiap mau connect ada minta username dan password…kalo bisa dengan contohnya…

    terima kasih banyak…

  32. 4Avatars v0.3.1 v0.3.1

    Salam untuk penulis.. :D mantap banget ilmuna sob thanx 4shared
    .-= azzura´s last blog… Library: 8 Pengertian Cinta Menurut Qur’an =-.

  33. 4Avatars v0.3.1 v0.3.1

    mas mohon bantuan….tugas akhir saya membahas tentang vpn….yang saya permasalahkan sekarang adalah ip public static dimana saya menggunakkan modem gsm…dikampus saya tidak dapat menggunakkan ip public kampus…..izinnya yg mungkin rumit…mohon bantuan mas
    .-= arofah azhar´s last blog… about C =-.

  34. 4Avatars v0.3.1 v0.3.1

    wah mantap, thx tp mas nurdiansyah , login adminnya dimana ?

    saya gk ngerti konek vpn nya, soalnya dia butuh admin login….

    anyone , where we can found admin login information and such, each answer very helpful :)

  35. 4Avatars v0.3.1 v0.3.1

    Typically linux will work for most things, even if the box doesn’t say linux compatible There is usually a way to get peripherals working on a linux system regardless of drivers. Since you’re new however, I’d suggest just going with things that say linux compatible to save you the glorious task of writing your own drivers.

  36. 4Avatars v0.3.1 v0.3.1

    This was a really good writeup by the author hope to come back more really soon.

  37. 4Avatars v0.3.1 v0.3.1

    You you could change the blog title Nurdiansyah » Web Designer | Programmer | Developer from Jakarta Indonesia » Instalasi Virtual Private Network dengan OpenVPN to more catching for your content you write. I enjoyed the blog post still.

  38. 4Avatars v0.3.1 v0.3.1

    mas.., kalo buat openVPN untuk client di ubuntu gimana ya..,
    misal pake kartu X* atau T*lkomsel..,
    thanks ya..,
    .-= dansen´s last blog… Plymouth Ubuntu Sunrise Keren =-.

  39. 4Avatars v0.3.1 v0.3.1

    Another good posting, I appreciate it. I’ve read other posts you made and I you’ve got some nice content. Cheers.

  40. 4Avatars v0.3.1 v0.3.1

    Thank you for give very good informations. Your blog is very goodI am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. You, my friend, ROCK! I found just the information I already searched everywhere and just couldn’t find. What a perfect site. Like this website your website is one of my new favs.I like this information presented and it has given me some sort of desire to succeed for some reason, so keep up the good work

  41. 4Avatars v0.3.1 v0.3.1

    I’ve been seeking for a while to have a beneficial content articles that is related to this subject . Researching in Yahoo and google I ultimately located this website. Seeing this info I’m just lucky to enunciate that I’ve got a wonderful impression I stumbled onto everything that I was ready for. I will make certain to don’t forget this website and take a look constantly.

  42. 4Avatars v0.3.1 v0.3.1

    The theme is definitely superb… You know how to balance writing and media. However, I cant get over how little you actually bring to light here. I think that everyones said the same thing that youve said over and over again. Dont you think its time for something more topical, especially for a college site…?

  43. 4Avatars v0.3.1 v0.3.1

    whoah this blog is great i love reading your posts. Keep up the good work! You know, many people are searching around for this info, you can help them greatly.

Leave a Reply

CommentLuv badge