• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

firewall-cmd: command not found

by admin

The purpose of Firewalld is to replace the need for iptables and improve security management by enabling configuration changes without stopping the current connections. Firewalld runs as a daemon that allows for rules to be added and changed instantly and it uses network zones to define a level of trust for any and all associated network connections. For the troubleshooter, this does provide a range of flexible options but, more importantly, it is necessary to understand that, while a connection can only be a part of a single zone, a zone can be used across many network connections.

The command-line tool firewall-cmd is part of the firewalld application, which is installed by default on most distributions. It can be used to make permanent and non-permanent runtime changes.

If you encounter the below error while running the firewall-cmd command:

firewall-cmd: command not found

you may try installing the firewalld package as per your choice of distribution:

Distribution Command
Debian apt-get install firewalld
Ubuntu apt-get install firewalld
Arch Linux pacman -S firewalld
Kali Linux apt-get install firewalld
CentOS yum install firewalld
Fedora dnf install firewalld
Raspbian apt-get install firewalld

firewall-cmd Command Examples

1. Discover what the default zone is:

# firewall-cmd --get-default-zone

2. The value of this can be updated with the following syntax:

# firewall-cmd --set-default-zone=[new-zone-name]

3. Taking this one step further, we can extend this command to provide not only a list of zones, but also network interface information like this:

# firewall-cmd --get-active-zones

4. In this situation, network interfaces can be managed with the following syntax:

# firewall-cmd --zone=[zone-name] --add-interface=[device-name]
# firewall-cmd --zone=[zone-name] --change-interface=[device-name]
# firewall-cmd --zone=[zone-name] --remove-interface=[device-name]

5. List all the allowed services using the following command:

# firewall-cmd –list-services

6. Show the tcp/udp ports that are allowed by your firewall using the following command:

# firewall-cmd --list-ports

7. Perform the following steps to allow NFSv4 traffic on your system:

First, allow nfs traffic via this command:

# firewall-cmd --add-service nfs –-permanent
success

Then, reload the configuration as follows:

# firewall-cmd --reload
success

Now, check the newly applied rule by executing the following command line:

# firewall-cmd –-list-services
nfs

8. Perform the following steps to allow incoming traffic on port 1234 over both tcp and udp:

First, allow traffic on port 1234 over tcp and udp by running the following:

# firewall-cmd --add-port 1234/tcp --permanent
success
# firewall-cmd --add-port 1234/udp --permanent
success

Reload the configuration by executing the following command:

# firewall-cmd –-reload
success

Check the newly applied rule via the following:

# firewall-cmd –-list-ports
1234/tcp 1234/udp

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : How to enable telnet for a group of users
  2. How to setup passwordless SSH login in Linux
  3. vncserver fails with “Starting VNC server: no displays configured”
  4. Secure Shell: Chrome Web Browser ssh client
  5. rsyslogd Command Examples in Linux
  6. How to Create/Format/Extend Virtual Data Optimizer(VDO) Volumes using Cockpit Web Console in CentOS/RHEL 8
  7. lastcomm: command not found
  8. What are /dev/zero and /dev/null files in Linux
  9. csplit: command not found
  10. How to Configure Proxy in CentOS/RHEL/Fedora

You May Also Like

Primary Sidebar

Recent Posts

  • qsub Command Examples in Linux
  • qsub: command not found
  • qrcp Command Examples in Linux
  • qmrestore Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright