系統:RockyLinux
安裝mosquitto
sudo yum install -y epel-release
sudo yum install mosquitto -y
sudo systemctl start mosquitto
sudo systemctl enable mosquitto
打開設定檔更改參數
sudo vi /etc/mosquitto/mosquitto.conf
listener 1883 {IP}
allow_anonymous true
重啟系統
sudo systemctl restart mosquitto
打開防火牆
sudo firewall-cmd --permanent --add-port=1883/tcp
重新載入防火牆
sudo firewall-cmd --reload
測試指令:
mosquitto_pub -h {IP} -t Rocky -m "test"