【发布时间】:2019-04-23 08:03:06
【问题描述】:
我正在免费运行 esxi 6.7。
我想通过我的路由器将我的 esxi 暴露在互联网上。但我想更改默认端口为 80 和 443。
我发现许多可用于 esxi 5.0 和 6.0 的教程/知识库,但这些都不起作用。
在这些教程中,有防火墙和反向代理的部分,但无论我做什么,都没有工作,主要是当我重新启动防火墙时。
【问题讨论】:
我正在免费运行 esxi 6.7。
我想通过我的路由器将我的 esxi 暴露在互联网上。但我想更改默认端口为 80 和 443。
我发现许多可用于 esxi 5.0 和 6.0 的教程/知识库,但这些都不起作用。
在这些教程中,有防火墙和反向代理的部分,但无论我做什么,都没有工作,主要是当我重新启动防火墙时。
【问题讨论】:
我想它已经解决了,但对其他人来说......
如何在 ESXi 6.7 主机视频上通过 ssh 更改端口 -> https://www.youtube.com/watch?v=a7kuwmLuwvU 或者在可能的情况下在路由器端口中设置从 443 重定向到所需端口。
编辑: 对于他们喜欢阅读的人:-)
1. enable ssh on esxi host
2. connect via ssh or press alt + f1 on esxi host
3. edit this file by command vi /etc/vmware/rhttpproxy/config.xml
4. find text https by command :/https
<!-- HTTPS port to be used by the reverse proxy -->
<httpsPort>443</httpsPort>
5. change port to eg. 9443
(press insert before editing and after finished press esc save it by :wq)
6. reboot needed by command reboot
7. after reboot connect to ssh and create new file changedport.xml by command
vi /etc/vmware/firewall/changedport.xml
8. copy this text to console.
<ConfigRoot>
<service>
<id>changedport</id>
<rule id='0000'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>9443</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>
9. save it by :wq
10. refresh firewall rules by command esxcli network firewall refresh
这不是一个永久的解决方案。 重启后需要重新添加防火墙规则 并执行命令 esxcli network firewall refresh
【讨论】:
感谢您的帮助。
正如你所描述的,这不是一个永久的解决方案。
要使其永久化,您需要执行相同操作,但将其保存在 VIB 文件中,如下所述:
https://www.altaro.com/vmware/how-to-create-persistent-firewall-rules-on-esxi/#comment-18186
按照本指南,我创建了自己的自定义 vib,允许端口 444
你可以在这里下载:https://multifilemirror.com/hik1l28cf6du/firewall444.vib.html
此 VIB 文件是一个简单的存档,因此您可以多次解压它以查看其中的 xml 文件以验证它只是这个并且没有其他恶意附加设置。
只需将 VIB 文件上传到 ESXI 服务器并运行“esxcli software vib install”命令即可使用 SSH 安装它
【讨论】:
步骤:
编辑“/etc/vmware/rhttpproxy/config.xml”(<httpsPort>443</httpsPort> 到 <httpsPort>4444</httpsPort>)
运行命令“/etc/init.d/rhttpproxy restart”
创建新文件“/etc/vmware/firewall/changes.xml”
将此文本复制到文件中:
<ConfigRoot> <service> <id>changedport</id> <rule id='0000'> <direction>inbound</direction> <protocol>tcp</protocol> <porttype>dst</porttype> <port>4444</port> </rule> <enabled>true</enabled> <required>false</required> </service> </ConfigRoot>
运行命令“/sbin/esxcli network firewall refresh”
将上述文件复制到 /vmfs/volumes/xxxxxxx-80925220-52bf-b8ac6f41950b/changes.xml
将以下代码添加到“/etc/rc.local.d/local.sh”以在重启后工作:
/sbin/cp /vmfs/volumes/xxxxxxx-80925220-52bf-b8ac6f41950b/changes.xml/ etc/vmware/firewall/ /sbin/esxcli network firewall refresh exit 0
完成。
【讨论】: