6

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.

3 Answers 3

10

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.

3
  • 1
    You don't need to reboot, just sudo ufw reload does the trick May 27, 2018 at 18:24
  • In case it helps anyone else looking at this; I know the IP of my phone on my network, so I could add the following more explicit rules: sudo ufw allow in on wlp2s0 proto tcp from 192.168.0.182 to any port 1714:1764 sudo ufw allow in on wlp2s0 proto udp from 192.168.0.182 to any port 1714:1764
    – Robin
    Jan 6, 2020 at 15:54
  • Is this just needed for discovery, or for all the features?
    – unhammer
    Feb 27, 2023 at 19:31
2

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
0

If you aren't using ufw you can just use iptables itself.

sudo iptables -I INPUT -i <your-interface> -p udp --dport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -I INPUT -i <your-interface> -p tcp --dport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -o <your-interface> -p tcp --sport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -o <your-interface> -p udp --sport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .