Tmux Essentials and Best Practices: A Modern Terminal Multiplexer Guide
Master Tmux essentials and enterprise best practices: session persistence, pane management, custom keybindings, and hardened DevSecOps remote workflows.
Nov 6, 2026Productivity
In the world of Linux system administration and cybersecurity, iptables plays a critical role in controlling the flow of network traffic. It is a command-line utility that enables administrators to configure packet filtering rules, allowing or blocking traffic based on IP addresses, protocols, ports, and other parameters.
Even though newer tools like nftables are emerging, iptables is still widely used in production environments due to its reliability and flexibility.
iptables works by organizing firewall rules into tables, and each table contains multiple chains. Each chain consists of rules, which define how packets should be handled.
Tables - Define the context (filtering, NAT, or mangle).
filter - Default table, handles packet filtering.nat - Network Address Translation (e.g., port forwarding).mangle - Alters packet headers.raw - Exempt from connection tracking.Chains - Built-in or user-defined lists of rules.
INPUT - Handles incoming packets to the local system.OUTPUT - Handles packets generated by the system.FORWARD - Handles packets routed through the system.Rules - Define matches and actions.
ACCEPT, DROP, REJECT, LOG, etc.sudo iptables -L -v -nsudo iptables -Fsudo iptables -A INPUT -p tcp --dport 22 -j ACCEPTsudo iptables -A INPUT -s 192.168.1.100 -j DROPsudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPTsudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPTForward incoming traffic on port 8080 to internal server 192.168.1.10:80:
sudo iptables -t nat -A PREROUTING -p tcp --dport 8080 \
-j DNAT --to-destination 192.168.1.10:80Enable IP forwarding:
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forwardImagine you run an e-commerce store on Linux. You only want to expose ports 80 (HTTP) and 443 (HTTPS) to customers. By using iptables, you can block all other inbound traffic except SSH from your office IP address. This drastically reduces the attack surface and protects against automated scans and brute-force attempts.
A company providing DNS services may become a target of DDoS attacks. By applying iptables rate-limiting rules, the administrator can throttle excessive DNS queries from suspicious IPs, preventing abuse of the service.
Example:
sudo iptables -A INPUT -p udp --dport 53 -m limit --limit 20/s -j ACCEPTA remote IT team manages servers across multiple data centers. To prevent unauthorized SSH login attempts, the administrator configures iptables to only allow SSH from a VPN subnet (10.8.0.0/24), dropping all other SSH traffic.
sudo iptables -A INPUT -p tcp --dport 22 -s 10.8.0.0/24 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -j DROPiptables rules are not persistent across reboots by default. To make them persistent:
On Debian/Ubuntu:
sudo apt install iptables-persistent
sudo netfilter-persistent saveOn CentOS/RHEL:
sudo service iptables saveiptables remains a powerful tool for Linux security and traffic management. While modern systems may use firewalld or nftables for easier configuration, understanding iptables gives administrators low-level control over packet filtering and security policies.
Whether you're securing a single web server or defending an enterprise network, iptables is a cornerstone of Linux security.
Love it? Share this article: