Portal Home > Knowledgebase > Articles Database > how to open port so other vps can connect thru that port?
how to open port so other vps can connect thru that port?
Posted by jay c, 06-17-2013, 10:30 AM |
Hi,
I have two vps, vps1 and vps2. vps1 needs to connect to vps2 thru port 2222. So what I did in vps2 was, to run the following command:
iptables -A INPUT -p tcp -i eth0 --dport 2222 -j ACCEPT
iptables -A INPUT -p udp -i eth0 --dport 2222 -j ACCEPT
I have also tried:
iptables -A INPUT -p udp --dport 2222 -j ACCEPT
iptables -A INPUT -p tcp --dport 2222 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 2222 -j ACCEPT
iptables -A OUTPUT -p udp --dport 2222 -j ACCEPT
service iptables save
service iptables restart
but when I use vps1 to do:
telnet vps2ipaddress 2222
I got the connection refused problem.
|
Posted by Ryan-, 06-17-2013, 10:36 AM |
I presume that this doesn't happen when iptables is stopped?
|
Posted by jay c, 06-17-2013, 10:43 AM |
I still got the same connection refused error
when I run service iptables stop on vps2
then run the telnet command on vps1
|
Posted by HiveNode, 06-17-2013, 01:39 PM |
Did you edit the sshd_config and change the port?
|
Posted by jay c, 06-17-2013, 01:50 PM |
may I ask why do I have to edit sshd_config???
|
Posted by HiveNode, 06-17-2013, 02:14 PM |
By default ssh is port 22 if you don't tell the ssh service it won't run on a different port.
|
Posted by BestServerSupport, 06-17-2013, 02:22 PM |
Try adding the IP addresses of both VPS in firewall allowed list vice versa and then have a try.
iptables -A INPUT -s VPS IP address -j ACCEPT
|
Posted by sansap, 06-18-2013, 06:53 AM |
Hello,
Make sure the IP address is in allowed list of the firewall.
Also if you are trying to connect from one vps to other vps via ssh using a different port it should be updated in the sshd config file.
|
Add to Favourites Print this Article
Also Read