一、前文
EMQX 入門教程——導讀
二、默認端口
- emqx初次安裝和啟動之后,其端口使用情況如下
[root@iZ2ze30dygwd6yh7gu6lskZ home]# netstat -nplt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN 1339/systemd-resolv
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 1110/redis-server *
tcp 0 0 0.0.0.0:4370 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:8883 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:8084 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1402/sshd
tcp 0 0 0.0.0.0:5370 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 7344/emqx
tcp 0 0 0.0.0.0:18083 0.0.0.0:* LISTEN 7344/emqx
tcp6 0 0 :::3306 :::* LISTEN 1298/mysqld
tcp6 0 0 :::5355 :::* LISTEN 1339/systemd-resolv
tcp6 0 0 :::6379 :::* LISTEN 1110/redis-server *
tcp6 0 0 :::8080 :::* LISTEN 7760/java
tcp6 0 0 :::8443 :::* LISTEN 7760/java
tcp6 0 0 :::33060 :::* LISTEN 1298/mysqld
端口 | 描述 |
---|---|
8083 | mqtt ws 監(jiān)聽端口 |
8084 | mqtt wss 監(jiān)聽端口 |
1883 | mqtt tcp 監(jiān)聽端口 |
8883 | mqtt ssl 監(jiān)聽端口 |
18083 | http 監(jiān)聽端口 |
4370 | Erlang 分布端口 |
5370 | 集群 RPC 端口 |
EMQX 4.x 版本的時候還有8081端口,不過在EMQX 5.x時,被合并到18083
三、端口策略
常規(guī)的用法,我們一般使用和開放這兩個端口:
- 1883,設備連接的端口
- 18083,后端API對接端口
因為開放,所以風險。
默認的端口號往往會引來很頻繁的掃描攻擊。
于是,我們要這么做:
- 1883端口改成2883端口(或者其他)
- 18083端口改成28083端口(或者其他)
- 如果是使用云服務器ECS,則別忘了在安全組中添加訪問規(guī)則
- 防火墻設置,1883端口不允許境外IP訪問(Linux系統(tǒng)firewalld防火墻的應用實操(禁止屏蔽海外國外IP訪問))
- 防火墻設置,18083端口只允許本機IP和常用IP訪問(Linux系統(tǒng)firewalld防火墻的應用實操(對外端口開放使用,對內(nèi)端口限制ip地址使用,不使用端口默認關(guān)閉))
四、1883端口修改
配置文件修改/etc/emqx/emqx.conf
listeners.tcp.default {
# bind = "0.0.0.0:1883"
bind = "0.0.0.0:2883"
max_connections = 1024000
}
dashboard {
listeners.http {
# bind = 18083
bind = 28083
}
default_username = "admin"
default_password = "public"
}
五、重啟emqx
emqx restart 好像在5.x版本之后不能用了,只能先stop再start文章來源:http://www.zghlxwxcb.cn/news/detail-780076.html
[root@iZ2ze30dygwd6yh7gu6lskZ emqx]# emqx stop
ok
[root@iZ2ze30dygwd6yh7gu6lskZ emqx]# emqx start
EMQX 5.0.7 is started successfully!
- 到了這一步,可以看到端口已經(jīng)變了過來
[root@iZ2ze30dygwd6yh7gu6lskZ emqx]# netstat -nplt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN 1339/systemd-resolv
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 1110/redis-server *
tcp 0 0 0.0.0.0:4370 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:28083 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:8883 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:8084 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1402/sshd
tcp 0 0 0.0.0.0:5370 0.0.0.0:* LISTEN 9917/emqx
tcp 0 0 0.0.0.0:2883 0.0.0.0:* LISTEN 9917/emqx
tcp6 0 0 :::3306 :::* LISTEN 1298/mysqld
tcp6 0 0 :::5355 :::* LISTEN 1339/systemd-resolv
tcp6 0 0 :::6379 :::* LISTEN 1110/redis-server *
tcp6 0 0 :::8080 :::* LISTEN 7760/java
tcp6 0 0 :::8443 :::* LISTEN 7760/java
tcp6 0 0 :::33060 :::* LISTEN 1298/mysqld
覺得好,就一鍵三連唄(點贊+收藏+關(guān)注)文章來源地址http://www.zghlxwxcb.cn/news/detail-780076.html
到了這里,關(guān)于EMQX 入門教程③——默認端口、端口策略和端口修改的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!