docker 运行方式
因之前使用的是默认指令,无法创建 502 等端口的连接,故此在新创建时候加上了 端口 502
docker run -d --name neuronex -p 8085:8085 -p 502:502 -p 503:503 emqx/neuronex:latest
运行中
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a13f8e95aa23 emqx/neuronex:latest "/usr/bin/entrypoint…" About an hour ago Up 27 minutes 0.0.0.0:502-503->502-503/tcp, :::502-503->502-503/tcp, 0.0.0.0:8085->8085/tcp, :::8085->8085/tcp neuronex
images
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
emqx/neuron latest ccdcdf877afa 9 days ago 280MB
emqx/neuronex latest 9737cb5b2c88 4 weeks ago 991MB
我查询我的iptables net
iptables -vnL -t nat
Chain PREROUTING (policy ACCEPT 1676 packets, 122K bytes)
pkts bytes target prot opt in out source destination
1784 124K DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT 4 packets, 475 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DOCKER all -- * * 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT 1492 packets, 89456 bytes)
pkts bytes target prot opt in out source destination
14 861 MASQUERADE all -- * !docker0 172.17.0.0/16 0.0.0.0/0
0 0 MASQUERADE all -- * !br-1e8fece7d1fb 172.18.0.0/16 0.0.0.0/0
20 1324 MASQUERADE all -- * !br-e841c7dd5fdc 172.19.0.0/16 0.0.0.0/0
0 0 MASQUERADE tcp -- * * 172.19.0.2 172.19.0.2 tcp dpt:3001
0 0 MASQUERADE tcp -- * * 172.19.0.3 172.19.0.3 tcp dpt:1884
0 0 MASQUERADE tcp -- * * 172.19.0.4 172.19.0.4 tcp dpt:8090
0 0 MASQUERADE udp -- * * 172.19.0.6 172.19.0.6 udp dpt:1700
0 0 MASQUERADE tcp -- * * 172.19.0.8 172.19.0.8 tcp dpt:8080
0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2 tcp dpt:9081
0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2 tcp dpt:7001
0 0 MASQUERADE tcp -- * * 172.17.0.2 172.17.0.2 tcp dpt:7000
0 0 MASQUERADE tcp -- * * 172.17.0.3 172.17.0.3 tcp dpt:8085
0 0 MASQUERADE tcp -- * * 172.17.0.3 172.17.0.3 tcp dpt:503
0 0 MASQUERADE tcp -- * * 172.17.0.3 172.17.0.3 tcp dpt:502
Chain DOCKER (2 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- docker0 * 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- br-1e8fece7d1fb * 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0
0 0 DNAT tcp -- !br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0 tcp dpt:3001 to:172.19.0.2:3001
0 0 DNAT tcp -- !br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0 tcp dpt:1884 to:172.19.0.3:1884
0 0 DNAT tcp -- !br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8090 to:172.19.0.4:8090
6 684 DNAT udp -- !br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0 udp dpt:1700 to:172.19.0.6:1700
50 2600 DNAT tcp -- !br-e841c7dd5fdc * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 to:172.19.0.8:8080
45 2340 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9081 to:172.17.0.2:9081
90 4680 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:7001 to:172.17.0.2:7001
2 104 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:7000 to:172.17.0.2:7000
3 156 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8085 to:172.17.0.3:8085
0 0 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:503 to:172.17.0.3:503
5 260 DNAT tcp -- !docker0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:502 to:172.17.0.3:502
然后使用浏览器访问 我的虚拟主机地址为 192.168.1.10
http://192.168.1.10:8083
在南向设备处创建了 Modbus TCP 和 RTU 应用
。
我再我的 PC 中。使用 TCP 连接工具 client方式 去连接 192.168.1.10 端口502
模拟发送数据。
不论是使用access 还是 十六进制的 在监控面板页面都无法收到数据。
打开debug 日志后,里边的内容只有 client 的连接日志,并没有 数据接收日志。
Modbus_Tcp_1.log:
2024-04-25 07:32:21:601 [NOTICE] modbus_tcp.c:102 Modbus_Tcp_1 init success
2024-04-25 07:32:21:602 [NOTICE] modbus_tcp.c:207 config: host: 0.0.0.0, port: 502, mode: 1
2024-04-25 07:32:21:603 [NOTICE] connection.c:751 tcp server listen 0.0.0.0:502 success, fd: 30
2024-04-25 07:32:21:603 [NOTICE] modbus_tcp.c:129 Modbus_Tcp_1 start success
2024-04-25 07:32:39:742 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:1137, fd: 31
2024-04-25 07:33:16:136 [WARN] connection.c:206 replace old client 31 with 32
2024-04-25 07:33:16:136 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:1186, fd: 32
2024-04-25 07:39:58:802 [WARN] connection.c:206 replace old client 32 with 23
2024-04-25 07:39:58:802 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:1645, fd: 23
2024-04-25 07:40:51:064 [WARN] connection.c:206 replace old client 23 with 35
2024-04-25 07:40:51:064 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:1696, fd: 35
2024-04-25 07:58:35:704 [WARN] connection.c:206 replace old client 35 with 31
2024-04-25 07:58:35:704 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:2838, fd: 31
2024-04-25 08:18:04:817 [WARN] connection.c:206 replace old client 31 with 22
2024-04-25 08:18:04:817 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:4126, fd: 22
2024-04-25 08:21:49:521 [WARN] connection.c:206 replace old client 22 with 33
2024-04-25 08:21:49:521 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:4386, fd: 33
2024-04-25 08:22:21:508 [WARN] connection.c:206 replace old client 33 with 22
2024-04-25 08:22:21:509 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:4414, fd: 22
2024-04-25 08:23:42:925 [WARN] connection.c:206 replace old client 22 with 33
2024-04-25 08:23:42:926 [NOTICE] connection.c:227 0.0.0.0:502 accpet new client: 192.168.1.31:4507, fd: 33
2024-04-25 08:26:11:651 [NOTICE] modbus_tcp.c:207 config: host: 192.168.1.10, port: 502, mode: 1
2024-04-25 08:26:11:651 [NOTICE] connection.c:761 tcp server close :502, fd: 30
2024-04-25 08:26:11:652 [ERROR] connection.c:732 tcp bind 192.168.1.10:502 fail, errno: Cannot assign requested address
2024-04-25 08:26:45:746 [NOTICE] modbus_tcp.c:102 Modbus_Tcp_1 init success
2024-04-25 08:26:45:746 [NOTICE] modbus_tcp.c:207 config: host: 192.168.1.10, port: 502, mode: 1
2024-04-25 08:26:45:746 [ERROR] connection.c:732 tcp bind 192.168.1.10:502 fail, errno: Cannot assign requested address
2024-04-25 08:26:45:770 [NOTICE] modbus_tcp.c:129 Modbus_Tcp_1 start success
2024-04-25 08:32:24:576 [NOTICE] modbus_tcp.c:207 config: host: 172.17.0.3, port: 502, mode: 1
2024-04-25 08:32:24:576 [NOTICE] connection.c:751 tcp server listen 172.17.0.3:502 success, fd: 44
2024-04-25 08:32:51:563 [NOTICE] modbus_tcp.c:102 Modbus_Tcp_1 init success
2024-04-25 08:32:51:564 [NOTICE] modbus_tcp.c:207 config: host: 172.17.0.3, port: 502, mode: 1
2024-04-25 08:32:51:564 [NOTICE] connection.c:751 tcp server listen 172.17.0.3:502 success, fd: 26
2024-04-25 08:32:51:596 [NOTICE] modbus_tcp.c:129 Modbus_Tcp_1 start success
2024-04-25 08:33:24:048 [NOTICE] connection.c:227 172.17.0.3:502 accpet new client: 192.168.1.31:5159, fd: 46
2024-04-25 08:36:08:037 [WARN] connection.c:206 replace old client 46 with 31
2024-04-25 08:36:08:037 [NOTICE] connection.c:227 172.17.0.3:502 accpet new client: 192.168.1.31:5329, fd: 31
2024-04-25 08:53:11:322 [WARN] connection.c:206 replace old client 31 with 44
2024-04-25 08:53:11:323 [NOTICE] connection.c:227 172.17.0.3:502 accpet new client: 192.168.1.31:6583, fd: 44
2024-04-25 09:23:21:595 [WARN] connection.c:206 replace old client 44 with 48
2024-04-25 09:23:21:595 [NOTICE] connection.c:227 172.17.0.3:502 accpet new client: 192.168.1.31:8552, fd: 48