首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IPTables配置帮助

IPTables配置帮助
EN

Server Fault用户
提问于 2010-06-14 05:12:53
回答 1查看 191关注 0票数 0

我需要一些帮助来建立IPTables。大多数情况下,配置是有效的,但是不管我尝试了什么,我都不能允许localhost只访问本地Apache (即localhost访问localhost:80 )。

这是我的剧本:

代码语言:javascript
复制
#!/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访问主机。我需要什么才能允许主机解析?

干杯伙计们。

EN

回答 1

Server Fault用户

回答已采纳

发布于 2010-06-14 05:57:42

一般性建议--在规则集的开头添加:

代码语言:javascript
复制
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和任何其他本地服务。

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/150927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档