Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring firewall for discovery #215

Closed
aleasto opened this issue Sep 24, 2024 · 10 comments · Fixed by #216
Closed

Configuring firewall for discovery #215

aleasto opened this issue Sep 24, 2024 · 10 comments · Fixed by #216

Comments

@aleasto
Copy link
Contributor

aleasto commented Sep 24, 2024

In Ubuntu 24.10, with UFW enabled and the /etc/ufw/applications.d/wsdd profile allowed, the discovery feature is not working.

Wireshark shows me that this host sends an outgoing multicast with a random source port, so that replies from other hosts will be blocked on an incoming random port.

Screenshot From 2024-09-24 16-11-54

[UFW BLOCK] IN=wlp1s0 OUT= MAC=<> SRC=192.168.1.17 DST=192.168.1.84 LEN=1255 TOS=0x00 PREC=0x00 TTL=128 ID=19980 PROTO=UDP SPT=3702 DPT=57315 LEN=1235

I don't know if firewalls can possibly track UDP multicast sessions.
Alternatively, is it possible to make wsdd use a fixed port as source for the multicast, that can be simply allowed for incoming packets?

@aleasto
Copy link
Contributor Author

aleasto commented Sep 24, 2024

Looks like this should be possible in both iptables and nftables, but probably not as an UFW application profile?

@christgau
Copy link
Owner

but probably not as an UFW application profile?

That's a question to the UFW community. AFAIK, that's not possible with UFW, but my knowledge is quite limited.

Alternatively, is it possible to make wsdd use a fixed port as source for the multicast

I have to check. AFAIK, there is no requirement that it should be a random port or it is forbidden to use a fixed port from the WSD protocol perspective. I don't right now if ipv4 multicast on multiple interfaces with the same port and address is possible. Nevertheless, using fixed port will limit functionality in the sense that you cannot run multiple instances of the discovery anymore.

@aleasto
Copy link
Contributor Author

aleasto commented Sep 25, 2024

Nevertheless, using fixed port will limit functionality in the sense that you cannot run multiple instances of the discovery anymore.

Yea, that's right... If the port could be specified as a command-line option then we could have GVfs use its own white-listed fixed port, to at least solve one use-case on the Desktop.

@ondrejholy do you not have this issue in Fedora/firewalld?

@ondrejholy
Copy link
Contributor

Discovery works fine for me on Fedora 40 with firewalld enabled using the /etc/firewalld/services/*.xml files.

@aleasto
Copy link
Contributor Author

aleasto commented Sep 25, 2024

The default firewalld zone for Workstation is "FedoraWorkstation" which allows 1205-65535 on both udp and tcp, so you might just be relying on that. Either that, or firewalld has somehow configured nft to be really smart about multicast replies.

@ondrejholy
Copy link
Contributor

Hmm, yes, the default zone is likely the reason it works, but I haven't looked into that closely.

@aleasto
Copy link
Contributor Author

aleasto commented Sep 26, 2024

I went to check what Windows does and indeed Windows Firewall is configured by default to allow unicast replies to multicast/broadcasts:

Windows Settings -> Security Settings -> Windows Firewall with Advanced Security -> Windows Firewall with Advanced Security -> Properties -> Private Profile Tab -> Settings -> "Allow unicast response"

@christgau
Copy link
Owner

Since the PR has been merged (thanks for contributing, @aleasto), what about agreeing on a number for a fixed source port? According to the IANA list, both 3701 and 3703 (right before/after the assigned 3702) are reserved already. Although I'm not sure, wsdd and those services will ever run on the same machine, it might be safe to use 37020, which is unassigned, in firewall profiles and downstream usages of wsdd.

@aleasto
Copy link
Contributor Author

aleasto commented Oct 5, 2024

My idea was that gvfs would choose some fixed port, like 37020 as you suggest, then other processes which might want to start wsdd can pick other port numbers.

An alternative could be that wsdd gains a dbus-like interface to multiplex one discovery daemon to multiple clients, so wsdd would be the "owner" of port 37020 rather than gvfs.

@aleasto
Copy link
Contributor Author

aleasto commented Oct 9, 2024

@christgau I implemented the second idea! #218

No need for fancy dbus things as the socket interface fits the purpose just as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants