Home > Article > System Tutorial > How to close firewall port in linux
Linux firewall ports can be closed by closing specific or range ports with the ufw command: Close specific ports: sudo ufw delete allow port/protocol Close port range: sudo ufw delete allow port_range:start_port:end_port/protocol Reload the firewall :sudo ufw reload
How to close Linux firewall ports
Useufw
Command to close a specific port:
<code class="bash">sudo ufw delete allow port/protocol</code>
where port
is the port number to be closed, protocol
is the protocol used by the port (for example, tcp
or udp
).
For example, to close the HTTP port with port number 80, run the following command:
<code class="bash">sudo ufw delete allow 80/tcp</code>
To close the port range, use the following command:
<code class="bash">sudo ufw delete allow port_range:start_port:end_port/protocol</code>
Where start_port
is the start port of the range, end_port
is the end port of the range, protocol
is the protocol used.
For example, to close TCP ports in the port range 8080 to 8090, run the following command:
<code class="bash">sudo ufw delete allow 8080:8090/tcp</code>
After closing the port, you need to reload the firewall rules to enable Changes take effect:
<code class="bash">sudo ufw reload</code>
The above is the detailed content of How to close firewall port in linux. For more information, please follow other related articles on the PHP Chinese website!