思科路由器配置PIM-SM

Hello World, Hello Blog

Posted by Haike Nan on March 31, 2021
拓扑:

配置:

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
!
ip multicast-routing
!开启组播路由
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.1.254 255.255.255.0
 ip pim sparse-mode
!开启pim-sm模式
interface Ethernet0/1
 ip address 192.168.12.1 255.255.255.0
 ip pim sparse-mode
!
interface Ethernet0/2
 ip address 192.168.13.1 255.255.255.0
 ip pim sparse-mode
!
!
router ospf 1
 router-id 1.1.1.1
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.1.254 0.0.0.0 area 0
 network 192.168.12.1 0.0.0.0 area 0
 network 192.168.13.1 0.0.0.0 area 0
!配置底层igp路由
ip pim rp-address 2.2.2.2 override
!静态指定RP

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
!
ip multicast-routing
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
 ip pim sparse-mode
!
interface Ethernet0/1
 ip address 192.168.235.2 255.255.255.0
 ip pim sparse-mode
!
!
router ospf 1
 router-id 2.2.2.2
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.12.2 0.0.0.0 area 0
 network 192.168.235.2 0.0.0.0 area 0
!
ip pim rp-address 2.2.2.2 override
!

R3:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
!
ip multicast-routing
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.13.3 255.255.255.0
 ip pim sparse-mode
!
interface Ethernet0/1
 ip address 192.168.235.3 255.255.255.0
 ip pim sparse-mode
!
!
router ospf 1
 router-id 3.3.3.3
 network 3.3.3.3 0.0.0.0 area 0
 network 192.168.13.3 0.0.0.0 area 0
 network 192.168.235.3 0.0.0.0 area 0
!
ip pim rp-address 2.2.2.2 override

R5:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
!
ip multicast-routing
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.235.5 255.255.255.0
 ip pim sparse-mode
!
interface Ethernet0/1
 ip address 192.168.2.5 255.255.255.0
 ip pim sparse-mode
!
!
router ospf 1
 router-id 5.5.5.5
 network 5.5.5.5 0.0.0.0 area 0
 network 192.168.2.5 0.0.0.0 area 0
 network 192.168.235.5 0.0.0.0 area 0
!
ip pim rp-address 2.2.2.2 override

PC6:

1
2
3
4
5
6
7
8
9
!
interface Ethernet0/0
 ip address 192.168.2.6 255.255.255.0
 ip igmp join-group 239.1.1.6
!路由器模拟PC,加入组播组
!
router ospf 1
 network 192.168.2.6 0.0.0.0 area 0
!

PC7:

1
2
3
4
5
6
7
8
9
10
!
interface Ethernet0/0
 ip address 192.168.2.7 255.255.255.0
 ip igmp join-group 239.1.1.7
 ip igmp join-group 239.1.1.6
!
!
router ospf 1
 network 192.168.2.7 0.0.0.0 area 0
!

PC8:

1
2
3
4
5
6
7
8
9
10
11
!
interface Ethernet0/0
 ip address 192.168.2.8 255.255.255.0
 ip igmp join-group 239.1.1.8
 ip igmp join-group 239.1.1.7
 ip igmp join-group 239.1.1.6
!
!
router ospf 1
 network 192.168.2.8 0.0.0.0 area 0
!
验证:

SERVER ping 239.1.1.6,如图:

注意,因为此实验环境存在MA网络的等价路径,所以第一次ping时会出现双倍数量的包,请多ping几次,待R2和R3声明(assert)谁为该网络的组播转发者后,再查看R1的组播路由表,如图:

发现R1会选择E0/2作为oif,组播包会走右边的R3(R2、R3路径等价,会选择IP地址较大的R3作为转发者),再到R5。

再查看R2、R3的组播路由表,会发现R2上去往239.1.1.6的oif是NULL,R3上去往239.1.1.6的oif是E0/1,与预期相符,如图: