troglobit / pimd

PIM-SM/SSM multicast routing for UNIX and Linux
http://troglobit.com/projects/pimd/
BSD 3-Clause "New" or "Revised" License
198 stars 90 forks source link

Multicast to Docker-Container #241

Open jeffrson opened 1 year ago

jeffrson commented 1 year ago

I read https://github.com/troglobit/pimd/issues/121 and my situation is similar, except that I tried the solution (forward accept) and it still doesn't work :-(

I have a docker container running: docker run --rm -it -p 2222:2222/udp -v $(pwd):/usr/src/app -w /usr/src/app node:alpine sh In this container I have a node.js script that receives multicast on the host just fine.

I installed pimd 2.3.2 and ran it by sudo /usr/sbin/pimd -d -f -c /etc/pimd.conf 2>&1 | grep 230.185, in order to grep for the multicast address I'm interested in. The log starts with these lines as soon as I run my script:

09:16:09.357 accept_group_report(): igmp_src 172.17.0.2 ssm_src 0.0.0.0 group 230.185.192.108 report_type 34
09:16:09.357 Set delete timer for group: 230.185.192.108
09:16:09.358 SM group order from  172.17.0.2 (*,230.185.192.108)
09:16:09.358 create group entry, group 230.185.192.108
09:16:09.358 Adding vif 1 for group 230.185.192.108
09:16:10.241 accept_group_report(): igmp_src 172.17.0.2 ssm_src 0.0.0.0 group 230.185.192.108 report_type 34
09:16:10.241 Set delete timer for group: 230.185.192.108
09:16:10.241 Adding vif 1 for group 230.185.192.108
INADDR_ANY       230.185.192.108  192.168.100.21   WC RP
INADDR_ANY       230.185.192.108  192.168.100.21   WC RP
INADDR_ANY       230.185.192.108  192.168.100.21   WC RP
09:16:24.289 accept_group_report(): igmp_src 172.17.0.2 ssm_src 0.0.0.0 group 230.185.192.108 report_type 34
09:16:24.290 Set delete timer for group: 230.185.192.108
09:16:24.290 Adding vif 1 for group 230.185.192.108
INADDR_ANY       230.185.192.108  192.168.100.21   WC RP

tcpdump on the host shows incoming UDP packets, however inside the container it doesn't: tcpdump -i eth0 -s0 -vv host 230.185.192.108

sudo pimd -r shows this:

Virtual Interface Table ======================================================
Vif  Local Address    Subnet              Thresh  Flags      Neighbors
---  ---------------  ------------------  ------  ---------  -----------------
  0  192.168.100.21   192.168.100/22           1  DR NO-NBR
  1  172.17.0.1       172.17                   1  DR NO-NBR
  2  192.168.100.21   register_vif0            1

 Vif  SSM Group        Sources

Multicast Routing Table ======================================================
...
----------------------------------- (*,G) ------------------------------------
Source           Group            RP Address       Flags
---------------  ---------------  ---------------  ---------------------------
INADDR_ANY       230.185.192.108  192.168.100.21   WC RP
Joined   oifs: ...
Pruned   oifs: ...
Leaves   oifs: .l.
Asserted oifs: ...
Outgoing oifs: .o.
Incoming     : ..I

TIMERS:  Entry    JP    RS  Assert VIFS:  0  1  2
             0    50     0       0        0  0  0
----------------------------------- (S,G) ------------------------------------
...

Network interfaces have "MULTICAST" - static routes with smcroute work. Did I miss something to set up for pimd?

jeffrson commented 1 year ago

Oh - it starts working as soon as the sender joins the multicast group as well. I always assumed this is only necessary for listeners, while the sender just uses the group as destination address. Hmm.

Furthermore, I really need sudo iptables --policy FORWARD ACCEPT. Is this a recommended solution? It's apparently not necessary for smcroute.

Finally, I tried pimd though smcroute works, because smcroute had a certain problem after installation (Debian/Ubuntu systemd): it does not recognize the docker0 interface when it's started. Surely because docker is started after smcroute or because it takes some more time. Unfortunately, pimd seems to have the same problem. It only works if I restart the service from terminal after first login after reboot. Any idea how this could be solved? Should pimd rescan network interfaces?