LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-19-2013, 02:18 AM   #1
tle94
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Rep: Reputation: Disabled
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.

Regards,
 
Old 03-19-2013, 03:07 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,142

Rep: Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363Reputation: 1363
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>
 
Old 03-19-2013, 03:21 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
On the machine (ie inside) you can use
Code:
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.
 
Old 03-19-2013, 10:39 PM   #4
tle94
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
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

?
Thanks.
 
Old 03-20-2013, 12:49 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Have a read of http://www.linuxhomenetworking.com/w...Using_iptables

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Check the Open Ports in a remote Linux Server kumarancs Linux - Server 2 01-31-2013 07:22 AM
[SOLVED] checking for open ports need ports 5198, 5199 open for UDP raypsi Linux - Security 9 05-22-2012 07:51 PM
Cannot Open Mail Server Ports 25, 110, and 220. Other Ports will open. Binxter Linux - Newbie 9 11-29-2007 03:03 AM
Check Open Ports on DHCP Server moo-cow Linux - Networking 3 07-06-2006 02:50 PM
"How to check and open ports in Linux" tux4j Linux - Networking 4 09-14-2005 05:56 PM


All times are GMT -5. The time now is 11:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration