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
Recent Comments