LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-23-2010, 03:41 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
How to check if a port is allowed in iptables?


I want to check if a port is allowed in iptables. How to do this?
 
Old 08-23-2010, 04:00 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
iptables -L

as root user
 
Old 08-23-2010, 04:18 AM   #3
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by chrism01 View Post
iptables -L

as root user
I got followings:

Code:
[root@s003ap25-test ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
Assumed I will check the port 8999 is allowed in the iptables, how can I do this?
 
Old 08-23-2010, 04:28 AM   #4
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
You do not have any rules configured in Iptables. It is showing empty table. To check the opened ports in iptables, you may use the following command,

iptables -nL | grep <port number>
 
1 members found this post helpful.
Old 08-23-2010, 04:38 AM   #5
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
I type

iptables -nL | grep 8999

But I get nothing shown. What does this mean?

Then I try and iptables -nL. But still nothing shown.

Last edited by thomas2004ch; 08-23-2010 at 04:42 AM.
 
Old 08-23-2010, 04:41 AM   #6
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
As I said already, the iptables in your system doesn't have any rules configured. For this reason, you are not getting anything after executing "iptables -nL | grep 8999".

You may refer the link http://www.linuxhomenetworking.com/w...Using_iptables

to configure iptables rules in your system.
 
Old 10-10-2017, 11:24 PM   #7
RevelationNow
LQ Newbie
 
Registered: Oct 2017
Posts: 2

Rep: Reputation: Disabled
Thumbs down

Quote:
Originally Posted by blue_print View Post
As I said already, the iptables in your system doesn't have any rules configured. For this reason, you are not getting anything after executing "iptables -nL | grep 8999".

You may refer the link [Ironically this message board won't allow me to quote a link]

to configure iptables rules in your system.
So, the way Grep works, is it will filter an output to only show lines containing your search criteria.

The way that IPTables -nL works is that it will list the target, protocol, source and destination, but doesn't list the port information for any of those rules.

So, the question remains, how can we see the port information? I don't think Grep is going to help on this output since the output doesn't contain the single detail we are searching for.
 
Old 10-10-2017, 11:28 PM   #8
RevelationNow
LQ Newbie
 
Registered: Oct 2017
Posts: 2

Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by thomas2004ch View Post
I want to check if a port is allowed in iptables. How to do this?
iptables -S
 
Old 10-11-2017, 09:17 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by thomas2004ch View Post
I got followings:

Code:
[root@s003ap25-test ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
Assumed I will check the port 8999 is allowed in the iptables, how can I do this?
None of the chains have any rules, so they all fall through to their default policy of "ACCEPT". Everything is accepted.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables can't port forward (PAT Port address translation) sfrederiksen Linux - Networking 7 12-20-2011 10:47 AM
debian iptables squid - redirect port 80 to port 8080 on another machine nickleus Linux - Networking 1 08-17-2006 12:59 AM
Iptables wide open, but no UDP packets allowed (all ports closed) please help mfeoli Linux - Networking 1 01-06-2006 09:52 AM
No Shorewall/IPtables: not inbound connections allowed psychobyte Mandriva 3 05-25-2005 01:29 AM
set time limit on allowed user in iptables? luap Linux - Networking 5 03-04-2003 10:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:18 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