This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:firewall:iptables [2021/09/27 12:22] gcooper |
networking:firewall:iptables [2022/07/29 11:12] (current) gcooper |
||
---|---|---|---|
Line 4: | Line 4: | ||
http:// | http:// | ||
+ | |||
+ | List rules: | ||
+ | |||
+ | < | ||
+ | iptables -nL < | ||
+ | </ | ||
===== Flush All ===== | ===== Flush All ===== | ||
- | - Set the **default policies** for each of the built-in chains to '' | + | - **Set the default policies** for each of the built-in chains to '' |
- **Flush** the '' | - **Flush** the '' | ||
- **Flush all chains** (-F) | - **Flush all chains** (-F) | ||
- **Delete all non-default chains** (-X) | - **Delete all non-default chains** (-X) | ||
+ | - **Flush all counters** (-Z) | ||
< | < | ||
Line 16: | Line 23: | ||
iptables -P FORWARD ACCEPT | iptables -P FORWARD ACCEPT | ||
iptables -P OUTPUT ACCEPT | iptables -P OUTPUT ACCEPT | ||
- | iptables -t nat -F | ||
- | iptables -t mangle -F | ||
iptables -F | iptables -F | ||
iptables -X | iptables -X | ||
+ | iptables -Z | ||
+ | iptables -t nat -F | ||
+ | iptables -t nat -X | ||
+ | iptables -t mangle -F | ||
+ | iptables -t mangle -X | ||
+ | iptables -t raw -F | ||
+ | iptables -t raw -X | ||
+ | </ | ||
+ | |||
+ | ===== Docker ===== | ||
+ | |||
+ | How to firewall external access to Docker ' | ||
+ | |||
+ | < | ||
+ | iptables -L DOCKER-USER >/ | ||
+ | iptables -I DOCKER-USER 1 -i eth0 -m conntrack --ctstate RELATED, | ||
+ | iptables -I DOCKER-USER 2 -i eth0 -m conntrack --ctstate INVALID -j DROP | ||
+ | iptables -I DOCKER-USER 3 -i eth0 --match multiport -p tcp --dports 80,443 -j ACCEPT | ||
+ | iptables -I DOCKER-USER 4 -i eth0 -m conntrack --ctstate NEW -j LOG --log-prefix " | ||
+ | iptables -I DOCKER-USER 5 -i eth0 -m conntrack --ctstate NEW -j DROP | ||
+ | |||
+ | iptables -nL DOCKER-USER -v | ||
</ | </ | ||