Skip to content

Commit

Permalink
Also mention allow_local setting
Browse files Browse the repository at this point in the history
  • Loading branch information
relativityspace-jsmith committed Mar 26, 2024
1 parent 021af2e commit 0c94134
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://access.redhat.com/solutions/53031#:~:text=rp_filter%20parameter%20only%20has%20two,default%20is%201%20(loose).>`_). 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.
Expand Down

0 comments on commit 0c94134

Please sign in to comment.