Operations 4 min read

Essential Linux iptables Rules Every Sysadmin Should Know

This guide presents a collection of commonly used Linux iptables rules—ranging from deleting existing rules and setting default policies to allowing specific services like SSH, HTTP, HTTPS, and configuring port forwarding, logging, and DoS protection—so you can tailor firewall settings to your environment.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Essential Linux iptables Rules Every Sysadmin Should Know

Below are some commonly used Linux iptables rules; adjust them to your specific needs.

# 1. Delete all existing rules

# 2. Set default chain policy

# 3. Block a specific IP address

# 4. Allow all incoming SSH

# 5. Allow SSH from a specific network

# 6. Allow incoming HTTP

# 7. Multiple ports (allow incoming SSH, HTTP, HTTPS)

# 8. Allow outgoing SSH

# 9. Allow outgoing SSH to a specific network

# 10. Allow outgoing HTTPS

# 11. Load balance incoming HTTPS traffic

# 12. Internal to external ping

# 13. External to internal ping

# 14. Allow loopback access

# 15. Allow packets from internal network to external

# 16. Allow outgoing DNS

# 17. Allow NIS connections

# 18. Allow rsync from a specific network

# 19. Allow MySQL connections from a specific network

# 20. Allow Sendmail or Postfix

# 21. Allow IMAP and IMAPS

# 22. Allow POP3 and POP3S

# 23. Prevent DoS attacks

# 24. Forward port 422 to port 22

# 25. Log dropped packets

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Sysadminnetwork securityiptables
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.