当前位置: 首页 > news >正文

bridge-multicast-igmpsnooping

 # 1.topo


 # 2.创建命名空间
 ip netns add ns0
 ip netns add ns1
 ip netns add ns2
 ip netns add ns3

 # 3.创建veth设备
 ip link add ns0-veth0 type veth peer name hn0-veth0
 ip link add ns1-veth0 type veth peer name hn1-veth0
 ip link add ns2-veth0 type veth peer name hn2-veth0
 ip link add ns3-veth0 type veth peer name hn3-veth0

 # 4.veth设备放入命名空间,启动接口
 ip link set ns0-veth0 netns ns0
 ip link set ns1-veth0 netns ns1
 ip link set ns2-veth0 netns ns2
 ip link set ns3-veth0 netns ns3
 ip -netns ns0 link set ns0-veth0 up
 ip -netns ns1 link set ns1-veth0 up
 ip -netns ns2 link set ns2-veth0 up
 ip -netns ns3 link set ns3-veth0 up

 # 5.创建br0,添加接口到br0
 brctl addbr br0
 ip link set br0 up
 brctl addif br0 hn0-veth0
 brctl addif br0 hn1-veth0
 brctl addif br0 hn2-veth0
 brctl addif br0 hn3-veth0

 ip link set dev hn0-veth0 up
 ip link set dev hn1-veth0 up
 ip link set dev hn2-veth0 up
 ip link set dev hn3-veth0 up

 # 7.配置地址
 ip -netns ns0 addr add 1.1.1.10/24 dev ns0-veth0
 ip -netns ns1 addr add 1.1.1.11/24 dev ns1-veth0
 ip -netns ns2 addr add 1.1.1.12/24 dev ns2-veth0
 ip -netns ns3 addr add 1.1.1.13/24 dev ns3-veth0

 # 8.测试
 # 8.1测试iperf
 ip netns exec ns0 iperf -s -u -B 239.1.1.1 -p 5001   //server
 ip netns exec ns1 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.11
 ip netns exec ns2 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.12
 ip netns exec ns3 iperf -c 239.1.1.1 -p 5001 -u -b 0.1m -B 1.1.1.13
 tcpdump -i br0 -e


 # 8.2测试 igmp snooping

 ## bridge开启igmp snooping
 echo 1 > /sys/devices/virtual/net/br0/bridge/multicast_querier //启用 IGMP 查询器功能
 echo 1 > /sys/devices/virtual/net/br0/bridge/multicast_snooping // IGMP Snooping 功能^S
 echo 100 > /sys/devices/virtual/net/br0/bridge/multicast_query_interval //IGMP 查询消息的发送间隔
 echo 4 > /sys/devices/virtual/net/br0/bridge/multicast_query_response_interval

 echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 //关闭ipv6协议栈

 ## 添加组播组
 smcroute -d
 ip netns exec ns1 smcroute -d
 ip netns exec ns1 smcroutectl join ns1-veth0 239.0.0.99  //加入组播组
 ip netns exec ns2 smcroute -d
 ip netns exec ns2 smcroutectl join ns2-veth0 239.0.0.99  //加入组播组

 bridge mdb show br0

 ## 发送组播报文
 //发送组播
 ip netns exec ns0 ip route add 239.0.0.0/8 dev ns0-veth0  添加路由,sendip才发送处理组播报文
 ip netns exec ns0  sendip -p ipv4 -is 1.1.1.10  -id 239.0.0.99 -p udp -us 5000 -ud 5001 -d "Hello, Multicast!" 239.0.0.99

 ## 抓包
 ip netns exec ns1 tcpdump -i ns1-veth0 -e
 ip netns exec ns2 tcpdump -i ns2-veth0 -e
 ip netns exec ns3 tcpdump -i ns3-veth0 -e

 ns1、ns2能收到,ns3收不到。

 # 9.删除
 ip netns del ns0
 ip netns del ns1
 ip netns del ns2
 ip netns del ns3
 ip link set br0 down
 brctl delbr br0

ip link del hn0-veth0
ip link del hn1-veth0
ip link del hn2-veth0
ip link del hn3-veth0


 # 组播
 cat /sys/devices/virtual/net/br0/bridge/multicast_snooping
 cat /proc/net/igmp
 ip maddr show dev br0

 # smcroute
 ip netns exec ns0 smcroute -d  //命名空间开启进程
 smcroute -d  //开启进程
 smcroutectl join br0 224.0.0.99  //加入组播组
 smcroutectl leave br0 224.0.0.99  //离开组播组

 cat /proc/net/igmp
 cat /proc/sys/net/ipv4/conf/all/mc_forwarding

 发送单播报文
 ip netns exec ns0  sendip -p ipv4 -is 1.1.1.10  -id 1.1.12 -p udp -us 5000 -ud 5001 -d "Hello, Multicast!" 1.1.1.12

 # 11.参考
Ubuntu Manpage: smcroute — SMCRoute, a static multicast router

http://www.lryc.cn/news/489722.html

相关文章:

  • git使用(一)
  • Linux环境安装MongoDB
  • Cyberchef使用功能之-多种压缩/解压缩操作对比
  • TypeScript 装饰器都有那些应用场景?如何更快的上手?
  • 堆优化版本的Prim
  • Ubuntu上安装MySQL并且实现远程登录
  • 蓝桥杯每日真题 - 第21天
  • (长期更新)《零基础入门 ArcGIS(ArcMap) 》实验一(下)----空间数据的编辑与处理(超超超详细!!!)
  • NLP论文速读(CVPR 2024)|使用DPO进行diffusion模型对齐
  • 操作系统——揭开盖子
  • 如何在 React 项目中应用 TypeScript?应该注意那些点?结合实际项目示例及代码进行讲解!
  • C++学习第四天
  • 【从零开始的LeetCode-算法】3232. 判断是否可以赢得数字游戏
  • 一种简单高效的RTSP流在线检测方法,不需要再过渡拉流就可以获取设备状态以及对应音视频通道与编码格式
  • 24/11/22 项目拆解 艺术风格转移
  • 数字赋能,气象引领 | 气象景观数字化服务平台重塑京城旅游生态
  • 关于Redux的学习(包括Redux-toolkit中间件)
  • 【无人机】
  • Zabbix7.0.6的容器镜像准备
  • 利用 GitHub 和 Hexo 搭建个人博客【保姆教程】
  • React第四节 组件的三大属性之state
  • MongoDB进阶篇-索引(索引概述、索引的类型、索引相关操作、索引的使用)
  • 使用FFmpeg实现视频与GIF的画中画效果
  • 车载信息安全框架 --- 车载信息安全相关事宜
  • Unreal5从入门到精通之EnhancedInput增强输入系统详解
  • 泛微E9与金蝶云星空的集成方案:实现审批流程与财务管理的无缝对接
  • 理解设计模式与 UML 类图:构建稳健软件架构的基石
  • FastAPI重载不生效?解决PyCharm中Uvicorn无法重载/重载缓慢的终极方法!
  • 最新子比主题zibll8.0开心版源码 无加密无后门
  • 【数据分析】认清、明确