0
votes

Trying to open port 60200 (for example) in CentOS 7. Virtual machine works via Proxmox hosted on SoYouStart/OVH dedicated. Other ports are working fine.

Running this commands:

iptables -A INPUT -i eth0 -p tcp --dport 60200 -j ACCEPT
service iptables save
service iptables restart

Checking configuration:

[root@s1 ~]# iptables -L | grep 60200
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:60200

Then running web server listening that port and trying to connect from home PC, but got error: ERR_CONNECTION_TIMED_OUT.

Trying to connect from another virtual machine in the same network:

[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.

And finally, trying to connect from localhost. Works!

[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]

How to open port for outcoming connections?

Important note: there is no firewall-cmd commands available on my server.

[root@s1 ~]# firewall-cmd --get-active-zones
FirewallD is not running
1

1 Answers

0
votes

Solved. Rule for iptables was added at end and was never executed. Correct syntax to add it first:

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