1. 修改ESXi主机的firewall配置
在ESXi主机的/etc/vmware/firewall目录下增加vnc的防火墙配置文件,vnc.xml,内容如下:
/etc/vmware/firewall # cat vnc.xml
<!– FirewallRule for VNC Console –>
<ConfigRoot>
<service>
<id>VNC</id>
<rule id = ‘0000’>
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>5900</begin>
<end>5910</end>
</port>
</rule>
<rule id = ‘0001’>
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>0</begin>
<end>65535</end>
</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>
2. 刷新防火墙规则
/etc/vmware/firewall# esxcli network firewall refresh
检查规则是否生效:
/etc/vmware/firewall# esxcli network firewall ruleset list | grep VNC
VNC true
/etc/vmware/firewall#
3. 虚拟机配置
步骤如下:
关闭虚拟机,然后对虚拟机“编辑设置”。
鼠标右击选择 “Edit settings”;
配置选择 “Options” 标签页;
选项在 “Advanced” 下选择 “General”;
高级下面的常规点击 “Configuration Parameters” 按钮;
编辑配置参数最后加入如下配置参数:
RemoteDisplay.vnc.enabled= true
RemoteDisplay.vnc.password= <password>
RemoteDisplay.vnc.port= <port>
设置完成以后,重新启动虚拟机。
4. 客户端测试
通过VNC-Viewer连接刚才的虚拟机控制台
VNC Server里面输入的是ESXi的IP地址,端口号为RemoteDisplay.vnc.port= <port>所配置的端口号。
这里的密码为:RemoteDisplay.vnc.password = <password>所配置的密码。
ESXi的最新版本仍然有一个VNC服务器的VM控制台,可以用普通的VNC连接作为老KB1246(形容用VNC客户端连接到虚拟机)与VMware的GSX Server产品!
注:如写在KB VMware不支持正在运行的虚拟机与一个VNC客户端。正确的客户端来访问虚拟机控制台仍然是在vSphere Client(或Web客户端),当然,在来宾操作系统中实现的协议。
配置此功能在虚拟机,但在主机级别提供的,因此要管理与VNC你必须为每个虚拟机使用不同的VNC端口。
To configure each VM edit the VMX file or use the vSphere Client to edit the Virtual Machine Properties to add the following lines:
- RemoteDisplay.vnc.enabled = TRUE
Setting this option to TRUE enables standard VNC support. This setting is valid only while the virtual machine is running. If the virtual machine is powered off, you cannot connect to it with a VNC client.
- RemoteDisplay.vnc.port = TCP_Port
Specify the port the VNC client uses to connect to the virtual machine (5900 is the default VNC port). If you want to connect to more than one virtual machine on the same host with a VNC client, you must specify a unique port number for each virtual machine. VMware suggests you use a port number in the range from 5900 to 5999. You can use any port number, but keep in mind that certain port numbers are used by other applications while others are privileged (meaning only the root or Administrator user can listen). For example, the VMware Management Interface uses ports 8333 and 8222; on Linux, only root can listen to ports up to port number 1024. Conflicts can occur if you specify a port in use by another application.
- RemoteDisplay.vnc.password =password
Support for the VNC 3.3 authentication, which is an eight character password. Use this password when you are prompted for authentication as you use the VNC client to connect to the virtual machine.
In this example, the TCP 5901 port is used and the password is set to “password” (without the quotes):
Now, on ESXi 5, you must add a new custom firewall rule, as described in William Lam post (How to Create Custom Firewall Rules in ESXi 5.0).
First step is build a new rule like this:
~ # cat /etc/vmware/firewall/vnc.xml
VNC
inbound
tcp
dst
5901
outbound
tcp
dst
0
65535
true
false
Then you can refresh the firewall rules and check that the new one is correctly loaded:
~ # esxcli network firewall refresh
~ # esxcli network firewall ruleset list | grep VNC
VNC true
Finally you can simple download a VNC client (like the TightVNC Viewer) and simple connect at the IP of the ESXi host at port 5901 (using the IP:5901 syntax).
最新评论