• 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

CentOS / RHEL 7 firewalld : Command line reference (Cheat Sheet)

by admin

Firewalld is the new way of interacting with the iptables rules in RHEL 7. It allows to set new sucurity rules and activate them in runtime without disconnecting any existing connections.

Managing firewalld

# firewall-cmd --state                 -- Display whether service is running
# systemctl status firewalld           -- Another command to display status of service
# systemctl restart firewall-cmd       -- To restart service
# firewall-cmd --reload                -- To reload the permanent rules without interrupting existing persistent connections

To start/stop/status firewalld service

# systemctl start firewalld.service
# systemctl stop firewalld.service
# systemctl status firewalld.service

To enable/disable firewalld service at boot time

To enable firewalld service from starting at boot time.

# systemctl enable firewalld

To disable firewalld service from starting at boot time.

# systemctl disable firewalld

To list details of default and active zones

# firewall-cmd --get-default-zone
# firewall-cmd --get-active-zones
# firewall-cmd --list-all

To add/remove interfaces to zones

To add interface “eth1” to “public” zone.

# firewall-cmd --zone=public --change-interface=eth1

To list/add/remove services to zones

To list available services :

# firewall-cmd --get-services

To add “samba and samba-client” service to a specific zone. You may include, “permanent” flag to make this permanent change.

# firewall-cmd --zone=public --add-service=samba --add-service=samba-client --permanent

To list services configured in a specific zone.

# firewall-cmd --zone=public --list-service

To list and Add ports to firewall

# firewall-cmd --list-ports
# firewall-cmd --zone=public --add-port=5000/tcp

Note:
You may restart the Network service followed by Firewall server.

# systemctl restart network.service
# systemctl restart firewalld.service

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  2. CentOS / RHEL 7 : How to disable IPv6 on a specific interface only
  3. How to clear the buffer/pagecache (disk cache) under Linux
  4. CentOS / RHEL : anacron basics (What is anacron and how to configure it)
  5. Why Does “netstat” Output Show Many Connections in CLOSE_WAIT Status?
  6. How to restrict ssh logins by user and client address on CentOS/RHEL
  7. Unable To Extend LVM File System with Associated Snapshot in CentOS/RHEL
  8. mdadm: Cannot open /dev/sda1: Device or resource busy
  9. How to Configure a Fiber-Channel Over Ethernet (FCoE) Interface in CentOS/RHEL
  10. How to Provide Credentials From a File While Mounting CIFS Share in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “aws s3 mv” Command Examples
  • “aws s3 mb” Command Examples
  • “aws s3 ls” Command Examples
  • “aws s3 cp” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright