简体   繁体   English

通过Wifi和以太网访问RaspberryPi MQTT Broker,而不会产生干扰

[英]RaspberryPi MQTT Broker access via Wifi and Ethernet without interference

I would like to run an MQTT broker (Mosquitto) on a Pi2. 我想在Pi2上运行MQTT代理(Mosquitto)。

The Pi is connected to two networks, ethernet and wifi. Pi被连接到两个网络,以太网和wifi。 Both networks are not administrated by myself. 这两个网络都不由我自己管理。

Two independent DHCP servers in both networks. 两个网络中都有两个独立的DHCP服务器。

How can I make the the broker available in both networks without interference with the network infrastructure. 如何在不干扰网络基础结构的情况下使代理在两个网络中均可用。

Dumb question ? 愚蠢的问题?

Cheers 干杯

By default mosquitto will bind to the 0.0.0.0 address, this is a special address that represents all IP addresses of the host machine. 默认情况下,mosquitto将绑定到0.0.0.0地址,这是一个特殊的地址,代表主机的所有IP地址。 There is no need to run 2 separate brokers, one will work just fine. 无需运行2个单独的经纪人,一个经纪人就可以正常工作。

This means that the broker will be accessible from both networks. 这意味着可以从两个网络访问代理。 The only problem is that if the pi is getting addresses from DHCP on both interfaces then you will need to know what IP addresses have been assigned in order to access the broker from each network. 唯一的问题是,如果pi在两个接口上都从DHCP获取地址,那么您将需要知道已分配了哪些IP地址才能从每个网络访问代理。

I suggest you look up a program called avahi which can be used to provide a mDNS service allowing you to refer to the pi by a .local domain name from both networks. 我建议您查找一个名为avahi的程序,该程序可用于提供mDNS服务,使您可以通过两个网络中的.local域名来引用pi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM