Linux 如何在iptables CentOS 6中打开2195端口来激活APNS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13606582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open port 2195 in iptables CentOS 6 for activating the APNS
提问by ElizaS
I tried this solution:
我试过这个解决方案:
iptables -I OUTPUT -p tcp --dport 2195 -j ACCEPT
/etc/init.d/iptables stop
/etc/init.d/iptables start
but still can't access the port.
但仍然无法访问端口。
If there are more ports that I have to open for APNS let me know.
如果我必须为 APNS 打开更多端口,请告诉我。
采纳答案by Aaron M.
回答by Metal3d
See my anwser here: https://stackoverflow.com/a/25229943/1472048
在此处查看我的答案:https://stackoverflow.com/a/25229943/1472048
For CentOS 7, you should use "firewall-cmd" command like so:
对于 CentOS 7,你应该像这样使用“firewall-cmd”命令:
firewall-cmd --add-port=2195/tcp --permanent
iptables is not recommended if you use the firewalld service.
如果您使用 firewalld 服务,则不建议使用 iptables。
回答by FentomX1
It didn't work for me completely, since my last rule was DROP ALL which basically negated all I added to iptables after.
它完全不适合我,因为我的最后一条规则是 DROP ALL 这基本上否定了我之后添加到 iptables 的所有内容。
It might be useful to use the -I switch:
使用 -I 开关可能很有用:
iptables -I INPUT 1 -p tcp --dport 2195 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 2195 -j ACCEPT
The INPUT 1
- means 1st Input rule instead of appending, to put rule in front of drop all
本INPUT 1
-手段第一个输入的规则,而不是追加,把规则在下降之前的所有
回答by Anjali Bakshi
Try the following command, it worked for me:
尝试以下命令,它对我有用:
$ sudo iptables -A INPUT -p tcp --jport 2195 -j ACCEPT
$ sudo /etc/init.d/iptables save
$ sudo iptables -A INPUT -p tcp --jport 2195 -j ACCEPT
$ sudo /etc/init.d/iptables 保存