DEV Community

Rümeysa Öz for Açıklab

Posted on

2

Sistem Firewall Kuralları : UFW ve Firewalld

1. UFW (Uncomplicated Firewall)

  • Ubuntu için varsayılan güvenlik duvarı yapılandırma aracı ufw güvenlik duvarıdır.

1.1. Firewall Durumunu Kontrol Etme

a. UFW'nin durumunu kontrol etmek için aşağıdaki komutu kullanın:

sudo ufw status
Enter fullscreen mode Exit fullscreen mode

Örnek çıktı:

Status: active
Enter fullscreen mode Exit fullscreen mode

veya

Status: inactive
Enter fullscreen mode Exit fullscreen mode

Eğer çıktıda "Status: active" görünüyorsa, firewall açıktır. Eğer "Status: inactive" görünüyorsa, firewall kapalıdır.

1.2. Belirli Bir Portu Kontrol Etme

a. UFW ile tüm açık portları ve ilişkili bilgileri kontrol etmek için şu komutu kullanın:

sudo ufw status verbose
Enter fullscreen mode Exit fullscreen mode
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW IN    Anywhere
80/tcp                     ALLOW IN    Anywhere
Enter fullscreen mode Exit fullscreen mode

Bu çıktıda, "ALLOW IN" ifadesi ile listelenen portlar açıktır.

b. Belirli bir portun durumunu kontrol etmek için şu komutu kullanın:

sudo ufw status numbered
Enter fullscreen mode Exit fullscreen mode

Örnek çıktı:

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    Anywhere
[ 2] 80/tcp                     ALLOW IN    Anywhere
Enter fullscreen mode Exit fullscreen mode

Bu çıktıda, numaralarla listelenen portlardan birinin durumunu kontrol edebilirsiniz.

1.3. Belirli Bir Portu Açma veya Kapatma

a. Belirli bir portu açmak için şu komutu kullanın:

sudo ufw allow <port>/tcp
Enter fullscreen mode Exit fullscreen mode

Örnek:

sudo ufw allow 8080/tcp
Enter fullscreen mode Exit fullscreen mode

Bu komut, 8080 numaralı TCP portunu açar.

b. Belirli bir portu kapatmak için şu komutu kullanın:

sudo ufw delete allow <port>/tcp
Enter fullscreen mode Exit fullscreen mode

Örnek:

sudo ufw delete allow 8080/tcp
Enter fullscreen mode Exit fullscreen mode

2. Firewalld

  • CentOS ve bazı Linux dağıtımlarında varsayılan olarak firewalld kullanılmaktadır.

2.1. Firewall Durumunu Kontrol Etme

a. Firewalld'nin durumunu kontrol etmek için aşağıdaki komutu kullanın:

sudo firewall-cmd --state
Enter fullscreen mode Exit fullscreen mode

Örnek çıktı:

running
Enter fullscreen mode Exit fullscreen mode

veya

not running
Enter fullscreen mode Exit fullscreen mode

Eğer çıktıda "running" görünüyorsa, firewall açıktır. Eğer "not running" görünüyorsa, firewall kapalıdır.

2.2. Belirli Bir Portu Kontrol Etme

a. Firewalld ile tüm açık portları kontrol etmek için şu komutu kullanın:

sudo firewall-cmd --list-ports
Enter fullscreen mode Exit fullscreen mode

Örnek çıktı:

8080/tcp 9090/tcp
Enter fullscreen mode Exit fullscreen mode

Bu çıktıda, listelenen portlar açıktır.

2.3. Belirli Bir Portu Açma veya Kapatma

a. Belirli bir portu açmak için şu komutu kullanın:

sudo firewall-cmd --add-port=<port>/tcp
Enter fullscreen mode Exit fullscreen mode

Örnek:

sudo firewall-cmd --add-port=8080/tcp
Enter fullscreen mode Exit fullscreen mode

Bu komut, 8080 numaralı TCP portunu açar.

b. Belirli bir portu kapatmak için şu komutu kullanın:

sudo firewall-cmd --remove-port=<port>/tcp
Enter fullscreen mode Exit fullscreen mode

Örnek:

sudo firewall-cmd --remove-port=8080/tcp
Enter fullscreen mode Exit fullscreen mode

Bu komut, 8080 numaralı TCP portunu kapatır.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay