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

running pimd on the same machine #206

Closed teamblubee closed 2 years ago

teamblubee commented 2 years ago

I am using debian with ip, route, pimd. Running pimd on the same machine that needs to create a gre tunnel.

I have a network connection where I need to bring up a GRE tunnel but I am getting routing information broadcast.

Scanning with tcdump I am getting this loop

21:24:22.587555 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:24:45.670504 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:24:51.787331 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:25:20.887682 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:25:45.670673 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:25:50.487457 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:26:20.237066 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:26:45.670849 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:26:49.937594 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:27:19.887558 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:27:45.670875 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:27:49.587255 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:28:19.037075 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:28:45.671013 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:28:48.336608 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:29:18.086936 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:29:45.671450 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:29:47.837119 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:30:17.336967 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:30:45.671627 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2    
21:30:46.986704 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38    
21:31:16.787066 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38 

pimd -n is showing this output

pimd: 21:29:02.209 New RP candidate 192.168.47.65 for group 224.0.0.0/4, priority 20                                         
pimd: 21:29:16.640 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:29:36.631 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:29:57.272 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:30:16.938 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:30:36.558 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:30:57.459 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:31:17.377 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:31:37.161 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:31:57.270 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:32:16.815 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:32:37.413 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:32:57.473 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:33:17.372 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER
pimd: 21:33:36.595 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER

Will I be able to run pimd on the same virtual machine that I am currently trying to bring up the GRE tunnel? If not, what are some suggestions to re-architect the program?

troglobit commented 2 years ago

Running pimd on the same machine that needs to create a gre tunnel.

Please tell me a bit more about your setup, I don't understand what you mean. How's the setup, what are you trying to do, where are your senders and receivers of multicast? Maybe a topology, ascii art is fine as long as you surround it in backticks (Markdown).

teamblubee commented 2 years ago

my machine creates an ipsec tunnel to the server. I also have to setup a gre tunnel through this ipsec tunnel.

                                         ┌───────────────────┐
                                         │                   │
                                         │                   │
┌──────────────┐                         │                   │
│              │      ipsec tunnel       │                   │
│             ─┼─────────────────────────┼─                  │
│              ├─────────────────────────┤                   │
│   my machine │       gre tunnel        │    server         │
│              ├─────────────────────────┤                   │
│             ─┼─────────────────────────┼──                 │
│              │                         │                   │
└──────────────┘                         │                   │
                                         │                   │
                                         │                   │
                                         └───────────────────┘

my machine first sets up an ipsec tunnel to the server; this part is configured correctly.

Next I will need to bring up a GRE tunnel inside the ipsec tunnel; These routes are being advertised from the server across the ipsec tunnel and I can examine the GRE broadcast messages in tcpdump.

On my machine I've built and installed pimd version 3.0-beta1, used the basic pimd.conf and started pimd. I can see the server broadcasting on my machine. I try to bring up a gre tunnel from my machine to the server but this is where I am having difficulties.

Multicast Routing Table                                                                                                      
Source            Group            RP Address       Flags                                             

Number of Groups        : 0
Number of Cache MIRRORs : 0

PIM Candidate Rendez-Vous Point Table
Group Address     RP Address       Prio  Holdtime  Expires                                            
232/8             169.254.0.1         1    Static  Never
224/4             192.168.47.65       20        75  0h1m10s

Current BSR address: 192.168.47.65

PIM Rendez-Vous Point Set Table
Group Address     RP Address       Prio  Holdtime  Type                                               
232/8             169.254.0.1         1   Forever  Static 
224/4             192.168.47.65       20        70  Dynamic

Trying to bring up the GRE tunnel fails. I think I need to have pim-sm correctly working. Looking at tcpdump I see the server sending igmp query v2 and pimv2 hello messages. My machine isn't responding.

on my machine, scanning the interface that I assigned to the GRE tunnel, I see this output, it just repeats

23:16:25.125573 IP 10.10.17.65 > 224.0.0.1: igmp query v3     
23:16:25.125593 IP 10.10.1.234 > 224.0.0.1: igmp query v3     
23:16:28.591113 IP 10.10.17.65 > 224.0.0.22: igmp v3 report, 3 group record(s)     
23:16:29.592398 IP 10.10.17.65 > 224.0.0.13: PIMv2, Hello, length 26     
23:16:29.592413 IP 10.10.1.234 > 224.0.0.13: PIMv2, Hello, length 26     
23:16:39.904570 IP 10.10.17.65 > 224.0.0.1: igmp query v3     
23:16:39.904625 IP 10.10.1.234 > 224.0.0.1: igmp query v3     
23:16:43.439168 IP 10.10.17.65 > 224.0.0.22: igmp v3 report, 3 group record(s)     
23:16:54.821550 IP 10.10.17.65 > 224.0.0.1: igmp query v3      

