Scenario / Questions

I have just installed CentOS 7:

[root@new ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core) 

I am trying to configure the firewall, and I’m told that in CentOS 7 iptables is no longer used, replaced by firewalld. When attempting to run a command to set a firewall rule as such:

firewall-cmd --add-port=80/tcp

I receive the following message:

[root@new ~]# firewall-cmd --add-port=80/tcp
-bash: firewall-cmd: command not found

edit: I tried the following command, too:

[root@new ~]# firewall-offline-cmd --add-port=80/tcp
-bash: firewall-offline-cmd: command not found

without any success.

I tried running the following to check that firewalld was installed:

[root@new ~]# service firewalld status
Redirecting to /bin/systemctl status  firewalld.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

Following this output, I tried starting firewalld:

[root@new ~]# service firewalld start
Redirecting to /bin/systemctl start  firewalld.service
Failed to issue method call: Unit firewalld.service failed to load: No such file or directory.

Any ideas what is wrong with the CentOS 7 install? This is a clean install on an OpenVZ VPS, I’m yet to make any changes at all.

Find below all possible solutions or suggestions for the above questions..

Suggestion: 1

Two possible options

  • Your PATH does not contain /usr/bin
  • firewall-cmd is not installed
    • yum install firewalld

Suggestion: 2

Looks to me like you don’t have it installed/enabled.

yum install firewalld
systemctl unmask firewalld
systemctl enable firewalld
systemctl start firewalld

Suggestion: 3

Try the GUI tool instead, this util ships default with centos 6/7. firewalld is deprecated after centos5

$ sudo system-config-firewall


# system-config-firewall 

The system-config-firewall looks like this image