相关疑难解决方法(0)

在 libvirt / KVM 中将端口转发给来宾

使用 NAT 时,如何将运行 libvirt/KVM 的服务器上的端口转发到 VM 上的指定端口?

例如,主机的公共 IP 为 1.2.3.4。我想将端口 80 转发到 10.0.0.1,将端口 22 转发到 10.0.0.2。

我假设我需要添加 iptables 规则,但我不确定在哪里合适以及应该指定什么。

iptables -L 的输出

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain 
ACCEPT     udp  --  anywhere             anywhere            udp dpt:bootps 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:bootps 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             10.0.0.0/24         state RELATED,ESTABLISHED 
ACCEPT     all  --  10.0.0.0/24 …
Run Code Online (Sandbox Code Playgroud)

ubuntu nat port-forwarding libvirt kvm-virtualization

39
推荐指数
3
解决办法
8万
查看次数