• 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 : How to open a port in the firewall with firewall-cmd?

by admin

Question: How to open a port in RHEL 7 using the firewall-cmd command?

Solution:

To begin with check the firewalld status using the systemctl command :

# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2016-10-29 21:47:04 IST; 1 weeks 4 days ago
 Main PID: 1055 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─1055 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Oct 29 21:46:50 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 29 21:47:04 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.

Execute these commands to add a port to the firewall:
The command below will open the port effective immediately, but will not persist across reboots:

# firewall-cmd --add-port=[YOUR PORT]/tcp

For example, to open TCP port 2222 :

# firewall-cmd --add-port=2222/tcp

The following command will create a persistent rule, but will not be put into effect immediately:

# firewall-cmd --permanent --add-port=[YOUR PORT]/tcp

For Example, to open TCP port 2222 :

# firewall-cmd --permanent --add-port=2222/tcp
CentOS / RHEL 7 : How to open the Firewall port for Samba server using FirewallD

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. How to Enable/Disable CPUs (Limiting CPU count) in CentOS / RHEL
  2. How to connect to an Active Directory Domain using Realmd (Configure CentOS/RHEL 7 as active directory client)
  3. How to Disable TLS 1.1 Cockpit port 9090
  4. The Squid Service in Failed State with Error: “Failed to make swap directory /var/spool/squid/00: (13) Permission denied”
  5. System Log File /var/log/messages Is Getting Deleted or Trimmed Automatically (CentOS/RHEL)
  6. How to install CentOS / RHEL 7 on RAID Partition
  7. /var/cache/yum Constantly Filling Files System in CentOS/RHEL
  8. How to use “btrfs scrub” command to manage scrubbing on Btrfs file systems
  9. How to send Audit Logs to Remote Rsyslog Server in CentOS/RHEL 6,7
  10. How to Create Yum Repository For System Packages Installation in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright