k8s笔记14
  YKMEHzdP8aoh 2023年11月13日 28 0

摘要:

pimd;pim6sd;igmpproxy;mcjoin;mping;pimd-dense;pimbd

Tip:

  • IGMP 应该仅是链路本地link-local的,而不是路由routed的。 PIM 路由器在共享 LAN 或隧道(例如 GRE)上使用 PIM 消息进行对等。 IGMP 仅适用于发送方和接收方的第 2 层。
  • 负责组播转发的软件是内核,而不是pimd。 pimd 是实际接收和传输 pim 消息的网络服务:the PIM register payload contains the source address, and it appears send_pim() sets them in "sin.sin_addr.s_addr = dst;"
  • 使用基于 Linux 的路由器(带有 pimd)作为静态 RP 作为我们的“核心”路由器。PIM 注册隧道只是 PIM 路由器之间的事务,在面向消费者的边缘,内核根据接口上收到的 IGMP 加入转发多播。 因此,您应该能够在内核中处理多播数据的 NAT。
  • pimreg 隧道

k8s笔记14_github

  • 一旦 pimd 守护进程启动并运行,如果在同一台计算机上创建了新的网络设备/接口,是否有一种方法可以让正在运行的 PIMD 守护进程检测到新的网络接口? 换句话说,一旦 PIMD 应用程序启动,有没有一种方法可以让它在不重新启动的情况下拾取这个新的网络接口?No,问题是,当接口在运行时出现和消失时,多播路由器必须更新 UNIX “VIFs”,即虚拟接口。 内核在设置多播路由时使用的抽象。 在多个 UNIX/Linux 变体中维护这一点是一项艰巨的任务。
  • 当 pimd 启动时,它会重新加载配置并丢弃现有流量。建议 pimd 用户不要尝试使用 NAT 来运行它,它不是为此设计的。
  • pimd 目前无法在配置中添加静态组成员身份之类的内容。
  • igmpproxy:使用 Docker 网络,在运行时动态创建虚拟接口。 这使得无法为它们创建 igmpproxy 配置。因为IP地址不是接口的(唯一)标识符,并且可能会发生变化, 而且igmpproxy运行在网络接口上,因此需要指定接口,因此使接口名称可预测而不是随机的。目前 igmpproxy 无法使用 Docker 网络。
  • SMCRoute: 使用 smcroute 时,它知道预运行时您想要什么规则,因此在流量进入路由器之前,它已经设置了多播路由。the 20 group MAX is only just for the daemon to act as a layer-2 client, sending IGMP join on behalf of the client on "the other side". If you can direct all multicast to your router using other means, e.g. setting "router port" or similar on switches or routers on the eth0 side, then you won't need the SMCRoute mgroup rows. (troglobit I fixed up my own tool, verified it outside of Docker and then used it as sink for 250 groups in a container

