From 0c9413435af502b4bf82f6140871ddc4bf66c6a2 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Tue, 26 Mar 2024 16:50:48 -0700 Subject: [PATCH] Also mention allow_local setting --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index b17e831..a70353c 100644 --- a/README.rst +++ b/README.rst @@ -140,8 +140,10 @@ Q: My multicasts aren't being received in Linux, even though I see them coming i A: On Linux, you must also be careful of a kernel feature called Reverse Path Filtering (RPF). You see, in most cases, multicast doesn't care about unicast IPs or subnets -- you can quite easily have a machine with IP 10.0.0.1 send multicasts to 192.168.1.2, even though those are on different subnets so they can't normally communicate. However, RPF throws a wrench in this. In its default "loose" mode (setting 2), it blocks reception of IP packets if they come from an IP address not reachable by any interface. So, for example, if you receive a multicast from 10.0.0.1 but you only have routes in your routing table for 192.168.x.x IP addresses, the kernel will summarily drop the packet. The easiest fix is to label one of your network interfaces as a default route. This makes all IP addresses reachable from an interface, so all packets will be able to get by the check. RPF's "strict" mode (setting 1) is even worse. It applies the same check, but on a per-interface level. So, in order to receive packets from multicast address X, each individual interface must have a routing rule permitting it to send packets to X. If this is too much of a pain to set up, you can turn RPF off using sysctl (`this seems like a decent guide `_). Just remember to change it both for the "all" interface and for whichever interfaces you want to affect -- the kernel takes the stricter of the two values. + + Another common issue is, if you have two NICs connected to each other on the same machine and want to send packets between them, you will need to change the [ipv4.accept_local](https://sysctl-explorer.net/net/ipv4/accept_local/) setting, e.g. ``sudo sh -c "echo 1 > /proc/sys/net/ipv4/conf/all/accept_local"`` (note that additional work is needed to make this persist across reboots) - If RPF isn't the problem, you may also want to check any firewalls (firewalld/iptables) and see if those are blocking multicast packets. + Last but not least, you may also want to check any firewalls (firewalld/ufw/iptables) and see if those are blocking multicast packets. Q: If I have a socket that receives from multiple mcast addresses, say A and B, and I receive a packet, how do I tell whether the packet was sent to multicast address A or B? A: You can't, or at least I haven't found a way to do this from Python. You'll need to create multiple sockets if you need this information.