# PIM6 - Protocol Independent Multicast for IPv6

> Configure PIM6 on VyOS: IPv6 multicast routing with MLD, Source-Specific Multicast (SSM), Rendezvous Point, Bootstrap Router for Yandex Cloud and VK Cloud

Source: https://opennix.org/en/docs/vyos/routing/vyos-pim6/


PIM6 (Protocol Independent Multicast for IPv6) provides multicast routing in IPv6 networks, using MLD (Multicast Listener Discovery) instead of IGMP.

## Overview

PIM6 is the version of the PIM protocol for IPv6 networks.

**Key characteristics**:
- Multicast routing for IPv6
- Uses MLD instead of IGMP
- Supports PIM-SM (Sparse Mode) and PIM-SSM (Source-Specific Multicast)
- Works with the IPv6 address space ff00::/8
- Requires RP (Rendezvous Point) configuration for SM mode
- Built-in support for Embedded RP (RFC 3956)

**Standards**:
- **RFC 4601** - Protocol Independent Multicast - Sparse Mode (PIM-SM): the base standard
- **RFC 7761** - Protocol Independent Multicast - Sparse Mode (PIM-SM): update
- **RFC 3810** - Multicast Listener Discovery Version 2 (MLDv2) for IPv6
- **RFC 3956** - Embedding the Rendezvous Point (RP) Address in an IPv6 Multicast Address
- **RFC 4607** - Source-Specific Multicast for IP
- **RFC 5059** - Bootstrap Router (BSR) Mechanism for PIM

**Use cases**:
- IPv6-only networks with multicast requirements
- Modern data centers with IPv6
- IoT networks based on IPv6
- Video conferencing over IPv6
- IPTV over IPv6
- Software-defined networking (SDN) with IPv6 multicast

## PIM6 vs PIM (IPv4)

### Key differences

| Characteristic | PIM (IPv4) | PIM6 (IPv6) |
|---------------|------------|-------------|
| Group management | IGMP | MLD |
| Address space | 224.0.0.0/4 | ff00::/8 |
| RP address | IPv4 | IPv6, Embedded RP support |
| SSM range | 232.0.0.0/8 | ff3x::/32 |
| Neighbor discovery | PIM Hello (IPv4) | PIM Hello (IPv6) |
| BSR address | IPv4 | IPv6 |
| Auto-RP | Available | Not applicable |

### Common features

**Similar between PIM and PIM6**:
- The PIM-SM algorithm is identical
- Bootstrap Router (BSR) mechanism
- Source-Specific Multicast (SSM)
- Register mechanism for new sources
- Join/Prune messages
- Assert mechanism for forwarder selection

## MLD (Multicast Listener Discovery)

### MLD overview

MLD is the IPv6 equivalent of IGMP.

**MLD versions**:

**MLDv1** (RFC 2710):
- Basic functionality
- Listener Report and Listener Done messages
- Any-Source Multicast (ASM)

**MLDv2** (RFC 3810):
- Source filtering (Include/Exclude)
- Source-Specific Multicast (SSM) support
- Backward compatibility with MLDv1

### MLD messages

**Multicast Listener Query**:
- Sent by the router to discover listeners
- General Query - for all groups
- Multicast-Address-Specific Query - for a specific group
- Multicast-Address-and-Source-Specific Query - for a group and source (MLDv2)

**Multicast Listener Report**:
- The host announces its intent to receive multicast traffic
- Periodic updates

**Multicast Listener Done** (MLDv1):
- The host leaves a multicast group
- Fast subscription removal

**MLDv2 Report**:
- Extended Report with source filtering
- Include/Exclude modes

### IPv6 Multicast addresses

**IPv6 multicast structure**: `ffXY::/8`

**X - Flags**:
- 0 = Well-known multicast
- 1 = Transient multicast

**Y - Scope**:
- 0 = Reserved
- 1 = Interface-local
- 2 = Link-local
- 4 = Admin-local
- 5 = Site-local
- 8 = Organization-local
- E = Global

**Special addresses**:
- **ff02::1** - All Nodes (all nodes on the link)
- **ff02::2** - All Routers (all routers on the link)
- **ff02::5** - OSPFv3 All Routers
- **ff02::6** - OSPFv3 Designated Routers
- **ff02::9** - RIPng Routers
- **ff02::d** - PIM Routers
- **ff02::16** - MLDv2 Reports destination
- **ff02::1:2** - All DHCP Servers and Relay Agents
- **ff05::1:3** - All DHCP Servers (site-local)

**SSM range**: ff3x::/32 (x = scope)
- **ff3e::/32** - SSM Global scope

**Embedded RP**: ff7x:0RP0::/96
- The RP address is embedded in the multicast address

## PIM6-SM (Sparse Mode)

### Concept

PIM6-SM uses a shared tree through a Rendezvous Point (RP).

**Operation stages**:

1. **The source registers**:
   - The source's Designated Router (DR) encapsulates multicast packets in a PIM Register
   - The Register is sent as unicast to the RP

2. **Receivers join**:
   - The receiver's DR sends a PIM Join toward the RP
   - A shared tree (*, G) is built from the receivers to the RP

3. **Shortest Path Tree (SPT)**:
   - The receiver's DR optionally switches to the SPT (S, G)
   - A direct path from the source to the receiver
   - Sends a Prune toward the RP for (*, G)

4. **Optimization**:
   - The SPT minimizes latency
   - The RP is offloaded once the SPT is built

### RP for IPv6

**RP configuration methods**:

1. **Static RP**:
   - Manual configuration on all routers
   - Maximum control
   - Requires synchronization

2. **Embedded RP** (RFC 3956):
   - The RP address is embedded in the multicast group
   - Automatic RP determination
   - Format: ff7x:0RP0::/96

3. **Bootstrap Router (BSR)**:
   - Dynamic distribution of RP information
   - Candidate-RP and Candidate-BSR
   - Automatic updates

### Embedded RP

**Address format**:
```
ff7S:0RPN:PPPP:PPPP:PPPP:PPPP:GGGG:GGGG
```

Where:
- **S** - Scope (4 bits)
- **0** - Reserved (4 bits)
- **R** - Riid (4 bits) - RP interface
- **P** - Plen (8 bits) - RP prefix length
- **N** - Network prefix (8 bits)
- **P...P** - RP IPv6 prefix (64 bits)
- **G...G** - Group ID (32 bits)

**Example**:
```
RP address: 2001:db8::1
Multicast group: ff75:0030:2001:0db8:0000:0000:0000:1234

Breakdown:
ff75 - flags=7 (transient), scope=5 (site-local)
0030 - Riid=0, Plen=48 (2001:db8::/48)
2001:0db8:0000 - RP prefix
0000:0000:1234 - Group ID
```

**Advantages**:
- Does not require manual RP configuration on every router
- The RP is determined automatically from the group
- Simplified configuration

**Disadvantages**:
- Limited flexibility in RP selection
- Dependency on the addressing scheme

## Basic PIM6 configuration

### Enabling PIM6 on an interface

**Syntax**:
```
set protocols pim6 interface <interface>
```

**Example**:
```
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 interface eth2

commit
save
```

**Effect**:
- Enables PIM6 on the interface
- Automatically starts MLD
- Sends/receives PIM Hello messages
- Participates in multicast routing

### Basic PIM6-SM network

**Scenario**:
- Three routers in a triangular topology
- Static RP on Router2
- Multicast source behind Router1
- Receivers behind Router3

**Topology**:
```
[Source] --- Router1 --- Router2 (RP) --- Router3 --- [Receivers]
             eth1         eth0  eth1     eth0  eth1
```

**Router1** (First Hop Router):
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:12::1/64
set interfaces ethernet eth1 address 2001:db8:1::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Static RP (must match on all routers)
set protocols pim6 rp address 2001:db8:2::1

commit
save
```

**Router2** (RP):
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:12::2/64
set interfaces ethernet eth1 address 2001:db8:23::1/64
set interfaces ethernet eth2 address 2001:db8:2::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 interface eth2

# RP on loopback or eth2
set protocols pim6 rp address 2001:db8:2::1

commit
save
```

**Router3** (Last Hop Router):
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:23::2/64
set interfaces ethernet eth1 address 2001:db8:3::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Static RP
set protocols pim6 rp address 2001:db8:2::1

commit
save
```

### Verifying the basic configuration

**Check PIM6 interfaces**:
```
show ipv6 pim interface
```

Output:
```
Interface  State  Address            PIM Nbrs  PIM DR   DR Priority
eth0       up     2001:db8:12::1/64  1         2001:db8:12::2  1
eth1       up     2001:db8:1::1/64   0         local      1
```

**Check PIM6 neighbors**:
```
show ipv6 pim neighbor
```

Output:
```
Interface  Neighbor          Uptime     Holdtime  DR Priority
eth0       2001:db8:12::2    00:15:23   105       1
```

**Check the RP**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group          Source          State
2001:db8:2::1    ff00::/8       Static          Active
```

## MLD configuration

### Enabling MLD on an interface

MLD is enabled automatically when PIM6 is activated, but you can tune its parameters.

**View MLD groups**:
```
show ipv6 mld groups
```

Output:
```
Interface        Address                    Group                   Uptime    Expires
eth1             2001:db8:3::1              ff3e::1234              00:05:23  00:04:12
eth1             2001:db8:3::1              ff05::5678              00:03:45  00:04:18
```

**View MLD interfaces**:
```
show ipv6 mld interface
```

Output:
```
Interface  State  Address            Version  Querier         Query Timer  Uptime
eth0       up     fe80::1            2        fe80::1         00:01:15     00:20:34
eth1       up     fe80::2            2        fe80::2         00:00:58     00:20:34
```

### MLD parameters

**Disable MLD on an interface**:
```
set protocols pim6 interface <interface> mld disable
```

**Use case**:
- The interface participates in PIM6 but does not process MLD
- Used for transit interfaces without clients

**Example**:
```
set protocols pim6 interface eth0 mld disable

commit
save
```

**Query Interval**:
```
set protocols pim6 interface <interface> mld interval <seconds>
```

**Parameters**:
- **seconds**: 1-65535 (default 125)

**Example**:
```
set protocols pim6 interface eth1 mld interval 60

commit
save
```

**Last Member Query Count**:
```
set protocols pim6 interface <interface> mld last-member-query-count <count>
```

**Use case**:
- Number of Group-Specific Queries after a Listener Done
- Affects the speed of removal from the group

**Example**:
```
set protocols pim6 interface eth1 mld last-member-query-count 2

commit
save
```

**Last Member Query Interval**:
```
set protocols pim6 interface <interface> mld last-member-query-interval <milliseconds>
```

**Parameters**:
- **milliseconds**: 100-6553500 (default 1000)

**Example**:
```
set protocols pim6 interface eth1 mld last-member-query-interval 500

commit
save
```

**Max Response Time**:
```
set protocols pim6 interface <interface> mld max-response-time <milliseconds>
```

**Use case**:
- Maximum time to wait for a response to a Query
- Affects convergence

**Example**:
```
set protocols pim6 interface eth1 mld max-response-time 5000

commit
save
```

**MLD Version**:
```
set protocols pim6 interface <interface> mld version <1-2>
```

**Use case**:
- Force the use of MLDv1 or MLDv2
- MLDv2 is required for SSM

**Example**:
```
set protocols pim6 interface eth1 mld version 2

commit
save
```

### Static group join

**Join a group on an interface**:
```
set protocols pim6 interface <interface> mld join <multicast-address>
```

**Example**:
```
set protocols pim6 interface eth1 mld join ff3e::1234

commit
save
```

**Use case**:
- The router joins the group as a host
- Useful for testing
- The router begins receiving the group's traffic on this interface

**Join with a specified source (SSM)**:
```
set protocols pim6 interface <interface> mld join <multicast-address> source <source-address>
```

**Example**:
```
set protocols pim6 interface eth1 mld join ff3e::5678 source 2001:db8:100::10

commit
save
```

**Use case**:
- Source-Specific Multicast
- The router receives only from the specified source
- Requires MLDv2

## RP configuration

### Static RP

**RP address configuration**:
```
set protocols pim6 rp address <ipv6-address>
```

**Important**: The configuration must be identical on all PIM6 routers in the domain.

**Example**:
```
set protocols pim6 rp address 2001:db8:100::1

commit
save
```

**Verification**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group          Source          State
2001:db8:100::1  ff00::/8       Static          Active
```

### RP for specific groups

**RP for a range of groups**:
```
set protocols pim6 rp address <ipv6-address> group <prefix>
```

**Example**:
```
set protocols pim6 rp address 2001:db8:100::1 group ff3e::/32
set protocols pim6 rp address 2001:db8:100::2 group ff05::/16

commit
save
```

**Use case**:
- Different RPs for different groups
- Load balancing between RPs
- Separation by scope

**Verification**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group          Source          State
2001:db8:100::1  ff3e::/32      Static          Active
2001:db8:100::2  ff05::/16      Static          Active
```

### Keep-Alive Timer for the RP

**Keep-Alive for (S,G) on the RP**:
```
set protocols pim6 rp keep-alive-timer <seconds>
```

**Parameters**:
- **seconds**: 31-60000 (default 185)

**Use case**:
- The time (S,G) state is held on the RP
- Affects convergence during changes

**Example**:
```
set protocols pim6 rp keep-alive-timer 210

commit
save
```

## BSR (Bootstrap Router) for IPv6

### BSR overview

BSR provides dynamic distribution of RP information.

**Components**:

**Candidate-BSR (C-BSR)**:
- A router that participates in BSR election
- Selected based on priority and address
- Distributes the RP-Set

**Candidate-RP (C-RP)**:
- A router that wants to be an RP
- Sends a Candidate-RP-Advertisement to the BSR
- The BSR includes it in the RP-Set

**Bootstrap Message (BSM)**:
- Contains the RP-Set
- Distributed via multicast ff02::d
- Flooded across the PIM6 domain

### BSR configuration

**Candidate-BSR**:
```
set protocols pim6 rp candidate-bsr address <ipv6-address>
set protocols pim6 rp candidate-bsr priority <priority>
```

**Parameters**:
- **address**: interface IPv6 address
- **priority**: 0-255 (default 0, higher = better)

**Example**:
```
set protocols pim6 rp candidate-bsr address 2001:db8:100::1
set protocols pim6 rp candidate-bsr priority 100

commit
save
```

**Candidate-RP**:
```
set protocols pim6 rp candidate-rp address <ipv6-address>
set protocols pim6 rp candidate-rp priority <priority>
set protocols pim6 rp candidate-rp interval <seconds>
```

**Parameters**:
- **address**: the IPv6 address that will be the RP
- **priority**: 0-255 (default 192, lower = better for RP)
- **interval**: 1-16383 (default 60) - the interval for sending C-RP Advertisements

**Example**:
```
set protocols pim6 rp candidate-rp address 2001:db8:100::1
set protocols pim6 rp candidate-rp priority 50
set protocols pim6 rp candidate-rp interval 30

commit
save
```

**Candidate-RP for specific groups**:
```
set protocols pim6 rp candidate-rp address <ipv6-address> group <prefix>
```

**Example**:
```
set protocols pim6 rp candidate-rp address 2001:db8:100::1 group ff3e::/32

commit
save
```

### Verifying BSR

**BSR information**:
```
show ipv6 pim bsr
```

Output:
```
PIM6 Bootstrap Information
Current BSR Address: 2001:db8:100::1
Priority: 100
Hash Mask Length: 126
Expires: 00:01:45

Candidate BSR Address: 2001:db8:100::1
  Priority: 100
  Hash Mask Length: 126
```

**RP-Set from the BSR**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group          Source          State      Priority  Holdtime
2001:db8:100::1  ff3e::/32      BSR             Active     50        150
2001:db8:100::2  ff05::/16      BSR             Active     100       150
```

## SSM (Source-Specific Multicast) for IPv6

### SSM overview for IPv6

SSM for IPv6 uses the ff3x::/32 range.

**Address format**:
```
ff3S::/32
```

Where **S** is the scope:
- **ff3e::/32** - Global SSM
- **ff35::/32** - Site-local SSM
- **ff38::/32** - Organization-local SSM

**SSM advantages**:
- Does not require an RP
- Direct (S,G) trees
- Improved security
- Less state on routers
- Predictable traffic paths

### SSM configuration

**Automatic SSM detection**:
VyOS automatically uses SSM for ff3x::/32.

**Explicit SSM range configuration**:
```
set protocols pim6 ssm-range <prefix>
```

**Example**:
```
set protocols pim6 ssm-range ff3e::/32

commit
save
```

**Verifying SSM**:
```
show ipv6 pim state
```

The output will show (S,G) entries without (*,G) for SSM groups:
```
Source           Group            IIF      OIL
2001:db8:100::10 ff3e::1234       eth0     eth1, eth2
```

### MLDv2 for SSM

SSM requires MLDv2 for source filtering.

**Enabling MLDv2**:
```
set protocols pim6 interface eth1 mld version 2

commit
save
```

**Verification**:
```
show ipv6 mld interface
```

Output:
```
Interface  State  Address            Version  Querier         Query Timer  Uptime
eth1       up     fe80::2            2        fe80::2         00:00:58     00:20:34
```

## Advanced configuration

### DR Priority

**Setting the Designated Router priority**:
```
set protocols pim6 interface <interface> dr-priority <priority>
```

**Parameters**:
- **priority**: 0-4294967295 (default 1, higher = better)

**Use case**:
- DR selection on a multi-access network
- The DR registers sources and sends Joins

**Example**:
```
set protocols pim6 interface eth0 dr-priority 100

commit
save
```

**Checking the DR**:
```
show ipv6 pim interface eth0
```

Output:
```
Interface  State  Address            PIM Nbrs  PIM DR          DR Priority
eth0       up     2001:db8:12::1/64  1         2001:db8:12::1  100
```

### Hello Interval

**Setting the Hello interval**:
```
set protocols pim6 interface <interface> hello <interval>
```

**Parameters**:
- **interval**: 1-65535 seconds (default 30)

**Use case**:
- The frequency of sending PIM Hello messages
- Affects neighbor discovery

**Example**:
```
set protocols pim6 interface eth0 hello 15

commit
save
```

### Join/Prune Interval

**Setting the Join/Prune interval**:
```
set protocols pim6 join-prune-interval <seconds>
```

**Parameters**:
- **seconds**: 60-600 (default 60)

**Use case**:
- The frequency of sending Join/Prune messages
- Refresh for existing (S,G) and (*,G)

**Example**:
```
set protocols pim6 join-prune-interval 90

commit
save
```

### Register Suppression Time

**Setting the Register suppression time**:
```
set protocols pim6 register-suppress-time <seconds>
```

**Parameters**:
- **seconds**: 5-60000 (default 60)

**Use case**:
- The time to suppress Register after a Register-Stop
- The source's DR stops encapsulation into Register

**Example**:
```
set protocols pim6 register-suppress-time 120

commit
save
```

### Multicast Routing Table

**SPT Switchover (iif)**:
VyOS automatically switches to the SPT when traffic is received.

**Infinity for the SPT Threshold**:
Disable switching to the SPT (stay on the shared tree):
```
set protocols pim6 spt-switchover infinity-and-beyond
```

**Use case**:
- All traffic flows through the RP
- Simplified topology
- May increase latency

**Example**:
```
set protocols pim6 spt-switchover infinity-and-beyond

commit
save
```

### Packet Parameters

**DSCP for PIM packets**:
```
set protocols pim6 packet dscp <value>
```

**Parameters**:
- **value**: 0-63

**Example**:
```
set protocols pim6 packet dscp 46

commit
save
```

## Configuration examples

### Example 1: IPv6 Multicast in Yandex Cloud

**Scenario**:
- VyOS router in Yandex Cloud as a PIM6 RP
- Video server in the 2001:db8:100::/64 subnet
- Three offices receive IPv6 multicast video
- Using PIM6-SM with a static RP
- SSM for critical streams

**Topology**:
```
[Video Server] --- eth1 --- [VyOS RP] --- eth0 --- [Internet/VPC]
  2001:db8:100::10                |
  ff3e::1234 (SSM)                |--- eth2 --- [Office 1]
  ff05::5678 (SM)                 |               2001:db8:1::/64
                                  |--- eth3 --- [Office 2]
                                  |               2001:db8:2::/64
                                  |--- eth4 --- [Office 3]
                                                  2001:db8:3::/64
```

**VyOS RP configuration**:
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:10::1/64
set interfaces ethernet eth0 description 'WAN - VPC Interconnect'

set interfaces ethernet eth1 address 2001:db8:100::1/64
set interfaces ethernet eth1 description 'DMZ - Video Servers'

set interfaces ethernet eth2 address 2001:db8:1::1/64
set interfaces ethernet eth2 description 'Office 1'

set interfaces ethernet eth3 address 2001:db8:2::1/64
set interfaces ethernet eth3 description 'Office 2'

set interfaces ethernet eth4 address 2001:db8:3::1/64
set interfaces ethernet eth4 description 'Office 3'

# Loopback for RP
set interfaces loopback lo address 2001:db8:999::1/128

# PIM6 on all interfaces
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 interface eth2
set protocols pim6 interface eth3
set protocols pim6 interface eth4

# MLD parameters for client interfaces
set protocols pim6 interface eth2 mld version 2
set protocols pim6 interface eth2 mld interval 60

set protocols pim6 interface eth3 mld version 2
set protocols pim6 interface eth3 mld interval 60

set protocols pim6 interface eth4 mld version 2
set protocols pim6 interface eth4 mld interval 60

# Disable MLD on WAN
set protocols pim6 interface eth0 mld disable

# RP configuration
set protocols pim6 rp address 2001:db8:999::1

# SSM range (automatic for ff3x::/32)
set protocols pim6 ssm-range ff3e::/32

# DR Priority on the server segment
set protocols pim6 interface eth1 dr-priority 100

# Firewall for IPv6 multicast
set firewall ipv6 input filter rule 100 action accept
set firewall ipv6 input filter rule 100 description 'Allow PIM6'
set firewall ipv6 input filter rule 100 protocol pim

set firewall ipv6 input filter rule 110 action accept
set firewall ipv6 input filter rule 110 description 'Allow MLD'
set firewall ipv6 input filter rule 110 protocol ipv6-icmp
set firewall ipv6 input filter rule 110 icmpv6 type 130-132

set firewall ipv6 input filter rule 120 action accept
set firewall ipv6 input filter rule 120 description 'Allow multicast traffic'
set firewall ipv6 input filter rule 120 destination address ff00::/8

# IPv6 Routing (OSPFv3 or BGP for unicast)
set protocols ospfv3 area 0 interface eth0
set protocols ospfv3 area 0 interface eth1
set protocols ospfv3 area 0 interface eth2
set protocols ospfv3 area 0 interface eth3
set protocols ospfv3 area 0 interface eth4
set protocols ospfv3 parameters router-id 10.0.0.1

commit
save
```

**Office routers** (example for Office 1):
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:1::254/64
set interfaces ethernet eth0 description 'To RP'

set interfaces ethernet eth1 address 2001:db8:10::100/64
set interfaces ethernet eth1 description 'Clients'

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# MLD on the client interface
set protocols pim6 interface eth1 mld version 2
set protocols pim6 interface eth1 mld interval 60

# RP (same as on the main router)
set protocols pim6 rp address 2001:db8:999::1

# SSM
set protocols pim6 ssm-range ff3e::/32

# OSPFv3 for unicast
set protocols ospfv3 area 0 interface eth0
set protocols ospfv3 area 0 interface eth1
set protocols ospfv3 parameters router-id 10.0.0.2

commit
save
```

**Verification**:
```
# On the RP
show ipv6 pim interface
show ipv6 pim neighbor
show ipv6 pim rp-info
show ipv6 pim state

# On the Office router
show ipv6 mld groups
show ipv6 pim join

# Traffic monitoring
tcpdump -i eth1 -n 'ip6 and dst net ff00::/8'
```

### Example 2: PIM6-SSM for an IPv6-only network (VK Cloud)

**Scenario**:
- IPv6-only network in VK Cloud
- Only SSM (ff3e::/32) is used
- No RP required
- Video conferencing between offices
- Sources in 2001:db8:100::/64

**Topology**:
```
[HQ Router] --- eth0 (2001:db8:10::1/64) --- [VK Cloud VPC]
     |                                              |
     eth1 (2001:db8:100::1/64)                     |
     |                                              |
[Video Server 2001:db8:100::10]            [Branch Router]
                                                    |
                                                    eth1 (2001:db8:200::1/64)
                                                    |
                                                [Users]
```

**HQ Router**:
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:10::1/64
set interfaces ethernet eth0 description 'VPC Interconnect'

set interfaces ethernet eth1 address 2001:db8:100::1/64
set interfaces ethernet eth1 description 'Video Servers'

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Disable MLD on the server interface
set protocols pim6 interface eth1 mld disable

# SSM only (no RP needed)
set protocols pim6 ssm-range ff3e::/32

# DR Priority
set protocols pim6 interface eth1 dr-priority 100

# Firewall
set firewall ipv6 input filter rule 100 action accept
set firewall ipv6 input filter rule 100 protocol pim

set firewall ipv6 input filter rule 110 action accept
set firewall ipv6 input filter rule 110 destination address ff3e::/32

# BGP for unicast routing
set protocols bgp system-as 65001
set protocols bgp neighbor 2001:db8:10::254 address-family ipv6-unicast
set protocols bgp neighbor 2001:db8:10::254 remote-as 65000

commit
save
```

**Branch Router**:
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:10::100/64
set interfaces ethernet eth0 description 'VPC Interconnect'

set interfaces ethernet eth1 address 2001:db8:200::1/64
set interfaces ethernet eth1 description 'Users'

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# MLDv2 for clients (mandatory for SSM)
set protocols pim6 interface eth1 mld version 2
set protocols pim6 interface eth1 mld interval 60

# SSM only
set protocols pim6 ssm-range ff3e::/32

# Firewall
set firewall ipv6 input filter rule 100 action accept
set firewall ipv6 input filter rule 100 protocol pim

set firewall ipv6 input filter rule 110 action accept
set firewall ipv6 input filter rule 110 destination address ff3e::/32

# BGP
set protocols bgp system-as 65001
set protocols bgp neighbor 2001:db8:10::254 address-family ipv6-unicast
set protocols bgp neighbor 2001:db8:10::254 remote-as 65000

commit
save
```

**Client subscription (Linux)**:
```bash
# SSM join: group ff3e::1234, source 2001:db8:100::10
smcroute -j eth0 2001:db8:100::10 ff3e::1234

# Or using socat
socat UDP6-RECV:5000,ipv6-join-source-group='[ff3e::1234]:[2001:db8:100::10]:eth0' STDOUT
```

**Verification**:
```
show ipv6 pim state
show ipv6 mld groups
```

### Example 3: Embedded RP

**Scenario**:
- Using Embedded RP to simplify configuration
- RP address: 2001:db8:999::1/64
- Groups: ff75:0040:2001:0db8:0999:0000::/96

**RP Router**:
```
# Interfaces
set interfaces loopback lo address 2001:db8:999::1/128

set interfaces ethernet eth0 address 2001:db8:10::1/64
set interfaces ethernet eth1 address 2001:db8:20::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Embedded RP (automatic for ff7x::/16)
# No additional configuration required

commit
save
```

**Client Router**:
```
# Interfaces
set interfaces ethernet eth0 address 2001:db8:10::2/64
set interfaces ethernet eth1 address 2001:db8:100::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Embedded RP - extracted automatically from the group address
# No manual RP configuration required

commit
save
```

**Using an Embedded RP group**:
The application uses a group of the form:
```
ff75:0040:2001:0db8:0999:0000:0000:1234
```

Breakdown:
- `ff75` - flags=7 (transient), scope=5 (site-local)
- `0040` - Riid=0, Plen=64
- `2001:0db8:0999:0000` - RP prefix (2001:db8:999::/64)
- `0000:1234` - Group ID

**Verification**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group                                  Source          State
2001:db8:999::1  ff75:40:2001:db8:999::/96              Embedded        Active
```

### Example 4: BSR for dynamic RP

**Scenario**:
- Two Candidate-RPs for redundancy
- One BSR
- Automatic distribution of RP information

**BSR and Primary RP (Router1)**:
```
# Interfaces
set interfaces loopback lo address 2001:db8:100::1/128

set interfaces ethernet eth0 address 2001:db8:10::1/64
set interfaces ethernet eth1 address 2001:db8:20::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# BSR configuration
set protocols pim6 rp candidate-bsr address 2001:db8:100::1
set protocols pim6 rp candidate-bsr priority 100

# Candidate-RP configuration
set protocols pim6 rp candidate-rp address 2001:db8:100::1
set protocols pim6 rp candidate-rp priority 50
set protocols pim6 rp candidate-rp interval 30

commit
save
```

**Secondary RP (Router2)**:
```
# Interfaces
set interfaces loopback lo address 2001:db8:100::2/128

set interfaces ethernet eth0 address 2001:db8:10::2/64
set interfaces ethernet eth1 address 2001:db8:30::1/64

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# Backup BSR (lower priority)
set protocols pim6 rp candidate-bsr address 2001:db8:100::2
set protocols pim6 rp candidate-bsr priority 50

# Candidate-RP (lower priority)
set protocols pim6 rp candidate-rp address 2001:db8:100::2
set protocols pim6 rp candidate-rp priority 100
set protocols pim6 rp candidate-rp interval 30

commit
save
```

**Client Routers**:
```
# PIM6 on the interfaces
set protocols pim6 interface eth0
set protocols pim6 interface eth1

# No static RP configuration!
# RP information is received via the BSR

commit
save
```

**Verification**:
```
show ipv6 pim bsr
show ipv6 pim rp-info
```

## Operational commands

### Show Commands

**PIM6 interfaces**:
```
show ipv6 pim interface
```

Output:
```
Interface  State  Address            PIM Nbrs  PIM DR          DR Priority
eth0       up     2001:db8:10::1/64  2         2001:db8:10::1  100
eth1       up     2001:db8:20::1/64  0         local           1
```

**Interface details**:
```
show ipv6 pim interface eth0
```

Output:
```
Interface eth0:
  State: up
  Address: 2001:db8:10::1/64
  PIM Neighbors: 2
  PIM DR: 2001:db8:10::1
  DR Priority: 100
  Hello Interval: 30s
  Generation ID: 0x12345678
```

**PIM6 neighbors**:
```
show ipv6 pim neighbor
```

Output:
```
Interface  Neighbor          Uptime     Holdtime  DR Priority  Generation ID
eth0       2001:db8:10::2    01:23:45   105       50           0xabcdef12
eth0       2001:db8:10::3    00:45:12   105       1            0x98765432
```

**Neighbor details**:
```
show ipv6 pim neighbor detail
```

**RP information**:
```
show ipv6 pim rp-info
```

Output:
```
RP address       Group          Source          State      Priority  Holdtime
2001:db8:100::1  ff00::/8       Static          Active     -         -
2001:db8:100::1  ff3e::/32      BSR             Active     50        150
2001:db8:999::1  ff75::/16      Embedded        Active     -         -
```

**PIM6 state (multicast routes)**:
```
show ipv6 pim state
```

Output:
```
Installed Source           Group            IIF      OIL
1         2001:db8:100::10 ff3e::1234       eth0     eth1, eth2
1         *                ff05::5678       eth0     eth1
```

**Details for a group**:
```
show ipv6 pim state ff3e::1234
```

**Join information**:
```
show ipv6 pim join
```

Output:
```
Interface  Source           Group            State      Uptime     Expire   Prune
eth1       2001:db8:100::10 ff3e::1234       JOIN       00:15:23   00:00:45 -
eth0       *                ff05::5678       JOIN       00:10:12   00:00:38 -
```

**BSR information**:
```
show ipv6 pim bsr
```

Output:
```
PIM6 Bootstrap Information
Current BSR Address: 2001:db8:100::1
Priority: 100
Hash Mask Length: 126
Expires: 00:01:45

Candidate BSR Address: 2001:db8:100::1
  Priority: 100
  Hash Mask Length: 126
```

**MLD groups**:
```
show ipv6 mld groups
```

Output:
```
Interface        Address                    Group                   Uptime    Expires
eth1             2001:db8:3::1              ff3e::1234              00:05:23  00:04:12
eth1             2001:db8:3::1              ff05::5678              00:03:45  00:04:18
```

**MLD interfaces**:
```
show ipv6 mld interface
```

Output:
```
Interface  State  Address            Version  Querier         Query Timer  Uptime
eth0       up     fe80::1            2        fe80::1         00:01:15     00:20:34
eth1       up     fe80::2            2        fe80::2         00:00:58     00:20:34
```

**MLD interface details**:
```
show ipv6 mld interface eth1
```

Output:
```
Interface eth1:
  State: up
  Link-local Address: fe80::2
  Version: 2
  Querier: fe80::2 (local)
  Query Interval: 125s
  Query Timer: 00:00:58
  Other Querier Present Timer: 00:00:00
  Startup Query Interval: 31s
  Startup Query Count: 2
  Last Member Query Interval: 1000ms
  Last Member Query Count: 2
  Uptime: 00:20:34
```

**MLD sources**:
```
show ipv6 mld sources
```

Output (for MLDv2 SSM):
```
Interface  Group           Source           Timer    Flags
eth1       ff3e::1234      2001:db8:100::10 00:04:15 I
```

**IPv6 Multicast Routing Table**:
```
show ipv6 mroute
```

Output:
```
Source           Group            Proto  Input      Output     Packets  Bytes
2001:db8:100::10 ff3e::1234       PIM6   eth0       eth1       15234    45678901
                                                     eth2       12456    37890123
*                ff05::5678       PIM6   eth0       eth1       5678     12345678
```

### Management Commands

**Restart PIM6**:
```
restart pim6
```

**Clear PIM6 interfaces**:
```
clear ipv6 pim interfaces
```

**Clear PIM6 oil (Outgoing Interface List)**:
```
clear ipv6 pim oil
```

## Troubleshooting

### Neighbors do not come up

**Problem**: PIM6 neighbors are not visible.

**Checks**:

1. **PIM6 enabled on the interfaces**:
   ```
   show ipv6 pim interface
   ```

2. **IPv6 connectivity**:
   ```
   ping6 2001:db8:10::2
   ```

3. **PIM Hello on the wire**:
   ```
   tcpdump -i eth0 -vv ip6 proto 103
   ```

   You should see PIM Hello on ff02::d.

4. **Firewall blocking PIM**:
   ```
   set firewall ipv6 input filter rule 100 action accept
   set firewall ipv6 input filter rule 100 protocol pim
   commit
   ```

5. **Different Hello intervals**:
   Make sure the Hello interval matches on both ends.

6. **MTU issues**:
   ```
   show interfaces ethernet eth0
   ```

   Check that the MTU is sufficient for IPv6 PIM packets.

### RP does not resolve

**Problem**: RP information is missing.

**Checks**:

1. **Static RP is configured**:
   ```
   show ipv6 pim rp-info
   ```

   It should show the RP address.

2. **RP is the same on all routers**:
   Check the configuration on all PIM6 routers:
   ```
   show protocols pim6 rp
   ```

3. **BSR is working**:
   ```
   show ipv6 pim bsr
   ```

   It should show the current BSR.

4. **C-RP Advertisement reaches the BSR**:
   ```
   tcpdump -i eth0 -vv 'ip6 proto 103 and dst ff02::d'
   ```

5. **Embedded RP format is correct**:
   Check that the group is in the ff7x::/16 format and contains a valid RP prefix.

### Traffic does not reach the receivers

**Problem**: Clients are subscribed, but do not receive multicast traffic.

**Checks**:

1. **MLD groups are active**:
   ```
   show ipv6 mld groups
   ```

2. **PIM Join was sent**:
   ```
   show ipv6 pim join
   ```

   You should see a (*,G) or (S,G) Join.

3. **Multicast routing table**:
   ```
   show ipv6 mroute
   ```

   There should be an entry for the group.

4. **PIM state**:
   ```
   show ipv6 pim state
   ```

   Check the IIF and OIL.

5. **Traffic on the incoming interface**:
   ```
   tcpdump -i eth0 -n 'ip6 and dst ff3e::1234'
   ```

6. **RPF check passes**:
   ```
   show ipv6 route 2001:db8:100::10
   ```

   The unicast route to the source should point to the IIF used for multicast.

7. **Firewall allows multicast**:
   ```
   set firewall ipv6 input filter rule 120 action accept
   set firewall ipv6 input filter rule 120 destination address ff00::/8
   commit
   ```

### SSM does not work

**Problem**: SSM groups do not receive traffic.

**Checks**:

1. **Group is in the SSM range**:
   It must be ff3x::/32 (for example ff3e::1234).

2. **MLDv2 is enabled**:
   ```
   show ipv6 mld interface
   ```

   The version must be 2.

   If not:
   ```
   set protocols pim6 interface eth1 mld version 2
   commit
   ```

3. **Client uses a source-specific join**:
   On Linux:
   ```bash
   smcroute -j eth0 2001:db8:100::10 ff3e::1234
   ```

4. **(S,G) state exists**:
   ```
   show ipv6 pim state ff3e::1234
   ```

   There should be an (S,G) entry, not (*,G).

5. **RP is not configured for SSM**:
   SSM does not require an RP. If there is an RP configuration for ff3x::/32, remove it:
   ```
   delete protocols pim6 rp address <ipv6> group ff3e::/32
   commit
   ```

### Register packets do not reach the RP

**Problem**: The source is active, but the RP does not receive Register.

**Checks**:

1. **DR is determined correctly**:
   ```
   show ipv6 pim interface eth1
   ```

   The PIM DR should be the router connected to the source.

2. **RP address is correct**:
   ```
   show ipv6 pim rp-info
   ```

3. **Unicast route to the RP**:
   ```
   show ipv6 route 2001:db8:100::1
   ```

   There should be a route to the RP.

4. **Register on the wire**:
   ```
   tcpdump -i eth0 -vv 'ip6 proto 103 and dst 2001:db8:100::1'
   ```

   You should see Register packets.

5. **Firewall on the RP**:
   ```
   set firewall ipv6 input filter rule 100 action accept
   set firewall ipv6 input filter rule 100 protocol pim
   set firewall ipv6 input filter rule 100 source address 2001:db8::/16
   commit
   ```

### High CPU from PIM6

**Problem**: High CPU load on the router.

**Causes and solutions**:

1. **Too many (S,G) entries**:
   ```
   show ipv6 pim state | wc -l
   ```

   Consider moving to SSM or increasing resources.

2. **Frequent Join/Prune**:
   Increase the Join/Prune interval:
   ```
   set protocols pim6 join-prune-interval 120
   commit
   ```

3. **Too frequent Hello**:
   Increase the Hello interval:
   ```
   set protocols pim6 interface eth0 hello 60
   commit
   ```

4. **Many MLD Queries**:
   Increase the MLD interval:
   ```
   set protocols pim6 interface eth1 mld interval 125
   commit
   ```

5. **Multicast traffic processed by the CPU**:
   Check hardware offloading:
   ```
   ethtool -k eth0 | grep offload
   ```

## Monitoring and logging

### Continuous Monitoring

**Monitoring PIM6 neighbors**:
```
watch -n 5 'show ipv6 pim neighbor'
```

**Monitoring multicast routes**:
```
watch -n 10 'show ipv6 mroute'
```

**Monitoring MLD groups**:
```
watch -n 5 'show ipv6 mld groups'
```

**Packet capture for PIM6**:
```
tcpdump -i eth0 -vv ip6 proto 103
```

**Packet capture for MLD**:
```
tcpdump -i eth1 -vv 'icmp6 and (ip6[40] == 130 or ip6[40] == 131 or ip6[40] == 132 or ip6[40] == 143)'
```

**Packet capture for multicast traffic**:
```
tcpdump -i eth1 -n 'ip6 and dst net ff00::/8'
```

**A specific group**:
```
tcpdump -i eth1 -n 'ip6 and dst ff3e::1234'
```

### Logging

**System logs**:
```
show log tail 100 | match pim6
```

**Syslog for protocols**:
```
set system syslog global facility protocols level info
commit
```

**External syslog**:
```
set system syslog host 2001:db8:100::100 facility protocols level info
set system syslog host 2001:db8:100::100 port 514
commit
```

**Debug logging** (for troubleshooting):
```
set system syslog global facility protocols level debug
commit
```

**Caution**: Debug can generate a large volume of logs.

After troubleshooting, revert:
```
set system syslog global facility protocols level info
commit
```

## Best practices

### Network design

1. **RP placement**:
   - Place the RP at the center of the network to minimize latency
   - Use a loopback for the RP address (stability)
   - Consider redundancy with BSR + multiple C-RPs

2. **SSM vs SM**:
   - Use SSM (ff3x::/32) where possible
   - SM only for Any-Source Multicast
   - SSM does not require an RP and is more efficient

3. **Embedded RP vs Static RP**:
   - Embedded RP to simplify configuration
   - Static RP for full control
   - BSR for dynamic RP in large networks

4. **Scope selection**:
   - ff02::/16 - Link-local (single hop only)
   - ff05::/16 - Site-local (within a site)
   - ff08::/16 - Organization-local (the whole organization)
   - ff0e::/16 - Global (the entire Internet)

### Configuration

1. **DR Priority**:
   - Set a high DR priority on the router closest to the source
   - Controls who sends Register to the RP

2. **Hello Interval**:
   - The default of 30 seconds is suitable for most networks
   - Decrease it for faster convergence (CPU load)
   - Increase it for stable networks with slow links

3. **MLD Version**:
   - Use MLDv2 for SSM support
   - MLDv1 only for legacy devices

4. **PIM6 on all interfaces**:
   - Enable PIM6 on all interfaces participating in multicast
   - Disable MLD on transit/upstream interfaces

### Security

1. **Firewall for PIM6**:
   ```
   set firewall ipv6 input filter rule 100 action accept
   set firewall ipv6 input filter rule 100 protocol pim
   set firewall ipv6 input filter rule 100 source address 2001:db8::/16
   ```

2. **Restricting multicast groups**:
   ```
   set firewall ipv6 input filter rule 120 action accept
   set firewall ipv6 input filter rule 120 destination address ff3e::/32
   set firewall ipv6 input filter rule 120 description 'Allow only company SSM'
   ```

3. **Rate limiting for MLD**:
   ```
   set firewall ipv6 input filter rule 110 action accept
   set firewall ipv6 input filter rule 110 protocol ipv6-icmp
   set firewall ipv6 input filter rule 110 icmpv6 type 130-132
   set firewall ipv6 input filter rule 110 limit rate 10/second
   ```

4. **Drop unknown multicast**:
   ```
   set firewall ipv6 input filter rule 999 action drop
   set firewall ipv6 input filter rule 999 destination address ff00::/8
   set firewall ipv6 input filter rule 999 description 'Drop unknown multicast'
   ```

### Performance

1. **SPT Switchover**:
   - By default, VyOS switches to the SPT immediately
   - To reduce load on the RP, you can stay on the shared tree:
   ```
   set protocols pim6 spt-switchover infinity-and-beyond
   ```

2. **Register Suppression**:
   - Increase it to reduce the load on the DR:
   ```
   set protocols pim6 register-suppress-time 120
   ```

3. **Hardware Offloading**:
   - Enable it where available for multicast forwarding
   - Check:
   ```
   ethtool -k eth0 | grep offload
   ```

4. **Resource monitoring**:
   ```
   show system resources
   show ipv6 pim state | wc -l
   ```

## Integration with other protocols

### PIM6 + OSPFv3

**Scenario**: OSPFv3 for unicast, PIM6 for multicast.

```
# OSPFv3
set protocols ospfv3 area 0 interface eth0
set protocols ospfv3 area 0 interface eth1
set protocols ospfv3 parameters router-id 10.0.0.1

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 rp address 2001:db8:100::1

commit
```

**Important**: PIM6 uses OSPFv3 unicast routes for the RPF check.

### PIM6 + BGP

**Scenario**: BGP for IPv6 unicast, PIM6 for multicast.

```
# BGP
set protocols bgp system-as 65001
set protocols bgp neighbor 2001:db8:10::254 address-family ipv6-unicast
set protocols bgp neighbor 2001:db8:10::254 remote-as 65000

# PIM6
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 rp address 2001:db8:100::1

commit
```

**Important**: BGP routes are used for the RPF check in PIM6.

### PIM6 + VPN (IPsec/WireGuard)

**Scenario**: Multicast through a VPN tunnel.

**IPsec with VTI**:
```
# VTI interface
set interfaces vti vti0 address 2001:db8:999::1/64

# PIM6 on VTI
set protocols pim6 interface vti0

# RP
set protocols pim6 rp address 2001:db8:100::1

commit
```

**WireGuard**:
```
# WireGuard interface
set interfaces wireguard wg0 address 2001:db8:888::1/64

# PIM6 on WireGuard
set protocols pim6 interface wg0

commit
```

**Important**: Multicast over VPN can have a performance impact.

### PIM6 + IPv4 (Dual Stack)

**Scenario**: PIM for IPv4 and PIM6 for IPv6 simultaneously.

