Home  >  Article  >  System Tutorial  >  How to close firewall port in linux

How to close firewall port in linux

下次还敢
下次还敢Original
2024-04-11 16:54:15977browse

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 firewall port in linux

How to close Linux firewall ports

Close specific 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>

Close the port range

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>

Reload the firewall

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn