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 - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-01-2020, 08:47 PM   #1
hacback17
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Rep: Reputation: Disabled
Question firewall-cmd doesn't show open ports on CentOS7


Hi pals

When running
Code:
sudo firewall-cmd --list-ports
, it doesn't show up any ports even though there are several ports open, for example SSH.

Code:
[osboxes@osboxes ~]$
[osboxes@osboxes ~]$ sudo firewall-cmd --state
running
[osboxes@osboxes ~]$ sudo firewall-cmd --list-services
cockpit dhcpv6-client ssh
[osboxes@osboxes ~]$ sudo firewall-cmd --list-ports

[osboxes@osboxes ~]$
[osboxes@osboxes ~]$ grep ssh /etc/services | head -n1
ssh             22/tcp                          # The Secure Shell (SSH) Protocol
[osboxes@osboxes ~]$
You can see the screenshot here for a better view: https://ibb.co/9ZMyGcK

So my question and confusion is that if a service, for example SSH is running, why it doesn't show the port when executing this
Code:
sudo firewall-cmd --list-ports
. Is it normal? I am new to firewalls.

Thanks in advance!
 
Old 12-01-2020, 10:02 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,799

Rep: Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953Reputation: 5953
Yes it is normal.

The list-services option does not convert ports numbers to names. It is a predefined list of services that have been installed on the system. Although the port numbers are assumed to be per the /etc/services file.

If for example you were to run ssh on another port like 2222 you would use --add-port=2222/tcp option and then that port will be shown with -list-ports.

It is possible to manually add a service to the list

If you are running the desktop there will be the gui firewall utility that shows the predefined listed and a checkbox to open it. In addition there will be an option to add a port. That is the same as the command line list-port.

Last edited by michaelk; 12-01-2020 at 10:11 PM.
 
Old 12-01-2020, 10:50 PM   #3
hacback17
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Original Poster
Rep: Reputation: Disabled
Very well explained, Michaelk!

Thanks for the help!
 
  


Reply

Tags
firewall, firewalld



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
How to handle NFS and CIFS mount points when using firewall-cmd to set up firewall? pclinux66 Linux - Security 2 06-20-2020 11:26 AM
Any problem if I install CENTOS7 Workstation over CENTOS7 Server? Rich Strebendt Linux - Software 5 05-03-2018 11:05 PM
Issue sg_modes cmd at cmd line, want to see the cmd in binary form NuUser Linux - Newbie 1 03-28-2012 08:08 AM
ports, ports, ports cjae Linux - Networking 1 04-09-2006 09:38 AM
CSH: "cmd >& file" or "cmd </dev/null >& file" stefanlasiewski Programming 1 09-08-2003 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:20 PM.

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