
CentOS 7.0 linux iptables 修改后出错配置出错,求教。。。。。。。。。。。。。 255
#sampleconfigurationforiptablesservice#youcaneditthismanuallyorusesystem-config-firew...
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8000
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
请问这段代码哪里出错,目的想iptables配置一条转发记录,转发给Nginx 的8000端口。以下为出错信息
Invalid argument. Run `dmesg' for more information.
Applying firewall rules: iptables-restore: line 14 failed
Nov 02 17:53:35 localhost.localdomain iptables.init[3585]: [FAILED]
main process exited, code=exited, status=1/FAILURE
Failed to start IPv4 firewall with iptables.
Unit iptables.service entered failed state.
iptables.service failed.
--dport 80 改为 53端口 也一样结果
tcp 改为 udp 也一样
求教。。。。。。。。。。。。。。。。。。。。。。 展开
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8000
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
请问这段代码哪里出错,目的想iptables配置一条转发记录,转发给Nginx 的8000端口。以下为出错信息
Invalid argument. Run `dmesg' for more information.
Applying firewall rules: iptables-restore: line 14 failed
Nov 02 17:53:35 localhost.localdomain iptables.init[3585]: [FAILED]
main process exited, code=exited, status=1/FAILURE
Failed to start IPv4 firewall with iptables.
Unit iptables.service entered failed state.
iptables.service failed.
--dport 80 改为 53端口 也一样结果
tcp 改为 udp 也一样
求教。。。。。。。。。。。。。。。。。。。。。。 展开
1个回答
展开全部
127.0.0.1 是 loop 环回地地址,不是对外的ip地址,所以你得改为局域网ip。
追问
我只针对内网用户,就是想通过过滤网站一些代码(比如广告代码)然后返回给内网用户,在Nginx 有设置一个8.8.8.8 dns. 用内网IP也试过,一样结果,
现在问题是service iptables restart 运行会出错,重启几次也还是一样结果
追答
-j DNAT --to IP[-IP][:端口-端口](nat 表的 PREROUTING 链)
目的地址转换,DNAT 支持转换为单 IP,也支持转换到 IP 地址池(一组连续的 IP 地址)
例如:
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 80 \
-j DNAT --to 192.168.0.1
把从 ppp0 进来的要访问 TCP/80 的数据包目的地址改为 192.168.0.1
你写的那句:iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8000
加粗的地方有问题。-m的语法是:
-m state --state 状态
状态:NEW、RELATED、ESTABLISHED、INVALID
NEW:有别于 tcp 的 syn
ESTABLISHED:连接态
RELATED:衍生态,与 conntrack 关联(FTP)
INVALID:不能被识别属于哪个连接或没有任何状态
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询