Search code examples
udpipmulticast

Multicast datagrams filtered when routed back to the origin


I have two applications running on the same Linux host. Each application joins the same multicast group, but each choose to use different NIC. Note that both NICs are managed in the same subnet and static configuration.

+------+         +------+
| APP1 |         | APP2 |
+------+         +------+
  |eth0|         |eth1|
  +----+         +----+
   |                 |
   |    +--------+   |
   |--> | Router |<--|
        +--------+

eth0 - 192.168.0.10/24, eth1 - 192.168.0.11/24

The problem is that the packets that leave the host from one NIC and come back to the other seem to be filtered out somewhere, possibly the IP stack. The things is that Wireshark records received packets, but they never turn-up on the socket.

The network statistics does not show any record of RX dropped packets or any errors whatsoever.

I just want to understand why the Linux IP stack rejects/filters UDP packets from 'itself'. Is it possible to go around this problem somehow?

Also, I don't want to use the same NIC for both applications because one of the them receives a high load of UDP traffic, so enabling LOOPBACK option I would like to avoid.


Solution

  • I revisited this issue in a hope to find an answer and it seems that I did. The answer to this problem is a matter of configuration. This Kernel parameter does the trick:

    net.ipv4.conf.all.accept_local=1
    

    Accept packets with local source addresses. In combination with suitable routing, this can be used to direct packets between two local interfaces over the wire and have them accepted properly. default FALSE