How to pair android and ubuntu via KDE connect behind firewall [ufw]?

I have my ufw setup in my ubuntu. I have problem with connecting KDE connect and my ubuntu pc behind firewall. How do I do it? Disabling firewall easily pairs the two device but I am having difficulty with firewall on.


Just found a solution

https://community.kde.org/KDEConnect mentions that we need to enable rule in ufw.

so...

sudo ufw allow 1714:1764/udp
sudo ufw allow 1714:1764/tcp

And I needed to reboot my laptop for things to work. Its working now like a charm with ufw running.


To do this in a more complete and secure fashion, only opening ports to devices in your local network, open the console and enter:

ip -4 addr

Look for inet line that looks like:

inet xxx.xxx.xxx.xxx/24 brd xxx.xxx.xxx.255 scope global...

Now enter these commands for IPv4:

sudo ufw allow proto udp from xxx.xxx.xxx.0/24 to any port 1714:1764
sudo ufw allow proto tcp from xxx.xxx.xxx.0/24 to any port 1714:1764

Substitute xxx.xxx.xxx with your inet adress first 3 numbers as shown in bold.

Use the line with scope global at the end to find your correct adress, don't use the line with 127.0.0.1 adress:

For IPv6 just enter:

sudo ufw allow proto udp from fe80::/64 to any port 1714:1764
sudo ufw allow proto tcp from fe80::/64 to any port 1714:1764

fe80:://64 is the local link range for IPv6 connections (your IPv6 local network adresses).

Finally type:

sudo ufw reload

This way you don't have your ports open to the wild.

You can install gufw a graphical tool to manage your firewall rules and delete previously set ones for kdeconnect. To do that just enter:

sudo apt install gufw