Yeni Alımlara Özel Türkiye Lokasyon (VDS/VPS) Ürünlerinde %50 İndirim Fırsatı! Kaçırmayın... (Stoklarla Sınırlıdır)

Arama Yap Mesaj Gönder

Biz Sizi Arayalım

+90
X
X
X
X

Knowledge Base

Homepage Knowledge Base SSH Blocking and Allowing IP Addresses ...

Bize Ulaşın

Konum Halkalı merkez mahallesi fatih cd ozgur apt no 46 , Küçükçekmece , İstanbul , 34303 , TR

Blocking and Allowing IP Addresses with IPTables: A Step-by-Step Security Guide

As one of the most powerful tools for firewall management in Linux systems, iptables is used to control incoming and outgoing network traffic. If you want to secure your server, block specific IP addresses, or allow only certain addresses, iptables commands are perfect for the job.

In this article, we explain how to block and allow IPs with iptables, and how to create basic rules in a detailed and understandable step-by-step manner.


What is IPTables? In Brief

IPTables is a firewall tool that runs in the Linux kernel and filters incoming/outgoing connections. It allows port and IP-based filtering by defining detailed rules on protocols such as TCP, UDP, and ICMP.


⚙️ Basic Concepts with IPTables

  • INPUT: Requests coming to the server

  • OUTPUT: Requests going out from the server

  • FORWARD: Requests passing through another interface (router function)

  • ACCEPT: Allow

  • DROP: Silently block

  • REJECT: Block and send notification


Blocking Access to an IP Address (Banning)

Blocking a single IP address:

iptables -A INPUT -s 192.168.1.100 -j DROP

This command rejects all connections from the 192.168.1.100 address.

Subnet blocking (CIDR):

iptables -A INPUT -s 192.168.1.0/24 -j DROP

All connections from the specified network block are blocked.


Granting Access to an IP Address

Allowing a specific IP for only a specific port:

iptables -A INPUT -p tcp -s 192.168.1.100 --dport 22 -j ACCEPT

This command allows SSH (port 22) connections from the 192.168.1.100 IP.

Blocking everyone except for specific IPs:

iptables -A INPUT -p tcp --dport 22 -j DROP
iptables -I INPUT -p tcp -s 192.168.1.100 --dport 22 -j ACCEPT

This order is important: first define DROP, then the exception rule ACCEPT.


Deleting or Clearing a Rule

Deleting a specific IP block:

iptables -D INPUT -s 192.168.1.100 -j DROP

Resetting all rules:

iptables -F

This command resets all rules, use with caution.


Making IPTables Rules Persistent

Ubuntu / Debian:

apt install iptables-persistent
netfilter-persistent save

CentOS / RHEL:

service iptables save

Or:

iptables-save > /etc/sysconfig/iptables

Tips to Avoid IPTables Errors

  • Allow your own IP first, then add blocking rules.

  • If your access is cut off after adding rules, plan physical/console access for recovery.

  • Check with the iptables -L -n --line-numbers command after each rule.


Conclusion

Managing IP addresses with IPTables provides a strong defense, especially against unwanted incoming connections. When applied correctly, it increases the security of your server, limits attacks, and allows you to take control of the network. However, careful configuration is essential; otherwise, you may lose your own access. 

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(350 times viewed / 62 people found it helpful)

Call now to get more detailed information about our products and services.

Diğer Hizmetlerimiz

Web siteniz için uygun fiyatlı Ucuz Hosting Paketleri ile yüksek performanslı barındırma hizmeti sunuyoruz.

Dijital varlığınızı güçlendirmek için profesyonel Sosyal Medya Hesap Yönetimi hizmeti sağlıyoruz.

Görsellerinizi sıkıştırmak için kullanışlı PNG to WebP dönüştürücümüzü deneyin.

Resim boyutlarını küçültmek isteyenler için JPG to WebP aracı idealdir.

SEO uyumu için Robots.txt Oluşturucu aracımızı kullanabilirsiniz.

Htaccess Oluşturucu ile yönlendirme ve erişim ayarlarınızı kolayca yapın.

Kullanıcı deneyimini artırmak için özgün UI/UX Tasarım çözümleri sunuyoruz.

Hızlı ve güvenli kurulum için WordPress hizmetimizden faydalanın.

Sitenizi arama motorlarında yükseltmek için Google Optimizasyon hizmeti sunuyoruz.

Markanızı tanıtmak için Tanıtım Yazısı içerikleri üretiyoruz.

UGC ile içerik gücünüzü artırın: UGC İçerik.

Profesyonel Yazılım Kurulum hizmetleri sunuyoruz.

Kaliteli içerik arayanlara özel Hazır Makale & İçerik Satışları.

Sıra Bulucu ile arama motoru sıralamanızı takip edin.

Google Haritalara Kayıt ile konumunuzu haritada gösterin.

Alan adı otoritenizi öğrenin: DA PA Sorgula.

Dış bağlantılarınızı analiz edin: Dış Link Aracı.

Dahili link yapınızı inceleyin: İç Link Aracı.

Arama motoru başarınızı artırmak için SEO Danışmanlığı alın.

Organik trafiğinizi artırmak için SEO çözümleri geliştirin.

Özel çözümler için Mobil Uygulama geliştirme hizmeti sunuyoruz.

Markanız için Logo tasarlıyoruz.

İşinize özel Web Yazılım çözümleri sunuyoruz.

Kurumsal imajınızı yansıtan Kurumsal Web Tasarım hizmeti.

Süreçlerinizi hızlandırmak için Bot Program geliştiriyoruz.

Online satışlarınız için Sanal POS sistemleri sunuyoruz.

Entegrasyonlar için Pazaryeri ve Kargo Entegrasyonu.

Kullanıcı deneyimi testleri için Son Kullanıcı Testleri.

İçerik indirimi için TikTok Video İndir aracı.

Görsellerinizi kolayca küçültün: Resim Boyutlandırma.

Yararlı kod örnekleri için Site Kodları rehberine göz atın.

Kodları online inceleyin: HTML Viewer.

IP adresinizi öğrenmek için IP Adresim Nedir aracını kullanın.

Bağlantı hızınızı test etmek için Hız Testi.

DNS önbellek sorunları için DNS Cache Problemi sayfasını inceleyin.

DNS değişikliklerini görmek için DNS Önizleme aracı.

IDN dönüştürme için IDN Çevirme kullanın.

Sunuculara ping atmak için Ping Gönder özelliğini deneyin.

Web sitenizin yanıt süresini test etmek için Web Site Ping aracımızı kullanın.

Top