Command to check if X port is open in IPTABLES and check if open in CSF?

000

Well-Known Member
Jun 3, 2008
535
29
78
Hi.

If X command is CLOSED in IPTABLES, but OPEN in rules of CSF = port no accesible
If X command is OPEN in IPTABLES, but CLOSED in rules of CSF = port no accesible

Then... Please:

With what command I check if X port is open/closed in IPTABLES ???

With what command I check if X port is open/closed in CSF ???

Thanks
 

cPMelaniel

Technical Analyst Supervisor
Staff member
Jun 25, 2013
9
1
78
Houston,Tx
cPanel Access Level
Root Administrator
Re: Command to check if X port is open in IPTABLES and OTHER command to check if is open in CSF - Th

Hi.

If X command is CLOSED in IPTABLES, but OPEN in rules of CSF = port no accesible
If X command is OPEN in IPTABLES, but CLOSED in rules of CSF = port no accesible

Then... Please:

With what command I check if X port is open/closed in IPTABLES ???

With what command I check if X port is open/closed in CSF ???

Thanks

CSF is simply a GUI for the IPTABLES firewall on the server. If the port is open or blocked in one, it should be the same status in the other.

Try using nmap to scan the ports.


EX:

nmap -Pn $IP -p $PORT
 

000

Well-Known Member
Jun 3, 2008
535
29
78
Re: Command to check if X port is open in IPTABLES and OTHER command to check if is open in CSF - Th

If the port is open or blocked in one, it should be the same status in the other.
Thanks.

I like detect if X port is blocked BY CSF or BY IPTABLES.

By this I like a command similar to:

csf -status_of_ -portX
iptables -status_of_ -portX

to I can detect if port is BLOCKED by IPTABLES, by CSF or by BOTH
 

quizknows

Well-Known Member
Oct 20, 2009
1,008
87
78
cPanel Access Level
DataCenter Provider
Re: Command to check if X port is open in IPTABLES and OTHER command to check if is open in CSF - Th

CSF just manages IPtables. If something is blocked in CSF, CSF blocks it by making an iptables rule.

You can make your own iptables rules outside of CSF using some of it's included files/configuration, but you should know if you have done this.

If you restart CSF it creates all your iptables rules based on CSF config. There should not be differences.

You can just run this to see all the actual iptables rules, but there will be a lot if you use LFD blocking:

Code:
iptables -L -n
 

000

Well-Known Member
Jun 3, 2008
535
29
78
Re: Command to check if X port is open in IPTABLES and OTHER command to check if is open in CSF - Th

Code:
iptables -L -n
Thanks.

This show just ALL RULES...

I need samplely know if X port is open, and this show all rules...
 

24x7server

Well-Known Member
Apr 17, 2013
1,912
99
78
India
cPanel Access Level
Root Administrator
Twitter
Re: Command to check if X port is open in IPTABLES and OTHER command to check if is open in CSF - Th

Hello,

Check the port status in iptables with the following command

Code:
iptables -L -n | grep :PORT
 

000

Well-Known Member
Jun 3, 2008
535
29
78
Code:
iptables -L -n | grep :PORT
Thanks master
Code:
[[email protected] docker-jitsi-meet]# iptables -L -n | grep :443
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW tcp dpt:443
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW tcp dpt:443
ACCEPT     tcp  --  0.0.0.0/0            172.18.0.2           tcp dpt:443
[[email protected] docker-jitsi-meet]# iptables -L -n | grep :10000
ACCEPT     udp  --  0.0.0.0/0            172.18.0.5           udp dpt:10000
[[email protected] docker-jitsi-meet]# iptables -L -n | grep :21
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW tcp dpt:21
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW udp dpt:21
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW tcp dpt:21
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            ctstate NEW udp dpt:21
[[email protected] docker-jitsi-meet]#