只允许 telnet 和 ftp 访问的 iptables.rules
Only allow access using telnet and FTP ports
————————————————————
端口说明:
21: FTP
23: telnet
# Generated by iptables-save v1.8.7 on Thu Mar 14 09:49:03 2024
*filter
:INPUT DROP [9:540]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 23 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 23 -j ACCEPT
-A OUTPUT -j ACCEPT
COMMIT
# Completed on Thu Mar 14 09:49:03 2024
特别说明:打开了本地端口和本机出口。
开放PING功能
如果想要PING,需要加上这个:
iptables -A INPUT -p icmp --icmp 8 -j ACCEPT
iptables -A OUTPUT -p icmp --icmp 0 -j ACCEPT
–icmp 8:回显请求
–icmp 0:回显应答
不想让别人PING本机:
iptables -t filter -A INPUT -p icmp -j REJECT
清除所有防火墙规则(开放)
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F