在 Ubuntu 上永久重定向 Mosquitto 双向 MQTT 流量

在 Ubuntu 上永久重定向 Mosquitto 双向 MQTT 流量

我需要在短期内将所有流量从旧的 mosquitto 服务器永久重定向到新的服务器,直到边缘设备上的固件更新完成。根据之前关于流量重定向的一些答案,我尝试使用 iptables:

iptables -t nat -A PREROUTING -p tcp --dport 1883 -j DNAT --to-destination 41.185.48.194:1883
iptables -t nat -A PREROUTING -p tcp --dport 9001 -j DNAT --to-destination 41.185.48.194:9001
iptables -t nat -A POSTROUTING -p tcp -d 41.185.48.194 --dport 9001 -j MASQUERADE
iptables -t nat -A POSTROUTING -p tcp -d 41.185.48.194 --dport 1883 -j MASQUERADE

但规则一旦实施,我就无法获得流量了。

任何帮助,将不胜感激

相关内容