使用virt-install并设置vnc端口在ipv6上监听。

问题描述 投票:0回答:1

当我尝试用virt-install创建一个新的虚拟机时,我遇到了一个问题。当用virt-install指定vnc时,用这个方法。

--vnc \
--vncport=5905 \
--noautoconsole

虚拟机被创建了,5905在监听,但只是在ipv4上,如图所示。

# netstat -l | grep 5905
tcp        0      0 localhost:5905          0.0.0.0:*               LISTEN

问题是当我尝试使用 "ssh -v -L 5905:localhost:5905 myhost "进行SSH隧道时,我得到一个连接拒绝的错误,因为vnc端口试图从主机的ipv6本地环回接口转发,而vnc端口没有监听。

debug1: Connection to port 5905 forwarding to localhost port 5905 requested.
debug1: channel 3: new [direct-tcpip]
channel 3: open failed: connect failed: Connection refused
debug1: channel 3: free: direct-tcpip: listening port 5905 for localhost port 5905, connect from ::1 port 57890 to ::1 port 5905, nchannels 4

我可以通过将vnc连接到主机的ipv4本地环回来解决这个问题,但我不知道该怎么做。理想情况下,我希望vnc能同时监听ipv4和ipv6。

ssh ipv6 portforwarding kvm vnc
1个回答
0
投票

我可以通过编辑xml在图形参数中加入这个参数来让虚拟机监听ipv6。

<graphics type='vnc' port='5905' autoport='no' listen='localhost'>
  <listen type='address' address='localhost'/>
</graphics>

你可以在virt -install命令中用这个来指定这个参数

--graphics vnc,listen=localhost,port=5905 \

如果你问我,virt -install应该默认为localhost,而不是ipv4的本地环回。

© www.soinside.com 2019 - 2024. All rights reserved.