Difference between revisions of "Mikrotik: OpenVPN Server ke Kali Linux Client"

From OnnoWiki
Jump to navigation Jump to search
(Created page with "Berikut adalah **langkah-langkah lengkap untuk konfigurasi OpenVPN Server di MikroTik** agar dapat diakses oleh **client Kali Linux**: --- ## ✅ 1. **Persiapan** Pastikan...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
Berikut adalah **langkah-langkah lengkap untuk konfigurasi OpenVPN Server di MikroTik** agar dapat diakses oleh **client Kali Linux**:
+
Berikut adalah '''langkah-langkah lengkap untuk konfigurasi OpenVPN Server di MikroTik''' agar dapat diakses oleh '''client Kali Linux''':
  
---
+
==Persiapan==
 
 
## ✅ 1. **Persiapan**
 
  
 
Pastikan MikroTik dan Kali Linux:
 
Pastikan MikroTik dan Kali Linux:
Line 11: Line 9:
 
* Kali Linux memiliki OpenVPN terinstal (`sudo apt install openvpn`)
 
* Kali Linux memiliki OpenVPN terinstal (`sudo apt install openvpn`)
  
---
+
==Generate Certificate dan Key==
  
## 🛠️ 2. **Generate Certificate dan Key**
+
Gunakan fitur '''MikroTik Certificate''' untuk membuat sertifikat.
  
Gunakan fitur **MikroTik Certificate** untuk membuat sertifikat.
+
'''a. Buat CA:'''
  
### a. Buat CA:
+
/certificate
 +
add name=ca-template common-name=myCA key-usage=key-cert-sign,crl-sign
 +
sign ca-template name=ca-cert
  
```shell
+
'''b. Buat Server Certificate:'''
/certificate
 
add name=ca-template common-name=myCA key-usage=key-cert-sign,crl-sign
 
sign ca-template name=ca-cert
 
```
 
  
### b. Buat Server Certificate:
+
add name=server-template common-name=server
 +
sign server-template ca=ca-cert name=server-cert
  
```shell
+
'''c. Buat Client Certificate:'''
add name=server-template common-name=server
 
sign server-template ca=ca-cert name=server-cert
 
```
 
  
### c. Buat Client Certificate:
+
add name=client-template common-name=client
 +
sign client-template ca=ca-cert name=client-cert
  
```shell
+
==Enable OpenVPN Server==
add name=client-template common-name=client
 
sign client-template ca=ca-cert name=client-cert
 
```
 
  
---
+
/interface ovpn-server server
 +
set enabled=yes \
 +
    certificate=server-cert \
 +
    require-client-certificate=yes \
 +
    auth=sha1 \
 +
    cipher=aes256 \
 +
    port=1194
  
## 🌐 3. **Enable OpenVPN Server**
+
==Buat PPP Profile dan Secret==
  
```shell
+
'''a. Buat profile:'''
/interface ovpn-server server
 
set enabled=yes \
 
  certificate=server-cert \
 
  require-client-certificate=yes \
 
  auth=sha1 \
 
  cipher=aes256 \
 
  port=1194
 
```
 
  
---
+
/ppp profile
 +
add name=ovpn-profile local-address=10.8.0.1 remote-address=10.8.0.2 dns-server=8.8.8.8
  
## 🔐 4. **Buat PPP Profile dan Secret**
+
'''b. Buat user untuk VPN:'''
  
### a. Buat profile:
+
/ppp secret
 +
add name=client password=123 profile=ovpn-profile service=ovpn
  
```shell
+
==Buka Firewall port OpenVPN==
/ppp profile
 
add name=ovpn-profile local-address=10.8.0.1 remote-address=10.8.0.2 dns-server=8.8.8.8
 
```
 
  
### b. Buat user untuk VPN:
+
/ip firewall filter
 +
add chain=input protocol=tcp dst-port=1194 action=accept
  
```shell
+
==Export Sertifikat dan Kunci==
/ppp secret
 
add name=client password=123 profile=ovpn-profile service=ovpn
 
```
 
 
 
---
 
 
 
## 📤 5. **Export Sertifikat dan Kunci**
 
  
 
Export sertifikat agar bisa digunakan di Kali Linux:
 
Export sertifikat agar bisa digunakan di Kali Linux:
  
```shell
+
/certificate export-certificate ca-cert export-passphrase=""
/certificate export-certificate ca-cert export-passphrase=""
+
/certificate export-certificate client-cert export-passphrase="123456789"
/certificate export-certificate client-cert export-passphrase=""
 
```
 
  
Download file `.crt` dan `.key` dari **Files** di MikroTik:
+
Download file `.crt` dan `.key` dari '''Files''' di MikroTik:
  
 
* `ca-cert.crt`
 
* `ca-cert.crt`
Line 88: Line 69:
 
* `client-cert.key`
 
* `client-cert.key`
  
---
+
==Konfigurasi Client OpenVPN di Kali Linux==
 
 
## 💻 6. **Konfigurasi Client OpenVPN di Kali Linux**
 
 
 
### a. Install OpenVPN (jika belum)
 
 
 
```bash
 
sudo apt update && sudo apt install openvpn
 
```
 
  
### b. Buat file konfigurasi: `client.ovpn`
+
'''a. Install OpenVPN (jika belum)'''
  
```ovpn
+
sudo apt update && sudo apt install openvpn
client
 
dev tun
 
proto tcp
 
remote [IP-PUBLIK-MIKROTIK] 1194
 
resolv-retry infinite
 
nobind
 
persist-key
 
persist-tun
 
remote-cert-tls server
 
  
auth-user-pass
+
'''b. Buat file konfigurasi: `client.ovpn`'''
cipher AES-256-CBC
 
auth SHA1
 
  
ca ca-cert.crt
+
client
cert client-cert.crt
+
dev tun
key client-cert.key
+
proto tcp
 +
remote [IP-PUBLIK-MIKROTIK] 1194
 +
resolv-retry infinite
 +
nobind
 +
persist-key
 +
persist-tun
 +
remote-cert-tls server
 +
 +
auth-user-pass
 +
cipher AES-256-GCM
 +
auth SHA1
  
verb 3
+
ca cert_export_ca-cert.crt
```
+
cert cert_export_client-cert.crt
 +
key client-cert.key
 +
 +
verb 3
  
### c. Simpan file `client.ovpn`, `ca-cert.crt`, `client-cert.crt`, dan `client-cert.key` di folder yang sama.
+
'''c. Simpan file `client.ovpn`, `ca-cert.crt`, `client-cert.crt`, dan `client-cert.key` di folder yang sama.'''
  
---
+
==Menjalankan VPN dari Kali==
  
## ▶️ 7. **Menjalankan VPN dari Kali**
+
sudo openvpn --config client.ovpn
 
 
```bash
 
sudo openvpn --config client.ovpn
 
```
 
  
 
Masukkan username dan password sesuai yang dibuat di MikroTik (`client` dan `123`).
 
Masukkan username dan password sesuai yang dibuat di MikroTik (`client` dan `123`).
  
---
+
==Verifikasi Koneksi==
 
 
## 🔍 8. **Verifikasi Koneksi**
 
  
 
Di MikroTik:
 
Di MikroTik:
  
```shell
+
/ppp active print
/ppp active print
 
```
 
  
 
Akan muncul entry koneksi OVPN aktif dari client.
 
Akan muncul entry koneksi OVPN aktif dari client.
 
---
 
 
Kalau mau saya buatin juga file `.ovpn` lengkap beserta struktur foldernya, tinggal bilang aja.
 

Latest revision as of 16:17, 13 May 2025

Berikut adalah langkah-langkah lengkap untuk konfigurasi OpenVPN Server di MikroTik agar dapat diakses oleh client Kali Linux:

Persiapan

Pastikan MikroTik dan Kali Linux:

  • MikroTik sudah memiliki koneksi internet
  • Port TCP 1194 terbuka di firewall MikroTik
  • Kali Linux memiliki OpenVPN terinstal (`sudo apt install openvpn`)

Generate Certificate dan Key

Gunakan fitur MikroTik Certificate untuk membuat sertifikat.

a. Buat CA:

/certificate
add name=ca-template common-name=myCA key-usage=key-cert-sign,crl-sign
sign ca-template name=ca-cert

b. Buat Server Certificate:

add name=server-template common-name=server
sign server-template ca=ca-cert name=server-cert

c. Buat Client Certificate:

add name=client-template common-name=client
sign client-template ca=ca-cert name=client-cert

Enable OpenVPN Server

/interface ovpn-server server
set enabled=yes \
   certificate=server-cert \
   require-client-certificate=yes \
   auth=sha1 \
   cipher=aes256 \
   port=1194

Buat PPP Profile dan Secret

a. Buat profile:

/ppp profile
add name=ovpn-profile local-address=10.8.0.1 remote-address=10.8.0.2 dns-server=8.8.8.8

b. Buat user untuk VPN:

/ppp secret
add name=client password=123 profile=ovpn-profile service=ovpn

Buka Firewall port OpenVPN

/ip firewall filter
add chain=input protocol=tcp dst-port=1194 action=accept

Export Sertifikat dan Kunci

Export sertifikat agar bisa digunakan di Kali Linux:

/certificate export-certificate ca-cert export-passphrase=""
/certificate export-certificate client-cert export-passphrase="123456789"

Download file `.crt` dan `.key` dari Files di MikroTik:

  • `ca-cert.crt`
  • `client-cert.crt`
  • `client-cert.key`

Konfigurasi Client OpenVPN di Kali Linux

a. Install OpenVPN (jika belum)

sudo apt update && sudo apt install openvpn

b. Buat file konfigurasi: `client.ovpn`

client
dev tun
proto tcp
remote [IP-PUBLIK-MIKROTIK] 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server

auth-user-pass
cipher AES-256-GCM
auth SHA1
ca cert_export_ca-cert.crt
cert cert_export_client-cert.crt
key client-cert.key

verb 3

c. Simpan file `client.ovpn`, `ca-cert.crt`, `client-cert.crt`, dan `client-cert.key` di folder yang sama.

Menjalankan VPN dari Kali

sudo openvpn --config client.ovpn

Masukkan username dan password sesuai yang dibuat di MikroTik (`client` dan `123`).

Verifikasi Koneksi

Di MikroTik:

/ppp active print

Akan muncul entry koneksi OVPN aktif dari client.