How to set gufw/ufw firewall rules?

I want to set up through gufw or through ufw directly from the terminal, the next settings from the first print screen

The second print screen is the one from gufw, if in that gufw window, I must set up these rules.

1 Like

HI @xmty welcome to the Linux community. :handshake:

To implement the firewall rules shown in your screenshot via UFW, you can follow these steps:

  1. Allow port 64297 for a specific IP address (e.g., 141.0.145.180/32):
sudo ufw allow from 141.0.145.180/32 to any port 64297 proto tcp

This command allows TCP traffic on port 64297 only from the specific IP 141.0.145.180/32.

  1. Allow TCP traffic on all ports (0-64000) from any IP address (0.0.0.0/0):
sudo ufw allow 0:64000/tcp

This allows incoming TCP traffic on all ports from 0 to 64000 from any IP address.

  1. Enable UFW (if not already enabled):
sudo ufw enable
  1. Check the current rules to ensure they’ve been added:
sudo ufw status numbered

or…

To configure this via Gufw (GUI):

  1. Open Gufw (you can find it under your applications or run gufw in the terminal).
  2. Add the first rule (allow port 64297 from IP 141.0.145.180/32):
    • Go to the “Rules” tab.
    • Click “Add” and select:
      • Preconfigured: Set to “Custom” (if needed).
      • Protocol: TCP.
      • Port: 64297.
      • Source IP: Enter 141.0.145.180/32.
  3. Add the second rule (allow all ports 0-64000 from any IP):
    • Again, click “Add”.
    • Protocol: TCP.
    • Port: Set to 0:64000.
    • Source IP: Leave as “Any” (or 0.0.0.0/0).

Once these rules are added, they will reflect the settings you showed in your screenshot.

Please let me know if you require any further assistance!

1 Like

Thak you very much @hydn

The first step, it seems that it works perfect.
The second rule, it seems that it doesn’t work. I have tried also through the terminal:

sudo ufw allow 0:64000/tc
ERROR: Bad Port.

Also, in the gufw, it is not accepted.
I appreciate.

That’s my error. Try:

sudo ufw allow 1:64000/tcp
1 Like

You are the best @hydn