{"id":11488,"date":"2024-05-28T05:35:29","date_gmt":"2024-05-28T05:35:29","guid":{"rendered":"https:\/\/greenwebpage.com\/community\/?p=11488"},"modified":"2024-05-28T05:40:27","modified_gmt":"2024-05-28T05:40:27","slug":"how-to-open-and-close-ports-on-centos-9","status":"publish","type":"post","link":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/","title":{"rendered":"How to Open and Close Ports on CentOS 9"},"content":{"rendered":"<p>On CentOS 9, opening and closing ports are important for managing network access. Opening specific or required ports allows only authorized services to access your network. On the other hand, closing unwanted and unnecessary ports helps prevent cyber attacks and enhances system security.<\/p>\n<p>Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.<\/p>\n<h2><strong>How to Open and Close Ports on CentOS 9?<\/strong><\/h2>\n<p>With the following methods, you can open and\/or close ports on your CentOS 9 system:<\/p>\n<ul>\n<li>Method 1: Open and Close Ports on CentOS 9 using \u201cFirewalld\u201d<\/li>\n<li>Method 2: Open and Close Ports on CentOS 9 via \u201ciptables\u201d<\/li>\n<\/ul>\n<h3><strong>Method 1: Open and Close Ports on CentOS 9 using \u201cFirewalld\u201d<\/strong><\/h3>\n<p>The procedure of opening and closing ports via \u201cFirewalld\u201d tool will be demonstrated in this method.<\/p>\n<p><strong>Step 1: Update CentOS System Packages<\/strong><\/p>\n<p>Run the update command using DNF package manager to refresh your CentOS 9 system packages:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo dnf update<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img fetchpriority=\"high\" decoding=\"async\" width=\"887\" height=\"136\" class=\"wp-image-11489\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-1.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-1.png 887w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-1-300x46.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-1-768x118.png 768w\" sizes=\"(max-width: 887px) 100vw, 887px\" \/><\/pre>\n<p>The \u201cNothing to do\u201d message shows that all your system packages have been refreshed and updated.<\/p>\n<p><strong>Step 2: Install Firewall Managing Tool<\/strong><\/p>\n<p>Firewalld is a firewall management tool that simplifies the management of firewall rules on Linux-based systems, including CentOS 9. To install Firewalld, execute the following command:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo dnf install firewalld<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img decoding=\"async\" width=\"882\" height=\"178\" class=\"wp-image-11490\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-2.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-2.png 882w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-2-300x61.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-2-768x155.png 768w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><\/pre>\n<p>If Firewalld is installed, the above command will return the release number of the package, such as <strong>\u201cfirewalld-1.3.4\u201d<\/strong>.<\/p>\n<p><strong>Step 3: Initiate Firewall <\/strong><\/p>\n<p>Right after the installation of the Firewalld, start it using the given below command:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo systemctl start firewalld<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img decoding=\"async\" width=\"878\" height=\"48\" class=\"wp-image-11491\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-3.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-3.png 878w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-3-300x16.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-3-768x42.png 768w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/pre>\n<p>The output indicates that the Firewalld tool is activated on your CentOS 9 machine.<\/p>\n<p><strong>Step 4: Enable Firewall to Start on Boot:<\/strong><\/p>\n<p>If you want to start the Firewalld on boot, you can enable the services via the command:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo systemctl enable firewalld<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"45\" class=\"wp-image-11492\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-4.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-4.png 880w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-4-300x15.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-4-768x39.png 768w\" sizes=\"(max-width: 880px) 100vw, 880px\" \/><\/pre>\n<p>Encountering no error indicates that you have enabled the Firewalld successfully.<\/p>\n<p><strong>Step 5: Check the Status of \u201cFirewalld\u201d<\/strong><\/p>\n<p>Using the provided command will verify the current status (i.e. Stopped\/Active) of Firewalld on your CentOS 9 system:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo systemctl status firewalld<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"357\" class=\"wp-image-11493\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-5.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-5.png 888w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-5-300x121.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-5-768x309.png 768w\" sizes=\"(max-width: 888px) 100vw, 888px\" \/><\/pre>\n<p>You can also utilize the following command to check the running state of Firewalld:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --state<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"71\" class=\"wp-image-11494\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-6.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-6.png 881w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-6-300x24.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-6-768x62.png 768w\" sizes=\"(max-width: 881px) 100vw, 881px\" \/><\/pre>\n<p>If you see the \u201crunning\u201d on your terminal screen, it shows that the <strong>Firewalld<\/strong> has been successfully configured on your CentOS 9 system.<\/p>\n<h3><strong>How to Open Ports via Firewalld?<\/strong><\/h3>\n<p>The following steps can be used to open the port(s) on your CentOS 9 system.<\/p>\n<p><strong>Step 1: List Existing Open Ports<\/strong><\/p>\n<p>First, check the existing ports that are open on your system:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --list-ports<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"69\" class=\"wp-image-11495\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-7.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-7.png 875w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-7-300x24.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-7-768x61.png 768w\" sizes=\"(max-width: 875px) 100vw, 875px\" \/><\/pre>\n<p>If there are no open ports on your CentOS 9 system, it will return an empty output, as shown above.<\/p>\n<p><strong>Step 2: Open a Port<\/strong><\/p>\n<p>Let\u2019s open a port using the Firewalld tool. You can simply copy the following command to your terminal to open a port, such as TCP=8880:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --zone=public --add-port=8880\/tcp --permanent<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1013\" height=\"69\" class=\"wp-image-11496\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-8.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-8.png 1013w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-8-300x20.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-8-768x52.png 768w\" sizes=\"(max-width: 1013px) 100vw, 1013px\" \/><\/pre>\n<p>You will see the message \u201csuccess\u201d as output, indicating that TCP port 8880 is now open.<\/p>\n<p><strong>Step 3: Reload Firewall<\/strong><\/p>\n<p>To apply the changes after adding or opening the port, reload the firewall using the following command:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --reload<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1011\" height=\"70\" class=\"wp-image-11497\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-9.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-9.png 1011w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-9-300x21.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-9-768x53.png 768w\" sizes=\"(max-width: 1011px) 100vw, 1011px\" \/><\/pre>\n<p>As illustrated, the above step has reloaded the firewall configuration.<\/p>\n<p><strong>Step 4: Confirm Open Port(s)<\/strong><\/p>\n<p>Utilize the command to list the open ports and confirm that the port (e.g TCP port 8880) has been successfully opened:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --list-ports<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1015\" height=\"68\" class=\"wp-image-11498\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-10.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-10.png 1015w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-10-300x20.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-10-768x51.png 768w\" sizes=\"(max-width: 1015px) 100vw, 1015px\" \/><\/pre>\n<p>You can see that the TCP is now open on port 8880.<\/p>\n<h3><strong>How to Close Ports using Firewalld?<\/strong><\/h3>\n<p>You can close the ports that are open on your CentOS 9 through the following steps.<\/p>\n<p><strong>Step 1: Close the Existing Port<\/strong><\/p>\n<p>To close the existing port, copy the provided command to your CentOS terminal and execute it:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --zone=public --remove-port=8880\/tcp --permanent<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1019\" height=\"91\" class=\"wp-image-11499\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-11.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-11.png 1019w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-11-300x27.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-11-768x69.png 768w\" sizes=\"(max-width: 1019px) 100vw, 1019px\" \/><\/pre>\n<p>When you see the \u201csuccess\u201d message on your terminal, proceed to the next step.<\/p>\n<p><strong>Step 2: Reload Firewall<\/strong><\/p>\n<p>Run the below-mentioned command to reload the Firewall configuration from the terminal:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --reload<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"69\" class=\"wp-image-11500\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-12.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-12.png 973w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-12-300x21.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-12-768x54.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-12-960x69.png 960w\" sizes=\"(max-width: 973px) 100vw, 973px\" \/><\/pre>\n<p>Once you have reloaded the firewall, you will see a \u201csuccess\u201d message, indicating that the changes have been applied successfully.<\/p>\n<p><strong>Step 3: Verify the Port(s) after Closing <\/strong><\/p>\n<p>To confirm that the port has been successfully closed, operate the command to list the ports:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo firewall-cmd --list-ports<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"994\" height=\"70\" class=\"wp-image-11501\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-13.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-13.png 994w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-13-300x21.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-13-768x54.png 768w\" sizes=\"(max-width: 994px) 100vw, 994px\" \/><\/pre>\n<p>A blank output indicates that the previously open port <strong>(e.g. 8880\/TCP)<\/strong> has been closed on your CentOS 9 system.<\/p>\n<h3><a id=\"post-11488-_j4md7ev78ow5\"><\/a><strong>Method 2: Open and Close Ports on CentOS 9 via \u201ciptables\u201d<\/strong><\/h3>\n<p>In this method, we will demonstrate how to open and close ports on CentOS using the \u201ciptables\u201d.<\/p>\n<p><strong>Step 1: Install \u201cnamp\u201d Tool<\/strong><\/p>\n<p>Install \u201cnmap\u201d for scanning hosts and open ports on a network:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo dnf install nmap<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1018\" height=\"529\" class=\"wp-image-11502\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-14.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-14.png 1018w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-14-300x156.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-14-768x399.png 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/> <img loading=\"lazy\" decoding=\"async\" width=\"1023\" height=\"488\" class=\"wp-image-11503\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-15.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-15.png 1023w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-15-300x143.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-15-768x366.png 768w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><\/pre>\n<p>As illustrated above, you have installed \u201cnmap\u201d version 7.92 on your CentOS 9 machine.<\/p>\n<p><strong>Step 2: Inspect Hosts and Open Ports<\/strong><\/p>\n<p>Now, let\u2019s scan the hosts and open ports on your network (i.e. localhost):<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo nmap localhost<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"289\" class=\"wp-image-11504\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-16.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-16.png 996w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-16-300x87.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-16-768x223.png 768w\" sizes=\"(max-width: 996px) 100vw, 996px\" \/><\/pre>\n<p>Through this command, you can inspect the current status of ports on your network.<\/p>\n<h3><strong>How to Open Ports using \u201ciptables\u201d?<\/strong><\/h3>\n<p><strong>Step 1: Open a port (TCP port 8880)<\/strong><\/p>\n<p>For example, you can open TCP port 8880 by executing the command:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo iptables -I INPUT -p tcp --dport 8880 -j ACCEPT<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"46\" class=\"wp-image-11505\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-17.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-17.png 1009w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-17-300x14.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-17-768x35.png 768w\" sizes=\"(max-width: 1009px) 100vw, 1009px\" \/><\/pre>\n<p><strong>Step 2: Inspect Existing \u201ciptables\u201d Ports<\/strong><\/p>\n<p>After opening the ports, use the given below command to check the existing \u201ciptables\u201d rules, especially ports:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo iptables -L -v -n<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"967\" height=\"269\" class=\"wp-image-11506\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-18.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-18.png 967w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-18-300x83.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-18-768x214.png 768w\" sizes=\"(max-width: 967px) 100vw, 967px\" \/><\/pre>\n<p>If you see the port, such as \u201ctcp dpt:8880\u201d, it indicates that the previous command was executed successfully.<\/p>\n<h3><strong>How to Close Ports via \u201ciptables\u201d?<\/strong><\/h3>\n<p><strong>Step 1: Close a port (TCP port 8880)<\/strong><\/p>\n<p>If you want to close a port, such as TCP 8880, you can run the command from your CentOS terminal:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo iptables -D INPUT -p tcp --dport 8880 -j ACCEPT<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"961\" height=\"46\" class=\"wp-image-11507\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-19.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-19.png 961w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-19-300x14.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-19-768x37.png 768w\" sizes=\"(max-width: 961px) 100vw, 961px\" \/><\/pre>\n<p>In the above command the \u201c-D\u201d is used to delete the port. Thus, it will remove\/close the specific port (TCP port 8880) from your centOS 9s system.<\/p>\n<p><strong>Step 2: Confirm the Ports After Closing<\/strong><\/p>\n<p>To ensure that the port (TCP dpt:8880) has been successfully ended or closed, use the following command to list the \u201ciptables\u201d rules:<\/p>\n<table>\n<thead>\n<tr>\n<th>\n<pre>sudo iptables -L -v -n<\/pre>\n<\/th>\n<\/tr>\n<\/thead>\n<\/table>\n<pre><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"224\" class=\"wp-image-11508\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-20.png\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-20.png 973w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-20-300x69.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/word-image-11488-20-768x177.png 768w\" sizes=\"(max-width: 973px) 100vw, 973px\" \/><\/pre>\n<p>If you don&#8217;t see \u201dtcp dpt:8880\u201d in your output, it indicates that the port is no longer open on your CentOS 9 system.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>One can open and close ports on CentOS 9 using &#8220;Firewalld&#8221; and &#8220;iptables&#8221;. These two tools are simple and commonly used among Linux-based users. If the Firewalld tool is not configured on your CentOS system, you can use the command &#8220;sudo dnf install firewalld&#8221; to install it on your system.<\/p>\n\n    <div class=\"xs_social_share_widget xs_share_url after_content \t\tmain_content  wslu-style-1 wslu-share-box-shaped wslu-fill-colored wslu-none wslu-share-horizontal wslu-theme-font-no wslu-main_content\">\n\n\t\t\n        <ul>\n\t\t\t        <\/ul>\n    <\/div> \n","protected":false},"excerpt":{"rendered":"<p>On CentOS 9, opening and closing ports are important for managing network access. Opening specific or required ports allows only authorized services to access your network. On the other hand, closing unwanted and unnecessary ports helps prevent cyber attacks and enhances system security. Through this guided article, you will explore different methods of how to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":11510,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[321,322,285,320],"class_list":["post-11488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-centos-9","tag-firewalld","tag-iptables","tag-ports"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Open and Close Ports on CentOS 9 - Greenwebpage Community<\/title>\n<meta name=\"description\" content=\"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Open and Close Ports on CentOS 9 - Greenwebpage Community\" \/>\n<meta property=\"og:description\" content=\"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\" \/>\n<meta property=\"og:site_name\" content=\"Greenwebpage Community\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-28T05:35:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-28T05:40:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Karim Buzdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Karim Buzdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\"},\"author\":{\"name\":\"Karim Buzdar\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8\"},\"headline\":\"How to Open and Close Ports on CentOS 9\",\"datePublished\":\"2024-05-28T05:35:29+00:00\",\"dateModified\":\"2024-05-28T05:40:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\"},\"wordCount\":956,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg\",\"keywords\":[\"CentOS 9\",\"Firewalld\",\"IPtables\",\"Ports\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\",\"url\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\",\"name\":\"How to Open and Close Ports on CentOS 9 - Greenwebpage Community\",\"isPartOf\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg\",\"datePublished\":\"2024-05-28T05:35:29+00:00\",\"dateModified\":\"2024-05-28T05:40:27+00:00\",\"description\":\"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.\",\"breadcrumb\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage\",\"url\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg\",\"contentUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg\",\"width\":1020,\"height\":600,\"caption\":\"How to open and close ports on centos 9\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/greenwebpage.com\/community\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Open and Close Ports on CentOS 9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#website\",\"url\":\"https:\/\/greenwebpage.com\/community\/\",\"name\":\"Greenwebpage Community\",\"description\":\"Get online in three steps with our wide range of web hosting solutions. Choose from professional business to enterprise options designed to meet your needs.\",\"publisher\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/greenwebpage.com\/community\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\",\"name\":\"Greenwebpage Community\",\"url\":\"https:\/\/greenwebpage.com\/community\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png\",\"contentUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png\",\"width\":512,\"height\":512,\"caption\":\"Greenwebpage Community\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8\",\"name\":\"Karim Buzdar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g\",\"caption\":\"Karim Buzdar\"},\"sameAs\":[\"https:\/\/greenwebpage.com\"],\"url\":\"https:\/\/greenwebpage.com\/community\/author\/karim\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Open and Close Ports on CentOS 9 - Greenwebpage Community","description":"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/","og_locale":"en_US","og_type":"article","og_title":"How to Open and Close Ports on CentOS 9 - Greenwebpage Community","og_description":"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.","og_url":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/","og_site_name":"Greenwebpage Community","article_published_time":"2024-05-28T05:35:29+00:00","article_modified_time":"2024-05-28T05:40:27+00:00","og_image":[{"width":1020,"height":600,"url":"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg","type":"image\/jpeg"}],"author":"Karim Buzdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Karim Buzdar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#article","isPartOf":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/"},"author":{"name":"Karim Buzdar","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8"},"headline":"How to Open and Close Ports on CentOS 9","datePublished":"2024-05-28T05:35:29+00:00","dateModified":"2024-05-28T05:40:27+00:00","mainEntityOfPage":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/"},"wordCount":956,"commentCount":0,"publisher":{"@id":"https:\/\/greenwebpage.com\/community\/#organization"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage"},"thumbnailUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg","keywords":["CentOS 9","Firewalld","IPtables","Ports"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/","url":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/","name":"How to Open and Close Ports on CentOS 9 - Greenwebpage Community","isPartOf":{"@id":"https:\/\/greenwebpage.com\/community\/#website"},"primaryImageOfPage":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage"},"thumbnailUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg","datePublished":"2024-05-28T05:35:29+00:00","dateModified":"2024-05-28T05:40:27+00:00","description":"Through this guided article, you will explore different methods of how to open and close ports on the CentOS 9 system.","breadcrumb":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#primaryimage","url":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg","contentUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2024\/05\/How-to-open-and-close-ports-on-centos-9.jpg","width":1020,"height":600,"caption":"How to open and close ports on centos 9"},{"@type":"BreadcrumbList","@id":"https:\/\/greenwebpage.com\/community\/how-to-open-and-close-ports-on-centos-9\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/greenwebpage.com\/community\/"},{"@type":"ListItem","position":2,"name":"How to Open and Close Ports on CentOS 9"}]},{"@type":"WebSite","@id":"https:\/\/greenwebpage.com\/community\/#website","url":"https:\/\/greenwebpage.com\/community\/","name":"Greenwebpage Community","description":"Get online in three steps with our wide range of web hosting solutions. Choose from professional business to enterprise options designed to meet your needs.","publisher":{"@id":"https:\/\/greenwebpage.com\/community\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/greenwebpage.com\/community\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/greenwebpage.com\/community\/#organization","name":"Greenwebpage Community","url":"https:\/\/greenwebpage.com\/community\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/","url":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png","contentUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png","width":512,"height":512,"caption":"Greenwebpage Community"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8","name":"Karim Buzdar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g","caption":"Karim Buzdar"},"sameAs":["https:\/\/greenwebpage.com"],"url":"https:\/\/greenwebpage.com\/community\/author\/karim\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/11488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/comments?post=11488"}],"version-history":[{"count":1,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/11488\/revisions"}],"predecessor-version":[{"id":11509,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/11488\/revisions\/11509"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/media\/11510"}],"wp:attachment":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/media?parent=11488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/categories?post=11488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/tags?post=11488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}