Junior — Middle
Can you tell about the principles of operation and basics of using iptables for managing network rules?
sobes.tech AI
Answer from AI
iptables is a tool in Linux for configuring network traffic filtering rules at the kernel level. It allows creating, modifying, and deleting rules that determine which packets to accept, reject, or redirect.
Main principles of operation:
- iptables works with tables (filter, nat, mangle, etc.), each containing chains of rules.
- Chains are sequences of rules through which a packet passes.
- Each rule contains criteria (e.g., IP address, port, protocol) and an action (ACCEPT, DROP, REJECT, LOG, etc.).
Example of basic usage:
# Allow incoming SSH traffic
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Block all other incoming traffic
iptables -P INPUT DROP
Thus, iptables allows flexible management of server access, ensuring security and control of network interactions.