在 Ubuntu 中更改主机文件

发布于 2025-01-04 04:06:21 字数 1459 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2025-01-11 04:06:21

/etc/hosts(或其他操作系统上的等效项)用于将主机名解析为某个 IP,而无需询问 dns 服务器。

您可以在您的/etc/hosts中使用:

127.0.0.1 myserver.com

然后打开http://myserver. com:3333 在浏览器中,它将连接到 127.0.0.13333 端口。

您不能使用 /etc/hosts 映射 IP 地址。

您可以为此使用 iptables。但这是另一个问题了。

/etc/hosts (or it's equivalents on other OS's) is used to resolve hostnames to some ip without asking to dns servers.

You can use in your /etc/hosts:

127.0.0.1 myserver.com

And then open http://myserver.com:3333 in your browser and it will connect to 127.0.0.1 to 3333 port.

You can NOT map ip addresses with /etc/hosts.

You can use iptables for this. But that's another question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文