AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1734024
Accepted
Alex Charters
Alex Charters
Asked: 2022-07-28 15:48:26 +0800 CST2022-07-28 15:48:26 +0800 CST 2022-07-28 15:48:26 +0800 CST

OpenWRT 广播包转发

  • 772

我正在尝试使用 OpenWRT 将广播数据包从一个 LAN 转发到另一个 LAN。我的设置如下所示: 网络设置 (Netgear R6080 路由器,OpenWrt SNAPSHOT r20168-b2681e584c / LuCI Master git-22.203.79817-25dcd0b)

我已经在两个 LAN 之间设置了端口转发,但我计算机上的软件会生成心跳数据包并将它们发送到广播 ip 255.255.255.255,端口 7001,但电路板没有接收到它们。因此,我假设发送到广播 IP 的数据包只能被同一 LAN 上的设备接收,因此我需要以某种方式将它们转发到另一个 LAN。

根据wiki,这是通过 igmpproxy 包完成的。我已经安装了该软件包并将其配置为:

config igmpproxy
        option quickleave 1
        option verbose 3
#       [0-3](none, minimal[default], more, maximum)

config phyint
        option network lan
        option zone lan
        option direction upstream
        list altnet 192.168.0.0/16

config phyint
        option network LAN_ROBOT
        option zone lan_robot
        option direction downstream

