<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Burak Erdem Yaprak on Medium]]></title>
        <description><![CDATA[Stories by Burak Erdem Yaprak on Medium]]></description>
        <link>https://medium.com/@burak.erdem.yaprak?source=rss-22b824856805------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*F5K7HMzBgJwTm0NG</url>
            <title>Stories by Burak Erdem Yaprak on Medium</title>
            <link>https://medium.com/@burak.erdem.yaprak?source=rss-22b824856805------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:08:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@burak.erdem.yaprak/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Firewall Management on Linux with UFW and Iptables Fundamentals]]></title>
            <link>https://medium.com/@burak.erdem.yaprak/firewall-management-on-linux-with-ufw-and-iptables-fundamentals-76a56b2f12c4?source=rss-22b824856805------2</link>
            <guid isPermaLink="false">https://medium.com/p/76a56b2f12c4</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity-training]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Burak Erdem Yaprak]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 14:54:46 GMT</pubDate>
            <atom:updated>2026-04-24T14:54:46.922Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Allowing /denying network traffic, blocking, logging denied packets, and monitoring with Wazuh SIEM.</em></p><h3>1. Scenario: Publishing a Web Server with Minimum Exposed Surface</h3><p>Assume you are operating a website that only needs to serve HTTP and HTTPS. In that case, the host does not need to accept inbound traffic on random ports, database ports, SSH from the internet, or management interfaces. The secure model is simple: close everything first, then open only what the service actually requires.</p><p>The scenario can be reduced to three technical goals:</p><p>· <strong>Allowed traffic: </strong>HTTP on 80/tcp and HTTPS on 443/tcp.</p><p>· <strong>Blocked traffic: </strong>SSH, database, admin-panel, scanner, or any inbound flow that has not been explicitly allowed.</p><p>· <strong>Observability: </strong>Blocked packets should be visible in /var/log/ufw.log, journald, or a SIEM pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Y7HgPag4buRHFVP_qb0FA.png" /></figure><h3>2. How UFW Relates to Netfilter, iptables, and nftables</h3><p>UFW (Uncomplicated Firewall) is an operational front-end for Linux firewalling. It exposes a safer and more readable interface while relying on the Linux Netfilter stack underneath. Depending on distribution and backend configuration, UFW rules are ultimately translated into iptables or nftables-compatible rule sets.</p><p>iptables was the classic Linux tool for packet filtering, NAT, and port forwarding for many years. nftables is the more modern framework, with a more consistent syntax and a cleaner way to manage IPv4, IPv6, ARP, and bridge filtering. On modern distributions, even the iptables command may use an nftables compatibility backend.</p><p>· <strong>Netfilter: </strong>Kernel-level hook points, connection tracking, and packet decision logic.</p><p>· <strong>iptables/nftables: </strong>Lower-level tools used to express and manage Netfilter rules.</p><p>· <strong>UFW: </strong>A human-friendly front-end that reduces operational mistakes and manages service-oriented rules.</p><p>· <strong>GUFW: </strong>A graphical desktop interface for managing UFW rules.</p><h3>Redesigned Netfilter / UFW Capability Matrix</h3><p>The first feature matrix in the source material has been rebuilt as a structured Word table instead of a screenshot-like visual. The goal is to make the capabilities searchable, readable, and technically useful: UFW is not just a set of beginner commands; it is an operational layer over the Linux Netfilter packet-filtering stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RTbcghmOSAQqB-KKlRNHg.png" /></figure><h3>3. UFW Design for Blocking Everything Except HTTP/HTTPS</h3><p>The web-server policy is straightforward: deny inbound traffic by default, allow outbound traffic, and explicitly open 80/tcp and 443/tcp. When logging is enabled, packets dropped by UFW are typically written through the kernel logging path and, depending on the distribution, into /var/log/ufw.log.</p><p><strong>Recommended baseline UFW rule set for a public web server</strong></p><pre># 1) Install UFW and check service state<br>sudo apt update<br>sudo apt install ufw -y<br>sudo systemctl status ufw<br><br># 2) If IPv6 is in use, configure it before enabling UFW<br>sudo nano /etc/default/ufw<br># IPV6=yes<br><br># 3) Baseline policies<br>sudo ufw default deny incoming<br>sudo ufw default allow outgoing<br><br># 4) Allow web traffic only<br>sudo ufw allow 80/tcp comment &#39;Allow HTTP web traffic&#39;<br>sudo ufw allow 443/tcp comment &#39;Allow HTTPS web traffic&#39;<br><br># 5) Log blocked packets<br>sudo ufw logging medium<br><br># 6) Enable and verify<br>sudo ufw enable<br>sudo ufw status verbose<br>sudo ufw show added</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRlTjBEGxsMoRxG9o-D1eA.png" /></figure><h3>Validation and Testing</h3><p>Writing firewall rules is only half of the job; the rule path must be verified. Prefer testing from another VM, a container, a network namespace, or another client on the same network. Loopback traffic is intentionally allowed on most systems, so localhost testing may not accurately represent inbound firewall behavior.</p><p><strong>UFW validation commands</strong></p><pre># Confirm that web services are listening<br>sudo ss -tulpen | grep -E &#39;:80|:443&#39;<br><br># From another client, test allowed ports<br>curl -I http://&lt;server-ip&gt;<br>curl -kI https://&lt;server-ip&gt;<br><br># Test a port that should not be reachable<br>nc -vz &lt;server-ip&gt; 8080<br>nmap -Pn -p 1-1000 &lt;server-ip&gt;<br><br># Watch blocked traffic logs<br>sudo tail -f /var/log/ufw.log<br>sudo journalctl -k -f | grep UFW<br>sudo grep &#39;UFW BLOCK&#39; /var/log/ufw.log</pre><h3>4. Rule Ordering, deny vs reject, and Operational Details</h3><p>UFW displays rules in a simplified way, but ordered evaluation still matters underneath. Source-specific rules, subnet rules, route rules, and broad policies should be reviewed with the question: “Which rule matches first?” This is especially important when combining allow, deny, limit, and route behavior.</p><p>· <strong>deny: </strong>Silently drops the packet. Scanners often experience a timeout. This is useful when you want to provide minimal feedback.</p><p>· <strong>reject: </strong>Rejects the packet and may return TCP RST or ICMP-style feedback. It is often easier to troubleshoot.</p><p>· <strong>limit: </strong>Rate-limits repeated connection attempts. It reduces brute-force noise, especially on SSH, but it is not a full IDS.</p><p>· <strong>route: </strong>Filters traffic routed through the host, not only traffic destined for local services.</p><p><strong>More advanced UFW examples</strong></p><pre># Allow administration only from a trusted subnet<br>sudo ufw allow from 10.10.10.0/24 to any port 22 proto tcp comment &#39;SSH from VPN subnet&#39;<br><br># Rate-limit SSH attempts<br>sudo ufw limit 22/tcp comment &#39;Rate-limit SSH attempts&#39;<br><br># Use reject behavior for a service that should be explicit<br>sudo ufw reject 25/tcp comment &#39;Reject inbound SMTP on non-mail host&#39;<br><br># Example for routed traffic<br>sudo ufw route allow in on eth1 out on eth0 to any port 443 proto tcp</pre><h4>Practical Command Map</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*883iYVeW9WYIqkVJGNv3zQ.png" /></figure><h3>5. Low-Level iptables Equivalent of the Same Policy</h3><p>UFW is usually the safer operational choice on production hosts, but understanding the lower-level iptables model is essential for troubleshooting. The following example approximates the same HTTP/HTTPS-only policy. Do not mix direct iptables management with UFW on production systems unless you are deliberately controlling rule precedence and persistence.</p><p><strong>iptables example that logs and drops inbound traffic except HTTP/HTTPS</strong></p><pre># WARNING: This directly modifies iptables.<br># Avoid mixed management while UFW is active.<br><br>sudo iptables -P INPUT DROP<br>sudo iptables -P FORWARD DROP<br>sudo iptables -P OUTPUT ACCEPT<br><br>sudo iptables -A INPUT -i lo -j ACCEPT<br>sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT<br>sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT<br>sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT<br><br>sudo iptables -A INPUT -j LOG --log-prefix &#39;BLOCKED_WEBHOST: &#39; --log-level 4<br>sudo iptables -A INPUT -j DROP</pre><p>The conntrack rule keeps return traffic for existing and related flows working. Without state tracking, simply opening inbound service ports is not enough; related responses or established sessions may behave unpredictably. UFW handles much of this through its backend rules and before.rules logic.</p><h3>6. GUFW: Managing UFW Through a Graphical Interface</h3><p>GUFW provides a graphical interface for UFW rule management. On servers, the CLI is usually more auditable and automation-friendly; however, GUFW is useful for desktop Linux, education, and quick visual inspection of rule profiles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*Nuvp6LZcBKvXYcq5r_Sf2g.png" /><figcaption><em>Figure 1 — GUFW baseline status screen: incoming deny and outgoing allow.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3es7_uoXIMH_7_3o5xzyTQ.png" /><figcaption><em>Figure 2 — GUFW rule list with ports, protocols, and inline comments.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cuRHbQGGH2xOl7xSqzuB8g.png" /></figure><h3>7. Expanded Scenario: Blue Team / Red Team SSH Access Control</h3><p>The SSH access example from the source material becomes more realistic when expanded into an operational policy. The goal is to allow SSH only from the Blue Team or VPN network, explicitly block a Red Team address, and keep the result testable and logged.</p><p><strong>Blue Team / Red Team SSH rule set</strong></p><pre># Baseline policy<br>sudo ufw default deny incoming<br>sudo ufw default allow outgoing<br><br># Allow SSH from Blue Team and VPN subnet<br>sudo ufw allow from 192.168.1.10 to any port 22 proto tcp comment &#39;Blue Team SSH&#39;<br>sudo ufw allow from 10.8.0.0/24 to any port 22 proto tcp comment &#39;VPN SSH access&#39;<br><br># Explicitly block Red Team SSH<br>sudo ufw deny from 192.168.1.20 to any port 22 proto tcp comment &#39;Block Red Team SSH&#39;<br><br># Rate-limit generic SSH attempts<br>sudo ufw limit 22/tcp comment &#39;Rate-limit generic SSH attempts&#39;<br><br># Logging and verification<br>sudo ufw logging medium<br>sudo ufw status numbered<br>sudo ufw status verbose</pre><p>The explicit Red Team deny rule is useful for readability and logging, but the real security control is the default deny incoming policy. Not only the Red Team address but every unapproved source is blocked. Nmap may show ports as filtered, closed, or open depending on whether the service is listening and whether the firewall uses deny or reject behavior.</p><h3>8. Monitoring UFW Logs with Wazuh</h3><p>Firewall logs are useful locally, but they become operationally valuable when centralized. Monitoring /var/log/ufw.log with the Wazuh agent allows blocked packet events to be normalized and correlated with other security telemetry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*wd1kYB5JRlRJBQnB49HSbA.png" /><figcaption><em>Figure 3 — Wazuh ossec.conf monitoring UFW logs through a localfile block.</em></figcaption></figure><p><strong>Wazuh agent UFW log source</strong></p><pre>&lt;!-- Example localfile entry in /var/ossec/etc/ossec.conf --&gt;<br>&lt;localfile&gt;<br>  &lt;log_format&gt;syslog&lt;/log_format&gt;<br>  &lt;location&gt;/var/log/ufw.log&lt;/location&gt;<br>&lt;/localfile&gt;</pre><p>In production, tune the rule level, decoder match, and alert thresholds. Internet-facing web servers receive constant scanning, so treating every blocked packet as a high-priority incident creates noise. A better model correlates source IP, repetition count, target port, and time window.</p><h3>9. Operational Hardening Checklist</h3><p>· Before enabling UFW, guarantee SSH access or out-of-band management.</p><p>· Use default deny for inbound traffic and explicitly allow only required service ports.</p><p>· If IPv6 is enabled, verify the IPv6 versions of every important rule.</p><p>· Tune UFW logging for production volume; high/full may create unnecessary disk pressure.</p><p>· Do not expose admin panels, database ports, or container management ports just because HTTP/HTTPS are open.</p><p>· After rule changes, store ufw status numbered and ufw status verbose output in the change record.</p><p>· In the SIEM, correlate blocked logs by repeated source, unexpected target port, and time window rather than alerting on every single drop.</p><h3>Conclusion</h3><p>UFW is simple enough for daily host firewall management but powerful enough for professional Linux operations when used with the right model. The real value is not memorizing individual commands; it is designing default policy, stateful filtering, logging, validation, and centralized monitoring as one system. The HTTP/HTTPS-only web server example is a small but production-relevant application of least privilege.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76a56b2f12c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux UFW ve iptables ile Firewall Yönetimi Temelleri]]></title>
            <link>https://medium.com/@burak.erdem.yaprak/linux-ufw-ve-iptables-ile-firewall-y%C3%B6netimi-temelleri-2b492087a2d9?source=rss-22b824856805------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b492087a2d9</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Burak Erdem Yaprak]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 14:40:45 GMT</pubDate>
            <atom:updated>2026-04-24T14:55:28.714Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux UFW ve iptables ile Firewall Yönetimi</h3><p><em>HTTP/HTTPS trafiğini güvenli şekilde açma, diğer istekleri bloklama, loglama ve Wazuh ile izleme</em></p><h3>1. Senaryo: Bir Web Sunucusunu Minimum Açık Yüzeyle Yayına Almak</h3><p>En basitçe elinizde yalnızca HTTP ve HTTPS üzerinden hizmet verecek bir web sitesi olduğunu düşünün. Bu durumda sunucunun 80/tcp ve 443/tcp dışındaki gelen bağlantıları kabul etmesi gerekmez.</p><p>Bu senaryoda hedef üç parçaya ayrılır:</p><p>· <strong>İzin verilecek trafik: </strong>HTTP için 80/tcp ve HTTPS için 443/tcp.</p><p>· <strong>Engellenecek trafik: </strong>SSH, veritabanı, yönetim paneli veya rastgele port taramaları gibi açıkça izin verilmemiş tüm inbound bağlantılar.</p><p>· <strong>Gözlemlenebilirlik: </strong>Bloklanan paketlerin /var/log/ufw.log, journald veya SIEM tarafında izlenebilmesi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XSlBaF7r1sznklJFE5lVJQ.png" /></figure><h3>2. UFW, Netfilter, iptables ve nftables İlişkisi</h3><p>UFW (Uncomplicated Firewall), Linux çekirdeğindeki Netfilter altyapısı üzerinde çalışan pratik bir yönetim katmanıdır. UFW komutları okunabilir ve operasyonel olarak güvenlidir; arka planda ise sistemin kullandığı backend’e göre iptables veya nftables kuralları üretilir.</p><p>iptables uzun yıllar boyunca Linux sistemlerde paket filtreleme, NAT ve port yönlendirme için standart araç oldu. nftables ise daha modern, daha tutarlı sözdizimine sahip ve IPv4/IPv6/ARP gibi farklı protokol ailelerini tek bir çatı altında yönetmeye daha yatkın bir yaklaşımdır. Modern dağıtımlarda iptables komutları çoğu zaman nftables uyumluluk katmanı üzerinden çalışır.</p><p>· <strong>Netfilter: </strong>Linux kernel seviyesinde hook noktaları, connection tracking ve paket karar mekanizması.</p><p>· <strong>iptables/nftables: </strong>Netfilter kurallarını yazmak ve yönetmek için kullanılan düşük seviyeli araçlar.</p><p>· <strong>UFW: </strong>Bu kuralları daha okunabilir, daha az hata yapılabilir ve servis odaklı yönetilebilir hâle getiren front-end.</p><p>· <strong>GUFW: </strong>UFW için grafiksel arayüz sağlayan masaüstü yönetim katmanı.</p><h3>Netfilter / UFW Özellik Matrisi</h3><p>Kaynak dokümandaki ilk özellik tablosu, okunabilirliği artırmak için görsel yerine düzenli bir Word tablosu olarak yeniden tasarlandı. Amaç, UFW’nin yalnızca birkaç komuttan oluşan basit bir araç değil; Linux Netfilter altyapısı üzerinde kural yönetimi, loglama, yönlendirme ve profil tabanlı yönetim sağlayan bir katman olduğunu netleştirmektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsEAQkpQ0TVIjDM1bHfVcw.png" /></figure><h3>HTTP/HTTPS Dışındaki Trafiği Bloklayan UFW Tasarımı</h3><p>Web sunucusu için temel policy şu şekildedir: gelen tüm bağlantılar reddedilir, giden trafik izinli kalır, yalnızca 80/tcp ve 443/tcp inbound olarak açılır. Loglama etkinleştirildiğinde UFW tarafından düşürülen paketler genellikle kernel log hattına ve dağıtıma göre /var/log/ufw.log dosyasına yazılır.</p><p><strong>Web sunucusu için önerilen temel UFW kural seti</strong></p><pre># 1) UFW kurulumu ve servis kontrolü<br>sudo apt update<br>sudo apt install ufw -y<br>sudo systemctl status ufw<br><br># 2) IPv6 kullanacaksanız, UFW etkinleşmeden önce kontrol edin<br>sudo nano /etc/default/ufw<br># IPV6=yes<br><br># 3) Varsayılan politikalar<br>sudo ufw default deny incoming<br>sudo ufw default allow outgoing<br><br># 4) Web trafiğine izin ver<br>sudo ufw allow 80/tcp comment &#39;Allow HTTP web traffic&#39;<br>sudo ufw allow 443/tcp comment &#39;Allow HTTPS web traffic&#39;<br><br># 5) Bloklanan paketlerin loglanması<br>sudo ufw logging medium<br><br># 6) Etkinleştir ve doğrula<br>sudo ufw enable<br>sudo ufw status verbose<br>sudo ufw show added</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UQ7WkIORn3fqoLiBCEEzQ.png" /></figure><h3>Doğrulama ve Test</h3><p>Firewall kuralı yazmak kadar, kuralın gerçekten beklenen yolu izlediğini test etmek de önemlidir. Testleri mümkünse aynı makinenin localhost trafiğiyle değil, farklı bir VM, container, network namespace veya aynı ağdaki başka bir istemci üzerinden yapın. Loopback arayüzü çoğu sistemde bilinçli olarak serbest bırakılır; bu nedenle localhost testi inbound firewall davranışını tam temsil etmeyebilir.</p><p><strong>UFW kural doğrulama komutları</strong></p><pre># Web servislerinin dinlediğini doğrula<br>sudo ss -tulpen | grep -E &#39;:80|:443&#39;<br><br># Başka bir istemciden izin verilen portları test et<br>curl -I http://&lt;sunucu-ip&gt;<br>curl -kI https://&lt;sunucu-ip&gt;<br><br># Açık olmaması gereken bir portu test et<br>nc -vz &lt;sunucu-ip&gt; 8080<br>nmap -Pn -p 1-1000 &lt;sunucu-ip&gt;<br><br># Blok loglarını izle<br>sudo tail -f /var/log/ufw.log<br>sudo journalctl -k -f | grep UFW<br>sudo grep &#39;UFW BLOCK&#39; /var/log/ufw.log</pre><h3>4. Kural Sırası, deny/reject Farkı ve Operasyonel İncelikler</h3><p>UFW, kuralları kullanıcıya sade gösterse de arka planda sıralı değerlendirme mantığı devam eder. Genel kural olarak daha spesifik allow/deny kuralları, geniş kapsamlı politikalardan önce düşünülmelidir. Özellikle IP bazlı yönetim erişimi, subnet izinleri ve route kuralları yazarken “hangi kural önce eşleşir?” sorusu önemlidir.</p><p>· <strong>deny: </strong>Paketi sessizce düşürür. Tarama yapan istemci çoğu zaman timeout görür. Gizlilik ve düşük geri bildirim için tercih edilir.</p><p>· <strong>reject: </strong>Paketi reddeder ve karşı tarafa TCP RST veya ICMP benzeri bir cevap döndürebilir. Sorun giderme sırasında daha açıklayıcıdır.</p><p>· <strong>limit: </strong>Bağlantı denemelerini sınırlı frekansta kabul eder. SSH brute-force denemelerine karşı temel gürültü azaltma sağlar.</p><p>· <strong>route: </strong>Makinenin yalnızca kendi servislerini değil, üzerinden yönlendirilen paketleri de filtrelemek için kullanılır.</p><p><strong>Daha gelişmiş UFW kullanım örnekleri</strong></p><pre># Yönetim erişimini sadece güvenilir subnetten açmak<br>sudo ufw allow from 10.10.10.0/24 to any port 22 proto tcp comment &#39;SSH from VPN subnet&#39;<br><br># SSH denemelerini hız sınırlamak<br>sudo ufw limit 22/tcp comment &#39;Rate-limit SSH attempts&#39;<br><br># Bir servis için reject davranışı kullanmak<br>sudo ufw reject 25/tcp comment &#39;Reject inbound SMTP on non-mail host&#39;<br><br># Yönlendirilen trafik örneği<br>sudo ufw route allow in on eth1 out on eth0 to any port 443 proto tcp</pre><p><strong>Pratik Komut Haritası</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iUpIWdI7rZidVbpDjWyQQ.png" /></figure><h3>5. iptables ile Aynı Politikanın Düşük Seviyeli Karşılığı</h3><p>UFW üretim sunucularında insan hatasını azaltmak için iyi bir tercih olsa da, iptables veya nftables mantığını bilmek sorun giderme sırasında kritiktir. Aşağıdaki örnek, UFW ile kurduğumuz HTTP/HTTPS-only politikasının düşük seviyeli karşılığıdır. Üretimde doğrudan kullanmadan önce mevcut UFW kurallarıyla çakışmayacağından emin olun.</p><p><strong>HTTP/HTTPS dışındaki inbound trafiği loglayıp düşüren iptables örneği</strong></p><pre># UYARI: Bu örnek, doğrudan iptables üzerinde çalışır.<br># UFW aktifken karışık yönetim yapmayın.<br><br>sudo iptables -P INPUT DROP<br>sudo iptables -P FORWARD DROP<br>sudo iptables -P OUTPUT ACCEPT<br><br>sudo iptables -A INPUT -i lo -j ACCEPT<br>sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT<br>sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT<br>sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT<br><br>sudo iptables -A INPUT -j LOG --log-prefix &#39;BLOCKED_WEBHOST: &#39; --log-level 4<br>sudo iptables -A INPUT -j DROP</pre><p>Bu örnekte conntrack modülü mevcut bağlantıların dönüş paketlerini korur. Aksi hâlde sadece inbound portları açmak yeterli olmaz; cevap trafiği veya ilişkili bağlantılar beklenmedik şekilde kırılabilir. UFW bunu sizin adınıza before.rules ve backend kurallarıyla yönetir.</p><h3>6. GUFW: Grafiksel Arayüz ile UFW Yönetimi</h3><p>GUFW, masaüstü sistemlerde UFW kurallarını grafik arayüz üzerinden yönetmek için kullanılır. Sunucu ortamlarında CLI daha izlenebilir ve otomasyona daha uygundur; ancak eğitim, hızlı profil inceleme veya masaüstü Linux kullanımında GUFW anlaşılır bir başlangıç noktası sağlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*Nuvp6LZcBKvXYcq5r_Sf2g.png" /><figcaption><em>Şekil 1 — GUFW temel durum ekranı: incoming deny, outgoing allow modeli.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3es7_uoXIMH_7_3o5xzyTQ.png" /><figcaption><em>Şekil 2 — GUFW kural listesi: port, protokol ve yorumlarla görsel kural yönetimi.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpdE_L3w8PzsXo9yt1Uyxw.png" /></figure><h3>7. Genişletilmiş Senaryo: Blue Team / Red Team SSH Erişim Kontrolü</h3><p>SSH erişim örneği, gerçek operasyonel bağlamda biraz daha geniş düşünülmelidir. Amaç, yönetim sunucusuna yalnızca Blue Team ağından SSH erişimi vermek; Red Team adresini ve diğer tüm kaynakları engellemektir. Ayrıca kuralın loglanması ve test edilebilir olması gerekir.</p><p><strong>Blue Team / Red Team SSH kural seti</strong></p><pre># Varsayılan politika<br>sudo ufw default deny incoming<br>sudo ufw default allow outgoing<br><br># Blue Team veya VPN subnetinden SSH izinleri<br>sudo ufw allow from 192.168.1.10 to any port 22 proto tcp comment &#39;Blue Team SSH&#39;<br>sudo ufw allow from 10.8.0.0/24 to any port 22 proto tcp comment &#39;VPN SSH access&#39;<br><br># Red Team IP adresini özellikle reddet<br>sudo ufw deny from 192.168.1.20 to any port 22 proto tcp comment &#39;Block Red Team SSH&#39;<br><br># SSH denemeleri için rate limiting<br>sudo ufw limit 22/tcp comment &#39;Rate-limit generic SSH attempts&#39;<br><br># Loglama ve durum kontrolü<br>sudo ufw logging medium<br>sudo ufw status numbered<br>sudo ufw status verbose</pre><p>Bu tasarımda Red Team IP’si için açık bir deny kuralı bulunur; fakat gerçek güvenlik, default deny incoming politikasından gelir. Çünkü yalnızca Red Team değil, izin verilmemiş tüm kaynaklar kapalıdır. Nmap çıktısında port durumu filtered, closed veya open görünebilir; bu sonuç firewall davranışı, servis dinleme durumu ve reject/deny tercihine göre değişir.</p><h3>8. UFW Loglarını Wazuh ile İzleme</h3><p>Firewall logları tek başına anlamlıdır; fakat merkezi görünürlük için SIEM tarafına taşındığında olay korelasyonu yapılabilir. Wazuh agent üzerinde /var/log/ufw.log dosyasının izlenmesi, bloklanan bağlantıların güvenlik olaylarına dönüştürülmesini sağlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*wd1kYB5JRlRJBQnB49HSbA.png" /><figcaption><em>Şekil 3 — Wazuh ossec.conf içinde UFW log dosyasının localfile olarak izlenmesi.</em></figcaption></figure><p><strong>Wazuh agent üzerinde UFW log kaynağı</strong></p><pre>&lt;!-- /var/ossec/etc/ossec.conf içinde örnek localfile tanımı --&gt;<br>&lt;localfile&gt;<br>  &lt;log_format&gt;syslog&lt;/log_format&gt;<br>  &lt;location&gt;/var/log/ufw.log&lt;/location&gt;<br>&lt;/localfile&gt;</pre><p><strong>UFW BLOCK olayları için örnek Wazuh kuralı</strong></p><pre>&lt;!-- /var/ossec/etc/rules/local_rules.xml içinde örnek kural --&gt;<br>&lt;group name=&quot;firewall,ufw,&quot;&gt;<br>  &lt;rule id=&quot;100101&quot; level=&quot;8&quot;&gt;<br>    &lt;decoded_as&gt;iptables&lt;/decoded_as&gt;<br>    &lt;match&gt;UFW BLOCK&lt;/match&gt;<br>    &lt;description&gt;UFW blocked packet detected on Linux host&lt;/description&gt;<br>  &lt;/rule&gt;<br>&lt;/group&gt;</pre><p>Üretim ortamında kural seviyesini, decoder eşleşmesini ve alarm gürültüsünü test ederek ayarlamak gerekir. Özellikle internete açık web sunucularında port taramaları çok yoğun olabilir; bu nedenle sadece “her blok bir alarmdır” yaklaşımı yerine kaynak IP, tekrar sayısı, hedef port ve zaman penceresiyle korelasyon yapmak daha sağlıklıdır.</p><h3>9. Operasyonel Kontrol Listesi</h3><p>· UFW etkinleştirilmeden önce SSH veya out-of-band yönetim erişimi garanti altına alınmalı.</p><p>· Varsayılan inbound policy deny olmalı; yalnızca ihtiyaç duyulan portlar açılmalı.</p><p>· IPv6 aktifse kuralların IPv6 karşılıkları ayrıca doğrulanmalı.</p><p>· UFW log seviyesi üretim log hacmine göre ayarlanmalı; high/full seviyeleri gereksiz disk tüketebilir.</p><p>· Web sunucusunda HTTP/HTTPS açık olsa bile admin paneli, database portu veya container management portları internete açılmamalı.</p><p>· Kural değişiklikleri sonrası ufw status numbered ve ufw status verbose çıktısı değişiklik kaydına eklenmeli.</p><p>· SIEM entegrasyonunda yalnızca blok logları değil, aynı IP’den tekrar eden denemeler ve beklenmeyen port hedefleri korele edilmeli.</p><h3>Sonuç</h3><p>UFW, Linux üzerinde güvenli host firewall yönetimi için sade ama güçlü bir arayüz sağlar. Profesyonel kullanımda asıl değer, tekil komutları bilmekten çok; default policy, stateful filtering, loglama, test metodolojisi ve merkezi izleme yaklaşımını birlikte tasarlamaktan gelir. HTTP/HTTPS-only web sunucusu örneği küçük görünse de, least privilege mantığının pratik ve üretime uygulanabilir bir modelidir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b492087a2d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>