With the tunnel setup like this

ip tun add tunnel mode gre local x.x.x.x remote x.x.x.x
ip link set multicast on tunnel
ip addr add 10.10.17.65 dev tunnel

I can tcpdump physical nic and see the server sending the hello messages, they do not make it to the tunnel interface. I can also tcpdump the gre tunnel interface and see that one doing hello broadcasts, but it doesn't make it to the server.

pimd is running, but it outputs pimd: 23:26:40.270 For src 169.254.0.1, iif is 1, next hop router is 10.1.0.1: NOT A PIM ROUTER

can I make some configuration changes to pimd on my local machine so that it can listen to the pim-sm broadcasts and build the routing table?

troglobit commented 2 years ago

Still not sure I understand what it is you want to achieve. You don't need PIM to establish a GRE tunnel. Nor does it seem you need PIM to receive generic multicast data from your server, because it's locally attached to the server. The server of course needs to listen to all its interfaces and support IGMP join, or flood multicast as broadcast.

Do you have control over both 'my machine' and 'server', or are you setting up 'my machine' as en end-device for multicast reception? Multicast routing daemons route multicast data between interfaces, you have not mentioned between which interfaces you expect the routing to happen.

If your setup is more along the lines of the following, and 'my machine' wants to receive multicast data from 'sender':

   [my machine]----------[server]----------[sender]

Then you only need a multicast router on 'server'.

teamblubee commented 2 years ago

I have no control over the remote server, only my machine. Lets assume that their server is configured correctly. I have just one host with a default interface eth0. I make an ipsec connection from my [host] -> [server]

once that tunnel is up, I see messages like these from the server `21:24:22.587555 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38 21:24:45.670504 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2 21:24:51.787331 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38

21:25:20.887682 IP 192.168.254.1 > 192.168.0.60: GREv0, length 62: IP 192.168.4.233 > 224.0.0.13: PIMv2, Hello, length 38 21:25:45.670673 IP 192.168.254.1 > 192.168.0.60: GREv0, length 36: IP 192.168.4.233 > 224.0.0.1: igmp query v2 `

at this point, the remote server is sending igmp and gre messages to my host address 192.168.0.60

do I use pimd to turn my host machine into a pimd server to accept and join the remote servers pim-sm network?

troglobit commented 2 years ago

I see. Well you don't need PIM. PIM is for routers only. You need a client that can do an IGMP join (assuming IPv4). You need to know the multicast group to join (via IGMP). The router/server then registers your request and possibly forwards it out on networks it knows of as either a "PIM join" or if it has the group locally, sets up a multicast route towards you for the group you requested.

teamblubee commented 2 years ago

monitoring my network I am seeing messages like these

x.x.x.x -> 224.0.0.13 pimv2 96 hello x.x.x.x -> 224.0.0.13 pimv2 96 hello x.x.x.x -> 224.0.0.1 igmpv2 70 membership query, general those three lines just repeats.

Are you saying that I do not need pimd but instead I need an application that reads the location to join from the igmp packets, then make a join request?

troglobit commented 2 years ago

To be perfectly honest, I still don't really understand what it is you want to do yet. A PIM Hello message is the initial message in a PIM router peering - "Hi, I'm a PIMv2 router with the following capabilities ...". An IGMP Query is akin to a newspaper salesman calling you up asking if you want to subscribe to any newspaper. None of those messages contain any information about what's available on the other side of the server/router -- that you need to know beforehand.

An IGMP join is sent either as a (*,G) or an (S,G) membership report. I.e., either source-specific or any-source. The G is the IP multicast group to join, e.g. 225.1.2.3 or something. What is it you want to do, watch movies, listen to music, record sensor data, or what? In any even, I suggest you seek help from another source, because I'm pretty sure this project is not the place to teach you about IP multicast networking.

teamblubee commented 2 years ago

Thank you for the clarification, it's my duty as the host to acknowledge the salesman to start listening to their offer so to speak.

That means I will need to either find a program that already speaks multicast or write one to initiate and maintain the conversation until Leaving.

Thanks again.

troglobit commented 2 years ago

Exactly that. Good luck!