```
# PIM for IPv4
set protocols pim interface eth0
set protocols pim interface eth1
set protocols pim rp address 10.0.0.1

# PIM6 for IPv6
set protocols pim6 interface eth0
set protocols pim6 interface eth1
set protocols pim6 rp address 2001:db8:100::1

commit
```

**Use case**:
- Dual-stack multicast
- Migration from IPv4 to IPv6
- Legacy applications (IPv4) + new ones (IPv6)

## Comparing PIM6 with other solutions

### PIM6 vs IGMP Proxy for IPv6

| Characteristic | PIM6 | IGMP/MLD Proxy |
|---------------|------|----------------|
| Complexity | High | Low |
| Topology | Any | Simple (tree) |
| Scalability | High | Limited |
| RP required | Yes (SM) | No |
| Redundancy | Full | Limited |
| Use case | Core/Data center | Edge/Branch |

**When to use PIM6**:
- Complex topology
- Many sources
- Data center multicast
- Redundancy required

**When to use MLD Proxy**:
- Simple topology (single source)
- Branch office
- IPTV from a provider
- Limited resources

### PIM6-SM vs PIM6-SSM

| Characteristic | PIM6-SM | PIM6-SSM |
|---------------|---------|----------|
| RP required | Yes | No |
| Groups | ff00::/8 (except ff3x::/32) | ff3x::/32 |
| (*,G) tree | Yes | No |
| (S,G) tree | Yes | Yes |
| Complexity | High | Low |
| Security | Medium | High |
| MLD Version | MLDv1/v2 | MLDv2 |

**When to use PIM6-SM**:
- Any-Source Multicast
- Many dynamic sources
- Legacy applications

**When to use PIM6-SSM**:
- Known sources
- Video distribution
- IPTV, streaming
- Improved security

## Automation and scripts

### Monitoring script

**Bash script to check PIM6 neighbors**:
```bash
#!/bin/bash

# pim6-monitor.sh
# Monitor PIM6 neighbors

LOG_FILE="/var/log/pim6-monitor.log"
EXPECTED_NEIGHBORS=2

check_neighbors() {
    local neighbor_count=$(vtysh -c "show ipv6 pim neighbor" | grep -c "eth0")

    if [ "$neighbor_count" -lt "$EXPECTED_NEIGHBORS" ]; then
        echo "$(date): WARNING - Only $neighbor_count neighbors, expected $EXPECTED_NEIGHBORS" >> "$LOG_FILE"
        return 1
    else
        echo "$(date): OK - $neighbor_count neighbors present" >> "$LOG_FILE"
        return 0
    fi
}

check_neighbors

vtysh -c "show ipv6 pim neighbor"
vtysh -c "show ipv6 pim interface"
```

**Installing in cron**:
```bash
*/5 * * * * /usr/local/bin/pim6-monitor.sh
```

### RP failover script

**Script to check RP availability**:
```bash
#!/bin/bash

# rp-watchdog.sh
# Check the RP and switch to the backup

PRIMARY_RP="2001:db8:100::1"
BACKUP_RP="2001:db8:100::2"
LOG_FILE="/var/log/rp-watchdog.log"

check_rp() {
    if ping6 -c 3 -W 2 "$PRIMARY_RP" > /dev/null 2>&1; then
        return 0
    else
        return 1
    fi
}

if ! check_rp; then
    echo "$(date): Primary RP $PRIMARY_RP unreachable, switching to backup" >> "$LOG_FILE"

    vtysh << EOF
configure terminal
protocols pim6 rp address $BACKUP_RP
commit
save
exit
EOF

    echo "$(date): Switched to backup RP $BACKUP_RP" >> "$LOG_FILE"
else
    echo "$(date): Primary RP $PRIMARY_RP is reachable" >> "$LOG_FILE"
fi
```

## References and resources

### RFC Documents

- **RFC 4601** - Protocol Independent Multicast - Sparse Mode (PIM-SM): Protocol Specification
- **RFC 7761** - Protocol Independent Multicast - Sparse Mode (PIM-SM): Protocol Specification (update)
- **RFC 3810** - Multicast Listener Discovery Version 2 (MLDv2) for IPv6
- **RFC 2710** - Multicast Listener Discovery (MLD) for IPv6
- **RFC 3956** - Embedding the Rendezvous Point (RP) Address in an IPv6 Multicast Address
- **RFC 4607** - Source-Specific Multicast for IP
- **RFC 5059** - Bootstrap Router (BSR) Mechanism for Protocol Independent Multicast (PIM)
- **RFC 4291** - IP Version 6 Addressing Architecture

### VyOS Documentation

- [VyOS PIM6 Documentation](https://docs.vyos.io/en/latest/configuration/protocols/pim6.html)
- [VyOS PIM Documentation](https://docs.vyos.io/en/latest/configuration/protocols/pim.html)
- [VyOS IPv6 Configuration](https://docs.vyos.io/en/latest/configuration/interfaces/index.html)

### Useful tools

- **FRRouting (FRR)** - the routing suite used by VyOS for PIM6
- **smcroute** - Static multicast routing tool
- **iperf3** - Network performance testing (multicast mode)
- **tcpdump** - Packet capture
- **Wireshark** - Packet analyzer
- **VLC** - Media player with multicast support

### Community

- [VyOS Forum](https://forum.vyos.io/)
- [VyOS Phabricator](https://vyos.dev/)
- [GitHub VyOS](https://github.com/vyos)
- [FRRouting GitHub](https://github.com/FRRouting/frr)

## Next steps

After configuring PIM6, we recommend studying:

- **[PIM (IPv4)](/docs/vyos/routing/vyos-pim)** - for IPv4 multicast
- **[IGMP Proxy](/docs/vyos/routing/vyos-igmp)** - for simple IPv4 multicast scenarios
- **[OSPFv3](/docs/vyos/routing/vyos-ospf/)** - for IPv6 unicast routing
- **[BGP](/docs/vyos/routing/vyos-bgp/)** - for IPv6 BGP routing
- **[Firewall](/docs/vyos/firewall/vyos-firewall/)** - for protecting multicast networks
- **[QoS](/docs/vyos/qos/)** - for prioritizing multicast traffic

## Conclusion

PIM6 provides efficient multicast routing in IPv6 networks. Proper RP configuration, using SSM for known sources, and integration with MLD ensure stable operation of modern multicast applications in Yandex Cloud and VK Cloud.

**Key takeaways**:
- PIM6 works with MLD instead of IGMP
- An RP is required for PIM6-SM, but not for SSM
- SSM (ff3x::/32) is recommended for most scenarios
- Embedded RP simplifies configuration
- BSR provides dynamic distribution of RP information
- Firewall and security are critical for production
- Monitoring neighbors, the RP, and multicast routes is mandatory

