tr

VPS Güvenlik Duvarı Kurulumu: UFW ve iptables

Güvenlik duvarı, VPS sunucunuzun dış tehditlere karşı ilk savunma hattıdır. UFW (Uncomplicated Firewall), iptables'ın kullanıcı dostu bir arayüzüdür ve çoğu kullanım senaryosu için yeterlidir. Bu rehberde hem UFW hem de doğrudan iptables kullanımını öğreneceksiniz.

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

UFW ile Temel Güvenlik Duvarı Kurulumu

UFW, Ubuntu ve Debian tabanlı sistemlerde iptables yönetimini kolaylaştıran bir araçtır. UFW durumunu kontrol edin: sudo ufw status verbose UFW'yi etkinleştirmeden önce SSH portunu açın (kendinizi kilitlememek için): sudo ufw allow 2222/tcp sudo ufw allow 80/tcp sudo ufw allow 443/tcp UFW'yi etkinleştirin: sudo ufw enable Mevcut kuralları listeleyin: sudo ufw status numbered Gereksiz bir kuralı silin: sudo ufw delete KURAL_NUMARASI IP adresine göre erişim kısıtlama: sudo ufw allow from 192.168.1.0/24 to any port 3306 sudo ufw deny from 45.33.32.156 UFW varsayılan politikaları - gelen trafiği reddet, giden trafiğe izin ver: sudo ufw default deny incoming sudo ufw default allow outgoing Bu yapılandırma, açıkça izin verilmeyen tüm gelen bağlantıları engeller; güvenlik açısından en iyi başlangıç noktasıdır.

iptables ile Gelişmiş Kural Yönetimi

iptables, Linux'un yerleşik paket filtreleme sistemidir ve UFW'nin altında çalışır. Daha karmaşık senaryolar için doğrudan iptables kullanmak gerekebilir. Mevcut kuralları görüntüleyin: sudo iptables -L -n -v --line-numbers Temel güvenlik kural seti: # Mevcut bağlantılara izin ver sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # Loopback arayüzüne izin ver sudo iptables -A INPUT -i lo -j ACCEPT # SSH portuna izin ver sudo iptables -A INPUT -p tcp --dport 2222 -j ACCEPT # HTTP ve HTTPS'e izin ver sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT # ICMP ping'e izin ver sudo iptables -A INPUT -p icmp -j ACCEPT # Diğer her şeyi reddet sudo iptables -A INPUT -j DROP Kuralları kalıcı hale getirin: sudo apt install -y iptables-persistent sudo netfilter-persistent save

Port Tarama ve DDoS Koruması

Agresif port taramalarına ve DDoS saldırılarına karşı ek iptables kuralları ekleyin. Yeni bağlantı hızını sınırlayın: sudo iptables -A INPUT -p tcp --dport 2222 -m state --state NEW -m recent --set sudo iptables -A INPUT -p tcp --dport 2222 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP SYN flood koruması: sudo iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT sudo iptables -A INPUT -p tcp --syn -j DROP Port tarayıcı tespiti: sudo iptables -A INPUT -m recent --name portscan --rcheck --seconds 86400 -j DROP sudo iptables -A FORWARD -m recent --name portscan --rcheck --seconds 86400 -j DROP Invalid paket koruması: sudo iptables -A INPUT -m conntrack --ctstate INVALID -j DROP sudo iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP Bu kurallar offshore VPS sunucularında özellikle önemlidir; çünkü offshore sunucular yüksek trafik ve saldırı hedefi olabilir.

Güvenlik Duvarı İzleme ve Log Yönetimi

Güvenlik duvarı loglarını düzenli olarak incelemek, saldırı girişimlerini erken tespit etmenizi sağlar. UFW loglarını etkinleştirin: sudo ufw logging on sudo ufw logging medium Logları görüntüleyin: sudo tail -f /var/log/ufw.log sudo grep "BLOCK" /var/log/ufw.log | awk '{print $12}' | sort | uniq -c | sort -rn | head -20 En çok engellenen IP adreslerini listeleyin: sudo grep "UFW BLOCK" /var/log/ufw.log | grep -oP 'SRC=K[d.]+' | sort | uniq -c | sort -rn | head -10 Geçici IP yasağı uygulayın: sudo ufw insert 1 deny from 45.33.32.156 Tüm aktif bağlantıları izleyin: sudo ss -tulpn sudo netstat -an | grep ESTABLISHED | wc -l Anubiz Host offshore VPS planlarında güvenlik duvarı yapılandırmanız üzerinde tam kontrol sahibisiniz; sağlayıcı tarafından dayatılan herhangi bir kısıtlama olmaksızın güvenlik politikalarınızı özgürce belirleyebilirsiniz.

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online