重新启动服务后,我没有看到任何迹象表明电路正在接收数据包,这是我从系统日志中看到的输出:

Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Searching for config file at '/var/etc/igmpproxy.conf'
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: Quick leave mode enabled.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: Got a phyint token.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Config for interface br-lan.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got upstream token.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got ratelimit token '0'.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got threshold token '1'.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got altnet token 192.168.0.0/16.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Altnet: Parsed altnet to 192.168/16.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: IF name : br-lan
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Next ptr : 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Ratelimit : 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Threshold : 1
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: State : 1
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Allowednet ptr : 77e0bc50
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: Got a phyint token.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Config for interface eth0.3.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got downstream token.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got ratelimit token '0'.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Config: IF: Got threshold token '1'.
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: IF name : eth0.3
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Next ptr : 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Ratelimit : 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Threshold : 1
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: State : 2
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Allowednet ptr : 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: buildIfVc: Interface lo Addr: 127.0.0.1, Flags: 0x0049, Network: 127/8
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: buildIfVc: Interface eth0.3 Addr: 192.168.200.1, Flags: 0x1043, Network: 192.168.200/24
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: buildIfVc: Interface eth0.2 Addr: 10.0.0.93, Flags: 0x1043, Network: 10.0.0/24
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: buildIfVc: Interface br-lan Addr: 192.168.1.1, Flags: 0x1043, Network: 192.168.1/24
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Found config for eth0.3
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Found config for br-lan
Wed Jul 27 21:04:52 2022 user.notice igmpproxy[10930]: adding VIF, Ix 0 Fl 0x0 IP 0x01c8a8c0 eth0.3, Threshold: 1, Ratelimit: 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]:         Network for [eth0.3] : 192.168.200/24
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Found upstrem IF #0, will assing as upstream Vif 3
Wed Jul 27 21:04:52 2022 user.notice igmpproxy[10930]: adding VIF, Ix 1 Fl 0x0 IP 0x0101a8c0 br-lan, Threshold: 1, Ratelimit: 0
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]:         Network for [br-lan] : 192.168.1/24
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]:         Network for [br-lan] : 192.168/16
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Got 262144 byte buffer size in 0 iterations
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Joining all-routers group 224.0.0.2 on vif 192.168.200.1
Wed Jul 27 21:04:52 2022 user.notice igmpproxy[10930]: Joining group 224.0.0.2 on interface eth0.3
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Joining all igmpv3 multicast routers group 224.0.0.22 on vif 192.168.200.1
Wed Jul 27 21:04:52 2022 user.notice igmpproxy[10930]: Joining group 224.0.0.22 on interface eth0.3
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: SENT Membership query   from 192.168.200.1   to 224.0.0.1
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Sent membership query from 192.168.200.1 to 224.0.0.1. Delay: 10
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Created timeout 1 (#0) - delay 10 secs
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: (Id:1, Time:10)
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: Created timeout 2 (#1) - delay 21 secs
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: (Id:1, Time:10)
Wed Jul 27 21:04:52 2022 user.debug igmpproxy[10930]: (Id:2, Time:21)
Wed Jul 27 21:04:52 2022 user.notice igmpproxy[10930]: RECV Membership query   from 192.168.200.1   to 224.0.0.1
Wed Jul 27 21:04:55 2022 user.notice igmpproxy[10930]: The IGMP message was local multicast. Ignoring.
Wed Jul 27 21:04:56 2022 user.notice igmpproxy[10930]: RECV V2 member report   from 192.168.1.1     to 224.0.0.106
Wed Jul 27 21:04:56 2022 user.notice igmpproxy[10930]: The IGMP message was from myself. Ignoring.
Wed Jul 27 21:04:56 2022 user.notice igmpproxy[10930]: RECV V2 member report   from 192.168.200.1   to 224.0.0.2
Wed Jul 27 21:04:56 2022 user.notice igmpproxy[10930]: The IGMP message was from myself. Ignoring.
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: About to call timeout 1 (#0)
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: Aging routes in table.
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]:
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: Current routing table (Age active routes):
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: -----------------------------------------------------
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: No routes in table...
Wed Jul 27 21:04:59 2022 user.debug igmpproxy[10930]: -----------------------------------------------------
Wed Jul 27 21:04:59 2022 user.notice igmpproxy[10930]: RECV V2 member report   from 192.168.200.1   to 224.0.0.22
Wed Jul 27 21:04:59 2022 user.notice igmpproxy[10930]: The IGMP message was from myself. Ignoring.

我是否正确地处理这件事?我刚刚搞砸了配置吗?

lan openwrt
  • 2 2 个回答
  • 178 Views

2 个回答

  • Voted
  1. Best Answer
    Spiff
    2022-07-28T16:40:47+08:002022-07-28T16:40:47+08:00

    您以错误的方式进行此操作,因为 IGMP 仅用于多播,而不用于广播。该心跳协议应该使用多播(或者更好的是单播),而不是广播。如果您无法修复心跳协议以正确使用多播(或者最好还是单播),那么您需要找到不同的解决方案。

    igmpproxy 包查找显示设备正在尝试订阅多播通信流的 IGMP 消息。igmpproxy 使用这些消息来了解它需要通过路由器代理哪些多播流。顾名思义,广播已经总是可以到达所有设备,而无需任何人订阅。这意味着广播不需要或使用 IGMP 之类的机制来确保它们被传递到所有主机。无论如何,广播总是传递给所有主机。

    • 1
  2. Alex Charters
    2022-07-29T09:17:45+08:002022-07-29T09:17:45+08:00

    Spiff 的回答确实是正确的,并且最正确地回答了我的问题,但我想出了一个解决方法,它完全符合我的需要。不幸的是,由于向后兼容的目的,我无法更改程序,所以我唯一能做的更改就是路由器本身。我的解决方案是让一个 python 脚本在启动时在路由器上运行,它监听广播并将其镜像到另一个 LAN。这是完整的脚本(使用 Python 3.10.5 测试):

    #!/usr/bin/python
    
    import socket
    
    localPort   = 7001
    bufferSize  = 5000
    RobotLanSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) #UDP
    RobotLanSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    RobotLanSocket.bind(('192.168.200.1',0))
    while(True):
        try:
            UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
            UDPServerSocket.bind(('', localPort))
            while(True):
                bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
                message = bytesAddressPair[0]
                address = bytesAddressPair[1]
                clientMsg = "Message from Client:{}".format(message)
                clientIP  = "Client IP Address:{}".format(address)
                RobotLanSocket.sendto(message, ("255.255.255.255", 7001))
        except Exception as e:
            print(str(e))
    

    为了让它在启动时运行,我安装了 coreutils-nohup 以避免在启动脚本时挂起:

    opkg update
    opkg install coreutils-nohup
    

    并将以下内容添加到/etc/rc.local文件中:

    /usr/bin/nohup /bin/broadcast-forwarder.py &
    
    • 0

相关问题

  • LAN-Server 上的 NGINX:通过域而不是 IP 访问 - 可能吗?

  • Coporation LAN(应用IP地址到友好地址)

  • 服务器在互联网上不可见

  • 无法通过 sftp 从 Windows 10 连接到 ubuntu 18.04 目录(全部在 LAN 中)-sftp 在服务器内部工作

  • 什么时候更新路由器上的 OpenWRT?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve