{"id":6678,"date":"2017-05-08T12:35:59","date_gmt":"2017-05-08T04:35:59","guid":{"rendered":"http:\/\/rmohan.com\/?p=6678"},"modified":"2017-05-08T12:35:59","modified_gmt":"2017-05-08T04:35:59","slug":"centos-rhel-7-how-to-open-a-port-in-the-firewall-with-firewall-cmd","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6678","title":{"rendered":"CentOS \/ RHEL 7 : How to open a port in the firewall with firewall-cmd?"},"content":{"rendered":"<p>Question: How to open a port in RHEL 7 using the firewall-cmd command?<\/p>\n<p>Solution:<\/p>\n<p>To begin with check the firewalld status using the systemctl command :<\/p>\n<p># systemctl status firewalld<br \/>\n? firewalld.service &#8211; firewalld &#8211; dynamic firewall daemon<br \/>\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/firewalld.service; enabled; vendor preset: enabled)<br \/>\n   Active: active (running) since Sat 2016-10-29 21:47:04 IST; 1 weeks 4 days ago<br \/>\n Main PID: 1055 (firewalld)<br \/>\n   CGroup: \/system.slice\/firewalld.service<br \/>\n           ??1055 \/usr\/bin\/python -Es \/usr\/sbin\/firewalld &#8211;nofork &#8211;nopid<\/p>\n<p>Oct 29 21:46:50 localhost.localdomain systemd[1]: Starting firewalld &#8211; dynamic firewall daemon&#8230;<br \/>\nOct 29 21:47:04 localhost.localdomain systemd[1]: Started firewalld &#8211; dynamic firewall daemon.<br \/>\nExecute these commands to add a port to the firewall:<br \/>\nThe command below will open the port effective immediately, but will not persist across reboots:<\/p>\n<p># firewall-cmd &#8211;add-port=[YOUR PORT]\/tcp<br \/>\nFor example, to open TCP port 2222 :<\/p>\n<p># firewall-cmd &#8211;add-port=2222\/tcp<br \/>\nThe following command will create a persistent rule, but will not be put into effect immediately:<\/p>\n<p># firewall-cmd &#8211;permanent &#8211;add-port=[YOUR PORT]\/tcp<br \/>\nFor Example, to open TCP port 2222 :<\/p>\n<p># firewall-cmd &#8211;permanent &#8211;add-port=2222\/tcp<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: How to open a port in RHEL 7 using the firewall-cmd command?<\/p>\n<p>Solution:<\/p>\n<p>To begin with check the firewalld status using the systemctl command :<\/p>\n<p># systemctl status firewalld ? firewalld.service &#8211; firewalld &#8211; 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 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6678"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6678"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6678\/revisions"}],"predecessor-version":[{"id":6679,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6678\/revisions\/6679"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}