sunucuhataları
teknik çözüm merkezi
Ara Giriş Yap Üye Ol
🏠 Ana Sayfa 📚 Kurulum Rehberleri
Kategoriler
🌐 Web Sunucuları 🐧 İşletim Sistemleri 📦 Sanallaştırma & VPS 🖥️ Kontrol Panelleri 🔒 SSL & Güvenlik 📝 CMS & Uygulamalar 🗄️ Veritabanı 📧 Mail Sunucusu 🗨️ Forum ℹ️ Hakkımızda 📧 İletişim
Giriş Yap Üye Ol
Ana Sayfa SSL & Güvenlik OpenVPN Sunucu Kurulumu: Ubuntu 22.04
🔒 SSL & Güvenlik

OpenVPN Sunucu Kurulumu: Ubuntu 22.04

Ubuntu 22.04'te OpenVPN sunucu kurulumu: PKI altyapısı, CA sertifikası, server.conf yapılandırması ve client ovpn dosyası.

📅 26 Mayıs 2025 👁 15 görüntülenme ⏱ 4 dk okuma
𝕏 Paylaş
📋 İçindekiler göster/gizle

OpenVPN Nedir?

OpenVPN, açık kaynaklı ve son derece esnek bir VPN (Virtual Private Network) çözümüdür. SSL/TLS protokolü kullanarak şifreli tünel oluşturur ve uzak kullanıcıların güvenli biçimde iç ağa erişmesini sağlar. Kurumsal ortamlarda, uzaktan çalışma senaryolarında ve coğrafi kısıtlamaları aşmak için yaygın olarak kullanılır.

OpenVPN'in güçlü yönleri: güçlü TLS şifreleme, NAT geçişi, TCP ve UDP desteği, çapraz platform istemci desteği (Windows, macOS, Linux, iOS, Android) ve geniş yapılandırma esnekliği. Bu rehberde Ubuntu 22.04 üzerinde tam OpenVPN sunucu kurulumunu ele alacağız.

Ön Gereksinimler

  • Ubuntu 22.04 LTS sunucu
  • Root erişimi
  • UDP 1194 (veya TCP 443) portunun açık olması
  • Genel IP adresi

Otomatik Kurulum Scripti (easy-openvpn)

Hızlı kurulum için Nyr'ın OpenVPN kurulum scriptini kullanabilirsiniz:

wget https://git.io/vpn -O openvpn-install.sh
chmod +x openvpn-install.sh
sudo bash openvpn-install.sh

Script size şunları soracak: sunucu IP, protokol (UDP önerilen), port, DNS sunucu seçimi ve ilk istemci adı. Ardından tam kurulumu otomatik yapar.

Manuel Kurulum

Adım 1: OpenVPN ve Easy-RSA Kurulumu

sudo apt update
sudo apt install openvpn easy-rsa -y

Adım 2: PKI Altyapısı Oluşturma

make-cadir /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa
./easyrsa init-pki

Adım 3: CA Oluşturma

./easyrsa build-ca nopass
# Common Name sorusuna: "OpenVPN-CA" yazın

Adım 4: Sunucu Sertifikası

./easyrsa gen-req server nopass
./easyrsa sign-req server server
# "yes" ile onaylayın

Adım 5: Diffie-Hellman Parametreleri

./easyrsa gen-dh
# Bu işlem birkaç dakika sürebilir

Adım 6: TLS Auth Anahtarı

sudo openvpn --genkey secret /etc/openvpn/ta.key

Adım 7: Sertifikaları Kopyalama

sudo cp /etc/openvpn/easy-rsa/pki/ca.crt /etc/openvpn/
sudo cp /etc/openvpn/easy-rsa/pki/issued/server.crt /etc/openvpn/
sudo cp /etc/openvpn/easy-rsa/pki/private/server.key /etc/openvpn/
sudo cp /etc/openvpn/easy-rsa/pki/dh.pem /etc/openvpn/

Adım 8: server.conf Oluşturma

sudo nano /etc/openvpn/server.conf
port 1194
proto udp
dev tun

ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh.pem
tls-auth /etc/openvpn/ta.key 0

server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt

push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 1.1.1.1"

keepalive 10 120
cipher AES-256-GCM
auth SHA256
user nobody
group nogroup
persist-key
persist-tun

status /var/log/openvpn/openvpn-status.log
log-append /var/log/openvpn/openvpn.log
verb 3

Adım 9: IP Forwarding ve NAT

echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

# NAT kuralı ekle
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
sudo apt install iptables-persistent -y
sudo netfilter-persistent save

Adım 10: OpenVPN Başlatma

sudo mkdir -p /var/log/openvpn
sudo systemctl start openvpn@server
sudo systemctl enable openvpn@server
sudo systemctl status openvpn@server

İstemci Sertifikası Oluşturma

cd /etc/openvpn/easy-rsa
./easyrsa gen-req client1 nopass
./easyrsa sign-req client client1

İstemci Yapılandırma Dosyası (.ovpn)

client
dev tun
proto udp
remote SUNUCU_IP 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
cipher AES-256-GCM
auth SHA256
key-direction 1
verb 3

<ca>
(ca.crt içeriği)
</ca>
<cert>
(client1.crt içeriği)
</cert>
<key>
(client1.key içeriği)
</key>
<tls-auth>
(ta.key içeriği)
</tls-auth>

UFW ile Güvenlik Duvarı

sudo ufw allow 1194/udp
sudo ufw allow OpenSSH
sudo ufw enable

Sık Karşılaşılan Sorunlar

TUN Cihazı Oluşturulamıyor

sudo modprobe tun
echo "tun" | sudo tee /etc/modules-load.d/tun.conf

Sonuç

Ubuntu 22.04 üzerinde OpenVPN sunucusunu kurarak güvenli ve şifreli VPN altyapısı oluşturdunuz. PKI altyapısı, sunucu/istemci sertifikaları, TLS auth ve NAT yapılandırmasıyla kurumsal düzeyde güvenli uzaktan erişim imkânı sağladınız.

🤔 Bu kurulumda sorun mu yaşıyorsunuz?

Hata mesajınızı kopyalayıp foruma konu açın. Topluluğumuz size özel durumunuza göre yardımcı olacaktır.

🗨️ Foruma Katıl & Yardım Al

Yorumlar

Henüz yorum yok. İlk yorumu siz yapın!

Yorum Yap

Yorumunuz onaylandıktan sonra yayınlanır.