教程
http://man.linuxde.net/iptables
https://www.cnblogs.com/zclzhao/p/5081590.html
http://blog.51cto.com/ailixing/38543
https://www.linuxprobe.com/chapter-08.html
http://blog.51cto.com/xiaogongju/2087254
https://blog.csdn.net/reyleon/article/details/12976341
http://www.zsythink.net/archives/1199
https://www.cnblogs.com/linuxprobe/p/5643684.html
1 2 3 4 5 6
| iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -A INPUT -p tcp --dport 21 -j ACCEPT iptables -A INPUT -p udp --dport 21 -j ACCEPT iptables -A INPUT -p icmp -j ACCEPT iptables -P INPUT DROP
|
概述
- 未开放的端口,用
nmap
扫描的话,端口状态是closed
;
命令概览
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| -I -A -D -R -L -F service iptables save iptables-save iptables-restore
service iptables stop systemctl stop iptables
service iptables restart systemctl restart iptables
service iptables start systemctl start iptables
|
1 2 3 4
| -s(source)//数据包的发送源 -p(protocol)//协议 --dport(端口) -j 规则执行的操作
|
列出规则,主要开关-L
1 2 3 4 5 6
| iptables -L -n -v
iptables -L -n --line-numbers iptables -nvL --line-n
|
1 2
| iptables-save > ~/iptables.rules iptables-restore < ~/iptables.rules
|
1
| service iptables restart
|
1 2
| iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
1
| iptables -A OUTPUT -j ACCEPT
|
1
| iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
|
Debian 上的 iptables
https://wiki.debian.org/iptables
Iptables if-pre-up blocking my network interfaces - Debian