LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 01: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, 02:07 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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, 02:21 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 09: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-19-2013, 11:49 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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 06:22 AM
[SOLVED] checking for open ports need ports 5198, 5199 open for UDP raypsi Linux - Security 9 05-22-2012 06:51 PM
Cannot Open Mail Server Ports 25, 110, and 220. Other Ports will open. Binxter Linux - Newbie 9 11-29-2007 02:03 AM
Check Open Ports on DHCP Server moo-cow Linux - Networking 3 07-06-2006 01:50 PM
"How to check and open ports in Linux" tux4j Linux - Networking 4 09-14-2005 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:29 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
Open Source Consulting | Domain Registration