How to open or close a port in VPS?

I Forgot

Member
Registered
Joined
Apr 19, 2016
Messages
15
Points
0
Are there any way(s) to open or close a port in VPS?

I am using Putty program. Thanks
 

ZenHosting

Member
Registered
Joined
Apr 26, 2016
Messages
64
Points
8
Hi there,

What distro and firewall are you using?

If you're using CSF, open the csf.conf file and go to TCP_IN and you'll see the lists of ports that are open.

You can check if the port is open / closed, by entering the IP address of the server and port number, using this website: http://www.yougetsignal.com/tools/open-ports/

Hope that helps!
 

I Forgot

Member
Registered
Joined
Apr 19, 2016
Messages
15
Points
0
Hi there,

What distro and firewall are you using?

If you're using CSF, open the csf.conf file and go to TCP_IN and you'll see the lists of ports that are open.

You can check if the port is open / closed, by entering the IP address of the server and port number, using this website: http://www.yougetsignal.com/tools/open-ports/

Hope that helps!
If I don't use CSF then is there a way to do that in SSH?

All the ports should already be open. which OS are you using?
Normally I use Linux and install Centos 6 on it.

Does it have any difference to check ports on different OS?
 

ZenHosting

Member
Registered
Joined
Apr 26, 2016
Messages
64
Points
8
ZenHosting
Just use your preferred text editor eg nano csf.conf, make and save the changes and then restart the firewall service.
 

Luxin Host

Well-known member
Registered
Joined
Jun 26, 2016
Messages
543
Points
43
Normally I use Linux and install Centos 6 on it.
Does it have any difference to check ports on different OS?
For a simple example, lets look at bittorrent. Bittorrent uses the tcp protocol on port 6881, so we would need to allow all tcp packets on destination port (the port on which they arrive at our machine) 6881:


# Accept tcp packets on destination port 6881 (bittorrent)
iptables -A INPUT -p tcp --dport 6881 -j ACCEPT
Here we append (-A) a rule to the INPUT chain for packets matching the tcp protocol (-p tcp) and entering our machine on destination port 6881 (--dport 6881).

Note: In order to use matches such as destination or source ports (--dport or --sport), you must first specify the protocol (tcp, udp, icmp, all).

We can also extend the above to include a port range, for example, allowing all tcp packets on the range 6881 to 6890:


# Accept tcp packets on destination ports 6881-6890
iptables -A INPUT -p tcp --dport 6881:6890 -j ACCEPT

Source: https://wiki.centos.org/HowTos/Network/IPTables#head-cdc2ff6985016368c04d0b37a5914eef2e8d5796

Let me know if this doesnt work then we can do more checks
 

HostPace

Active member
Registered
Joined
Apr 15, 2016
Messages
65
Points
8
Are there any way(s) to open or close a port in VPS?

I am using Putty program. Thanks

Open port XXX for example:

Open flle /etc/sysconfig/iptables:

# nano /etc/sysconfig/iptables

Append rule as follows:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport XXX -j ACCEPT

Save and close the file. Restart iptables:

# /etc/init.d/iptables restart

If you want to close / remove any particular port, simply remove the line of code for example above.

Verify that port is open

Run following command:

# netstat -tulpn | less

Make sure iptables is allowing port connections:

# iptables -L -n
 
Older Threads
Replies
14
Views
7,097
Replies
1
Views
4,015
Replies
14
Views
13,206
Newer Threads
Replies
3
Views
7,454
Replies
9
Views
9,621
Replies
6
Views
2,883
fwh
Latest Threads
Replies
0
Views
105
Replies
0
Views
62
Replies
0
Views
54
Replies
1
Views
85
Recommended Threads
Replies
19
Views
5,845
Replies
4
Views
3,552
Replies
5
Views
2,367
Replies
2
Views
2,914

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top