2016-03-06 15:50:33 +00:00
|
|
|
# iptables
|
|
|
|
|
2017-07-20 19:53:15 +01:00
|
|
|
> Program that allows configuration of tables, chains and rules provided by the Linux kernel firewall.
|
2016-03-06 15:50:33 +00:00
|
|
|
|
|
|
|
- See chains and rules for specific table:
|
|
|
|
|
|
|
|
`sudo iptables -t {{table_name}} -vnL`
|
|
|
|
|
|
|
|
- Set chain policy rule:
|
|
|
|
|
2017-12-11 15:36:15 +00:00
|
|
|
`sudo iptables -P {{chain}} {{rule}}`
|
2016-03-06 15:50:33 +00:00
|
|
|
|
|
|
|
- Append rule to chain policy for IP:
|
|
|
|
|
|
|
|
`sudo iptables -A {{chain}} -s {{ip}} -j {{rule}}`
|
|
|
|
|
|
|
|
- Append rule to chain policy for IP considering protocol and port:
|
|
|
|
|
|
|
|
`sudo iptables -A {{chain}} -s {{ip}} -p {{protocol}} --dport {{port}} -j {{rule}}`
|
|
|
|
|
|
|
|
- Delete chain rule:
|
|
|
|
|
|
|
|
`sudo iptables -D {{chain}} {{rule_line_number}}`
|
|
|
|
|
2016-04-21 13:44:40 +01:00
|
|
|
- Save iptables configuration:
|
2016-03-06 15:50:33 +00:00
|
|
|
|
2016-07-13 09:53:22 +01:00
|
|
|
`sudo iptables-save > {{path/to/iptables_file}}`
|