1、pim6sd是IPv6的PIM协议无关多播路由守护进程,支持任意源 Any-Source和特定源Source-Specific的多播,也称为PIM-SM和PIM-SSM。

  • pim6sd 自动将自身配置为在所有支持多播的接口interfaces(IFF_MULTICAST flag)上转发 forward,即设置了 IFF_MULTICAST 标志的接口(不包括excluding the "loopback interface" and interaces that do not have an IPv6 address)。
  • 如果多播组地址在SSM范围内(ff20::/12和ff30::/12),则pim6sd将充当SSM路由守护进程,
  • pim6sd必须在IPv6路由器上使用。请确保使用sysctl将net.inet6.ip6.forwarding变量设置为1(# sysctl -w net.ipv6.conf.all.forwarding=1)。pim6sd要求运行守护进程的节点具有IPv6全局地址。pim6sd does not work properly when interface is dynamically added or deleted (e.g. ifconfig gif0 create).
git clone https://github.com/troglobit/pim6sd.git
cd pim6sd/
./autogen.sh
./configure && make
sudo make install-strip
# sysctl -w net.ipv6.conf.all.forwarding=1
# pim6sd -f  /etc/pim6sd.conf -n -d all
-d  Specify debug level, Use -d all to enable all debug levels.
-n  Do not become daemon, run in foreground.
debug level 0xffffffffffffffff:......
17:46:42.132 pim6sd version 2.1.0-beta1 starting
17:46:42.133 Getting vifs from /etc/pim6sd.conf
17:46:42.134 Getting vifs from kernel
17:46:42.137 Installing lo (::1 on subnet ::1/128) ,as vif #1 - rate = 0
17:46:42.137 Installing enp4s0f0 (fe80::f3a8:9406:a5a8:f964 on subnet fe80::/64) ,as vif #2 - rate = 0
17:46:42.137 Installing calicf76ff9b329 (fe80::ecee:eeff:feee:eeee on subnet fe80::/64) ,as vif #3 - rate = 0
17:46:42.138 Installing calie1fca5ba8d1 (fe80::ecee:eeff:feee:eeee on subnet fe80::/64) ,as vif #24 - rate = 0
17:46:42.138 There's no global address available
# ip a
2: enp4s0f0:......inet6 fe80::f3a8:9406:a5a8:f964/64 scope link noprefixroute 
18: calib1f2f82ecb4@if4:......inet6 fe80::ecee:eeff:feee:eeee/64 scope link
  • 报错“There's no global address available” IPv6地址中分为本地链路地址(Link-Local Address)与全局单播地址(Global Address):本地链路地址根据mac等信息通过指定算法得到,不需要从路由器获取,以fe80:开头。全局单播地址从需要和路由器进行协商获取,可以与公网通信。配置IPv6 global address后运行OK,但是pim6stat显示Multicast Interface Table都是IPv6的地址。
# vim etc\sysconfig\network-scripts\ifcfg-enp4s0f0  //配置IPv6 global address
IPV6ADDR=2a01:1b0:5389:4::22f2
[root@k8s-node05 ~]# ip a
2: enp4s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether ac:16:2d:b0:df:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.31.218/24 brd 192.168.31.255 scope global enp4s0f0
       valid_lft forever preferred_lft forever
    inet6 2a01:1b0:5389:4::22f2/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::ae16:2dff:feb0:df0c/64 scope link 
       valid_lft forever preferred_lft forever
# pim6sd -f  /etc/pim6sd.conf -n -d all
[root@k8s-node05 ~]#  pim6stat
Multicast Interface Table
 Mif   PhyIF Local-Address/Prefixlen                     Scope GenID    Flags         
  0       lo ::1/128                                     0     0        DISABLED
             Timers: PIM hello = 0:00, MLD query = 0:00
             possible MLD version = 1 
  1   enp4s0f0 fe80::ae16:2dff:feb0:df0c/64                2     207e0ffe PIM QRY
             2a01:1b0:5389:4::22f3/64                    0    
             Timers: PIM hello = 0:20, MLD query = 0:55
             possible MLD version = 1 
  2   cali1f9a46be733 fe80::ecee:eeff:feee:eeee/64                15    54e9db48 QRY NO-NBR DR
             Timers: PIM hello = 0:20, MLD query = 0:55
             possible MLD version = 1

2、PIMD:将一些依赖于多播的应用程序迁移到 Docker 中碰到的问题。(尝试 mrouted 时,也遇到了类似的问题,但smcroute成功了),进而可以迁移到K8s。

  • 希望使用 pimd 将多播数据包从upstream 网络路由到docker bridge上的本地网络。hung up
  • docker 主机上启动 PIMD,没有在容器中得到任何组播内容(容器位于docker bridge上),但 eth0 上的 tcpdump 显示数据包传入,它们似乎没有被forwarded/routed 到容器。
  •  disabling multicast_snooping on the docker0 bridge
  • The Linux bridge (here docker0) does not always play nice with Layer-2 multicast (IGMP),为了让 pimd 考虑安装从 eth0 到 docker0 的多播路由,它需要:
  • To hear the client respond to an IGMP query it sent out (layer-2),
  • To actually have the desired multicast on eth0, or know of an upstream PIM-SM router (rendez-vous point) that has it to send a PIM join to (layer-3)。
  • multicast routing takes place not on regular interfaces, but on "VIF"'s ... virtual interfaces. These are unique to multicast and are enumerated when the multicast routing daemon (smcroute/pimd/mrouted) starts up. 就 pimd 而言,当允许将接口枚举为 VIF 时有点挑剔,这不仅仅MULTICAST interface flag。 检查 cat /proc/net/ip_mr_vif 的输出,确保已为 docker0 以及 eth0 创建 VIF。
# cat /proc/net/ip_mr_vif
Interface      BytesIn  PktsIn  BytesOut PktsOut Flags Local    Remote
 0 enp4s0f0          0       0         0       0 00000 DA1FA8C0 00000000
 1 virbr0            0       0         0       0 00000 017AA8C0 00000000
 2 pimreg            0       0         0       0 00004 DA1FA8C0 00000000
  • pimd -r show the routing tables;在文件 /proc/net/ip_mr_cache 中验证哪些路由实际写入了内核...可以使用 ip mroute 工具查看更可读的版本。(shared with SMCRoute)
# more /proc/net/ip_mr_cache
Group    Origin   Iif     Pkts    Bytes    Wrong Oifs
010101EB 11041CC0 -1         0        0        0
010001E1 B405A8C0 -1         0        0        0
#  ip mroute 
(192.168.5.50, 225.1.0.2)        Iif: unresolved  State: unresolved
(196.168.2.223, 233.1.21.1)      Iif: unresolved  State: unresolved
  • 测试:k8s-node04上运行./mc_svcttl ,pimd没有关于组播232.0.0.100的记录;当在k8s-node05上运行./mc_clittl 后,有组播232.0.0.100记录,但是2台宿主机上ip mroute都没有关于组播232.0.0.100的记录。
[root@k8s-node04 /]# pimd -d -f 2>&1 |grep 232.0.0.100
11:05:27.964 Received IGMP v2 Membership Report from 192.168.31.218 to 232.0.0.100
11:05:27.964 accept_group_report(): igmp_src 192.168.31.218 ssm_src 232.0.0.100 group 232.0.0.100 report_type 22
11:05:27.964 accept_group_report(): Source 232.0.0.100 added to new g:0x24e9b10
11:05:27.964 Set delete timer for group: 232.0.0.100
11:05:27.964 SSM group order from  192.168.31.218 (232.0.0.100,232.0.0.100)
11:05:27.964 create group entry, group 232.0.0.100
11:05:27.964 NETLINK: ask path to 232.0.0.100
11:05:27.964 NO ROUTE found for 232.0.0.100
   0  232.0.0.100     232.0.0.100 
11:05:37.088 Add leaf (232.0.0.100,232.0.0.100)
停止k8s-node05上./mc_clittl的客户端进程后
11:06:30.774 DelVif: Seek source 232.0.0.100, curr=232.0.0.100 (0x24e9b60)
11:06:30.774 DelVif: vif:0(enp4s0f0), (S=232.0.0.100,G=232.0.0.100)
  • A virtual network interface is a mechanism that supports aggregation of network interfaces ("links") into one logical interface unit ("trunk")虚拟网络接口是一种支持将网络接口(“links”)聚合成一个逻辑接口单元(“trunk”)的机制,一旦创建,vif 就与物理网络接口没有区别。 您可以使用 ifconfig 和 netstat 命令等检查和修改统计和配置信息。DelVif: vif:0(enp4s0f0)——multicast routing takes place not on regular interfaces, but on "VIF"'s ... virtual interfaces. These are unique to multicast and are enumerated when the multicast routing daemon (smcroute/pimd/mrouted) starts up。
  • The vif command has been DEPRECATED in favor of the na_ifgrp(1) command.(man1/na_ifgrp(1) manual page (netapp.com)

3、ip neigh命令neighbour/arp tables management操作邻居对象,为共享同一链路的主机在协议地址和链路层地址之间建立绑定。 相邻条目被组织成表。 IPv4 邻居表还有另一个名称:ARP 表。lladdr LLADDRESS(link-layer):the link layer address of the neighbour.  LLADDRESS can also be null。

# ip a 
246: cali97fbeeb99b8@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1480 qdisc noqueue state UP group default 
    link/ether ee:ee:ee:ee:ee:ee brd ff:ff:ff:ff:ff:ff link-netnsid 15
    inet6 fe80::ecee:eeff:feee:eeee/64 scope link 
       valid_lft forever preferred_lft forever
# arp |grep 56:cc:ea:27:62:2a
172.17.54.150            ether   56:cc:ea:27:62:2a   C                     cali97fbeeb99b8
# ip neighbour show 172.17.54.150
172.17.54.150 dev cali97fbeeb99b8 lladdr 56:cc:ea:27:62:2a REACHABLE
#  ip neighbour show dev cali97fbeeb99b8
172.17.54.150 lladdr 56:cc:ea:27:62:2a REACHABLE
fe80::54cc:eaff:fe27:622a lladdr 56:cc:ea:27:62:2a STALE

4、ip-mroute:multicast routing cache management。mroute对象是由用户级 mrouting 守护进程创建的组播路由缓存条目 (例如 pimd 或 mrouted )。由于当前组播路由引擎接口的限制,无法管理性地更改 mroute 对象,因此我们只能显示它们。 未来将取消此限制。

# ip mroute show iif enp4s0f0
(192.168.31.1, 239.255.255.250)  Iif: enp4s0f0   Oifs: pimreg  State: resolved

5、ip-maddress - multicast addresses management,这些命令附加/分离静态链路层多播地址以在接口上侦听。 请注意,不可能静态加入协议多播组。 该命令仅管理链路层地址。(ip-maddress(8) - Linux manual page (man7.org)

6、ip-rule - routing policy database management。ip 规则操作路由策略数据库中的规则,控制路由选择算法。ip rule是管理 路由规则。ip route是管理路由表的

  •  ip rule add to 114.114.114.114 table 10 :这行 表示凡是目的IP是114.114.114.144 就会进入路由表10
  •  ip route add to 114.114.114.114 via 192.168.188.2 table 10 :这行表示 在路由表10增加了路由转发规则 目的地址为   114.114.114.114  走网关 192.168.188.2 出去

7、mping — a simple multicast ping program

mping 是一个易于使用且脚本友好的程序,支持 IPv4 和 IPv6。 与标准 ping 程序类似,但不同的是,多播 ping 的响应是由另一个 mping 发送的。 它用于验证任何 layer-2 bridges (switches)设备中预期的 IGMP/MLD snooping 功能。以及验证静态 (SMCRoute) 或动态(mrouted、pimd、pimd-dense 或 pim6sd)多播路由设置中的多播forwarding。处于路由设置中时,记住调整 TTL 值,并使用 -i IFNAME 设置多播接口,否则内核将使用单播路由表来选择出站接口。

  • mping 目前仅支持任意源组播any-source multicast, ASM (*,G)
echo 2 | sudo tee /proc/sys/net/ipv4/conf/eth0/force_igmp_version
  • 测试,node1和node2的IP不在一个网段,组播测试可以通。
git clone https://github.com/troglobit/mping
make -j5 && make install-strip
node1# mping -s 233.1.1.100 -p 9999 -i enp4s0f0
node2# mping -r 233.1.1.100 -p 9999 -i enp4s0f0

8、mcjoin应用

[root@k8s-node04 ~]# mcjoin -i enp4s0f0 -s 234.1.1.1 -p 9999 //-s Act as sender, sends packets to select groups
[root@k8s-node05 ~]# mcjoin -j 234.1.1.1 -p 9999 //-j Join groups, default unless acting as sender
  • 在宿主机k8s-node04上的pod里运行组播服务程序,宿主机k8s-node04运行mcjoin从cali网卡能收到组播数据,但是物理网卡enp4s0f0收不到。
(130 09:34 tool-5b74f7b55d-4qr5q:/home) ./mc_svcttl 
[root@k8s-node04 home]# mcjoin -i calid98573fcd5b -j 232.0.0.100 -p 8888

9、pimd-dense和pimbd编译make未通过,未正常运行。

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月13日 0

暂无评论

推荐阅读
  MHUUsenkOJj9   2023年11月24日   31   0   0 Dockergithub
  KRsXEGSB49bk   2023年11月19日   30   0   0 gitgithub.net
  YKMEHzdP8aoh   2023年11月13日   29   0   0 github守护程序