我需要一些帮助来建立IPTables。大多数情况下,配置是有效的,但是不管我尝试了什么,我都不能允许localhost只访问本地Apache (即localhost访问localhost:80 )。
这是我的剧本:
#!/bin/bash
# Allow root to access external web and ftp
iptables -t filter -A OUTPUT -p tcp --dport 21 --match owner --uid-owner 0 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 80 --match owner --uid-owner 0 -j ACCEPT
#Allow DNS queries
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
# Allow in and outbound SSH to/from any server
iptables -A INPUT -p tcp -s 0/0 --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp -d 0/0 --sport 22 -j ACCEPT
# Accept ICMP requests
iptables -A INPUT -p icmp -s 0/0 -j ACCEPT
iptables -A OUTPUT -p icmp -d 0/0 -j ACCEPT
# Accept connections from any local machines but disallow localhost access to networked machines
iptables -A INPUT -s 10.0.1.0/24 -j ACCEPT
iptables -A OUTPUT -d 10.0.1.0/24 -j DROP
# Drop ALL other traffic
iptables -A OUTPUT -p tcp -d 0/0 -j DROP
iptables -A OUTPUT -p udp -d 0/0 -j DROP现在我尝试了许多排列,显然我错过了所有的东西。我将它们放在入/出绑定SSH到/from的上方,所以这不是优先级顺序。
如果有人能告诉我只允许本地机器访问本地web服务器,那就太好了。
而且--当上面的配置运行时,我不能(从Windows框中)按名称-通过IP访问主机。我需要什么才能允许主机解析?
干杯伙计们。
发布于 2010-06-14 05:57:42
一般性建议--在规则集的开头添加:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -F
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT在此之后附上你的规则。我真的不明白你为什么要阻止本地主机访问某些东西。这会引起很多问题..。使用dns、mysql和任何其他本地服务。
https://serverfault.com/questions/150927
复制相似问题