-   Linux - General (
-   -   Open and check ports in RHEL 5.8 (

tle94 03-19-2013 01:18 AM

Open and check ports in RHEL 5.8
Hi all,

I want use shell script to open some ports. But now, I did not have administrative privilege to test this script. I used bellow command:

iptables –I INPUT –p tcp –dport 5540 –j ACCEPT

My OS is RHEL version 5.8 64 bit.

Any body can help to verify it's correct or not ? And I did not knew, I should add OUTPUT, example to open port 5540:

iptables –I INPUT –p tcp –dport 5540 –j ACCEPT
iptables –I OUTPUT –p tcp –dport 5540 –j ACCEPT

And are there commands to check this port opened ?

Thanks so much.


pan64 03-19-2013 02:07 AM

this will not open a port, it will just allow to access that port. (yes usually it is called open a port on the firewall, but not open a port on a host).
You can check if a port is available with telnet <host> <port>

chrism01 03-19-2013 02:21 AM

On the machine (ie inside) you can use

netstat -tanp

iptables -nvL

From outside, try nmap.

As above, there's a difference between allowing a port to be used on the firewall and having a listening service on that port.

tle94 03-19-2013 09:39 PM

And so, to allow to access port 5540, I use both of bellow commands:

iptables –I INPUT –p tcp –dport 5540 –j ACCEPT
iptables –I OUTPUT –p tcp –dport 5540 –j ACCEPT


chrism01 03-19-2013 11:49 PM

Have a read of

You do need to be able to test your rules...

Most (end point) hosts only restrict INPUT table; OUTPUT is usually left open to all.

You still need a service listening on that port; otherwise its pointless even thinking about it.

All times are GMT -5. The time now is 09:54 PM.