如何在CentOS 7中打开端口?(Proxmox,OVH)

如何在CentOS 7中打开端口?(Proxmox,OVH),centos,ip,port,firewall,ovh,Centos,Ip,Port,Firewall,Ovh,正在尝试在CentOS 7中打开端口60200(例如)。虚拟机通过托管在SoyoStart/OVH专用服务器上的Proxmox工作。其他港口运作良好 运行以下命令: iptables -A INPUT -i eth0 -p tcp --dport 60200 -j ACCEPT service iptables save service iptables restart 正在检查配置: [root@s1 ~]# iptables -L | grep 60200 ACCEPT tcp

正在尝试在CentOS 7中打开端口60200(例如)。虚拟机通过托管在SoyoStart/OVH专用服务器上的Proxmox工作。其他港口运作良好

运行以下命令:

iptables -A INPUT -i eth0 -p tcp --dport 60200 -j ACCEPT
service iptables save
service iptables restart
正在检查配置:

[root@s1 ~]# iptables -L | grep 60200
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:60200
然后运行web服务器侦听该端口并尝试从家用电脑连接,但出现错误:ERR\u CONNECTION\u TIMED\u OUT

正在尝试从同一网络中的其他虚拟机连接:

[root@s2 ~]# wget https://my_ip:60200/
--2020-01-07 20:18:21--  https://my_ip:60200/
Connecting to my_ip:60200... failed: No route to host.
最后,尝试从本地主机连接有效

[root@s1 ~]# wget https://my_ip:60200 --no-check-certificate
--2020-01-08 03:19:53--  https://my_ip:60200/
Connecting to my_ip:60200... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.1’

    [ <=>                                   ] 5,768       --.-K/s   in 0.003s

2020-01-08 03:19:54 (1.86 MB/s) - ‘index.html.1’ saved [5768]

已解决。iptables的规则在末尾添加,从未执行。 要先添加它,请更正语法:

iptables -I INPUT 1 -i eth0 -p tcp --dport 60200 -j ACCEPT
iptables -I INPUT 1 -i eth0 -p tcp --dport 60200 -j ACCEPT