cheat-sheets/iptables.md
2024-01-19 09:52:59 +03:00

40 lines
583 B
Markdown

# Iptables.
## Allow ssh traffic.
~~~
iptables -A INPUT -p tcp --dport=22 -j ACCEPT
# -A Append (End table) | -I Insert (Start table).
# -p Protocol.
# -j Action.
~~~
## Allow localhost traffic.
~~~
iptables -A INPUT -i lo -j ACCEPT
# -i Interface name.
~~~
## Allow ping.
~~~
iptables -A INPUT -p icmp -j ACCEPT
~~~
## Warning!!!.
~~~
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
~~~
## Input policy drop.
~~~
iptables -P INPUT DROP
~~~
## Save/Restore rules from file.
~~~
iptables-save > ./filename.rules
# iptables-restore < ./filename.rules
~~~