KDE Connect open up firewall ports

Hello, anyone know how I can get KDE Connect to work while the firewall is on?
ChatGPT gave me this answer, but it hasn’t helped:

iptables
    sudo iptables -A INPUT -p udp --dport 1714:1764 -j ACCEPT
    sudo iptables -A INPUT -p tcp --dport 1714:1764 -j ACCEPT
    sudo iptables-save | sudo tee /etc/iptables/rules.v4

To make your iptables rules permanent on a Linux distribution like CachyOS, you can save them to a file and configure the system to load the rules at startup. Here’s what you can do: Create the file to save the rules: It looks like you’ve already created the rules file with iptables-save, but to be sure, run the command:

Bash sudo iptables-save | sudo tee /etc/iptables/rules.v4

Load the rules automatically at startup: CachyOS uses systemd, so you can create a service to load the rules automatically. Create a systemd service to load the rules at startup: Create a new service file with the following command:

Bash sudo nano /etc/systemd/system/iptables.service

Add the following contents to the file:

ini

[Unit]
Description=Load iptables rules
Wants=network-pre.target
Before=network-pre.target
Requires=network.target

[Service]
Type=oneshot
ExecStart=/sbin/iptables-restore /etc/iptables/rules.v4
ExecReload=/sbin/iptables-restore /etc/iptables/rules.v4
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

To load and activate the service: Run the following commands to load and activate the service at startup:

Bash sudo systemctl daemon-reload
sudo systemctl enable iptables.service
sudo systemctl start iptables.service

Now your iptables rules should load automatically every time the system is rebooted.

Forgot to mention, when I turn off the firewall KDE Connect works.

I do not use iptables.
Here is my solution depends on your preferences (UFW or FIREWALLD).

Firewall Configuration Guide

UFW (Uncomplicated Firewall)

If UFW is active, it’s necessary to allow the required ports:

sudo ufw allow 1716:1764/udp

FIREWALLD

Allowing Ports for TCP

To allow TCP ports:

sudo firewall-cmd --zone=public --add-port=1714-1764/tcp --permanent

Allowing Ports for UDP

To allow UDP ports:

sudo firewall-cmd --zone=public --add-port=1714-1764/udp --permanent

Reload Firewalld

To apply the changes, reload the firewalld:

sudo firewall-cmd --reload

Thx vawaver, I don’t have any preferences since I’m a beginner at this.

According to your suggestions, UFW seems the easiest and quickest since it is just one command. How do I know if UFW is active? I assume there is a command to see that? Should I activate it if it is not? As you understand by now, I know nothing about this. :slight_smile:

Basic UFW Commands

  • Enable UFW: Enables the UFW firewall to start protecting the system.

    sudo ufw enable
    
  • Start UFW: Starts the UFW service if it’s not already running. The difference between start and enable is that enable makes UFW start automatically on system boot, while start only initiates the service for the current session.

    sudo systemctl start ufw
    
  • Disable UFW: Disables UFW, stopping it from filtering network traffic.

    sudo ufw disable
    
  • Stop UFW: Stops the UFW service. The difference between stop and disable is that disable completely turns off UFW and its rules, while stop only halts the service temporarily until it is started again.

    sudo systemctl stop ufw
    
  • Check UFW Status: Displays the current status of UFW, including any active rules.

    sudo ufw status
    

Omg, thanks @vawaver this was such good and high quality answer which also solved my issue.

Solution:
I checked ufw status and it was active.

Then

UFW (Uncomplicated Firewall)

If UFW is active, it’s necessary to allow the required ports:

sudo ufw allow 1716:1764/udp

Done! It works! Thank you so much, I’m truly grateful! :pray:

1 Like

Cachy has UFW installed by default, so use the ufw commands

1 Like