Skip to content

Commit 82013c6

Browse files
committed
feat:添加端口占用查询说明
1 parent 7ee3262 commit 82013c6

File tree

3 files changed

+142
-21
lines changed

3 files changed

+142
-21
lines changed

docs/en/guide/oneclickvirt/oneclickvirt_qa.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,58 @@ Commonly encountered in source code deployment, Dockerfile, and Docker Compose d
9999

100100
Frequently observed in frontend compilation errors on ARM architectures
101101

102-
Directly deploy using pre-compiled Docker container images or binary files (most reliable approach)
102+
Directly deploy using pre-compiled Docker container images or binary files (most reliable approach)
103+
104+
105+
## Some commands cannot detect NAT mapping rules for Incus and LXD.
106+
107+
This is normal behavior.
108+
109+
Incus/LXD port mapping defaults to **kernel-level NAT (DNAT + FORWARD)** and **does not create port listening processes on the host machine**.
110+
Therefore, traditional port occupancy tools typically **will not show any results**.
111+
112+
For example, the following commands will **not detect host port usage**:
113+
114+
```shell
115+
ss -lntup
116+
lsof -i
117+
netstat -lntp
118+
```
119+
120+
Only by running:
121+
122+
```shell
123+
incus config device show instance1
124+
```
125+
126+
or:
127+
128+
```shell
129+
lxd config device show instance1
130+
```
131+
132+
to view configured port mapping rules, as traffic bypasses the host and forwards directly externally.
133+
134+
The correct method to check port mappings is to examine nftables rules
135+
136+
```shell
137+
nft list ruleset
138+
```
139+
140+
or view only the NAT table:
141+
142+
```shell
143+
nft list table ip nat
144+
```
145+
146+
On systems using `iptables`, use:
147+
148+
```shell
149+
iptables -t nat -L
150+
```
151+
152+
If traffic is flowing in or out, inspect actual connection states with:
153+
154+
```shell
155+
conntrack -L | grep <port>
156+
```

docs/guide/oneclickvirt/oneclickvirt_qa.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,63 @@ internal error, please report: running “lxd.lxc” failed: cannot create trans
9494

9595
最终还是需要在限制实例数量的时候,慎重考虑节点的性能,较弱或者限制较多的节点,建议不要开设过多实例
9696

97-
## 自编译出现问题
97+
## 自编译出现依赖缺失或者兼容性问题
9898

9999
常见于 源码部署、Dockerfile、DockerCompose 方式部署
100100

101101
常见于 ARM 架构下前端编译出错
102102

103-
直接使用 预编译的Docker容器镜像 或 直接使用二进制文件部署(最稳妥)
103+
直接使用 预编译的Docker容器镜像 或 直接使用二进制文件部署(最稳妥)
104+
105+
## incus 和 lxd 进行 NAT 映射一些命令查不到映射规则
106+
107+
这是正常现象。
108+
109+
Incus / LXD 的端口映射默认使用 **内核态 NAT(DNAT + FORWARD)** 实现,并 **不会在宿主机上创建端口监听进程**
110+
因此,使用传统的端口占用查询工具通常**无法看到任何结果**
111+
112+
例如,以下命令都 **查不到宿主机端口占用**
113+
114+
```shell
115+
ss -lntup
116+
lsof -i
117+
netstat -lntp
118+
```
119+
120+
只有通过:
121+
122+
```shell
123+
incus config device show 实例1
124+
```
125+
126+
或:
127+
128+
```shell
129+
lxd config device show 实例1
130+
```
131+
132+
才能看到已配置的端口映射规则,因为流量不过宿主机直接对外转发。
133+
134+
正确的端口映射查找方式是查看 nftables 规则
135+
136+
```shell
137+
nft list ruleset
138+
```
139+
140+
或仅查看 NAT 表:
141+
142+
```shell
143+
nft list table ip nat
144+
```
145+
146+
在使用 `iptables` 的系统中可使用:
147+
148+
```shell
149+
iptables -t nat -L
150+
```
151+
152+
如果有流量进出,查看真实连接状态可使用:
153+
154+
```shell
155+
conntrack -L | grep <端口>
156+
```

package-lock.json

Lines changed: 32 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)