iptables
Linux, and
Syntax
iptables [-t table] command chain rule-specification
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-A |
|
Common | |
-I |
|
Common | |
-D |
|
Common | |
-L |
|
Common | |
-F |
|
Common | |
-P |
|
Common | |
-j |
(ACCEPT/DROP/REJECT) | |
Common |
-p |
(tcp/udp/icmp) | |
Common |
Examples
(, )
iptables -L -n --line-numbers
80
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT
SSH
iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
()
iptables-save > /etc/iptables.rules
Tips
- ,
- iptables-save,
- Recommended nftables firewalld
- SSH,