跳至正文
  • 29 views
  • 2 min read

使用vnc通过esxi管理虚拟机

新浪微博 豆瓣 QQ 百度贴吧 QQ空间

参考博客:https://blog.51cto.com/68240021/1970732

前言:现有需求,我的虚拟化中有一台虚拟机,这台虚拟机拥有ipv4和ipv6的网络环境,为防止网络紊乱,将其ipv4服务禁用只使用ipv6,这样就出现一个问题,如何在ipv4的环境中去管理这台ipv6的机器?终于在网上面找到一篇解决办法,能使我们使用vnc工具连接时通过esxi跳转到虚拟机。

1、首先将esxi主机的ssh功能打开,配置-安全配置文件-属性-ssh。

2、ssh登录主机后,新建vnc防火墙规则

[root@localhost:~] cd /etc/vmware/firewall
[root@localhost:/etc/vmware/firewall] ls
fdm.xml         service.xml     vsanhealth.xml
#新增规则配置文件vnc.xml
cat >>/etc/vmware/firewall/vnc.xml<<EOF
<!-- 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>
EOF

3、esxi刷新防火墙规则

esxcli network firewall refresh
#检查规则是否生效,生效显示true
esxcli network firewall ruleset list | grep VNC

4、虚拟机中添加配置参数

#添加3行参数参数
RemoteDisplay.vnc.enabled= true     
RemoteDisplay.vnc.password=<password>
RemoteDisplay.vnc.port= <port>
#RemoteDisplay.vnc.password后面输入设置连接vnc的密码
#RemoteDisplay.vnc.port后面设置连接vnc的端口

5、使用vnc viewer连接
连接地址ip为esxi主机ip,端口为RemoteDisplay.vnc.port设置的端口号

发表回复