使用类似域名的域来访问测试网站而不是IP地址

发布于 2025-02-02 18:18:38 字数 239 浏览 2 评论 0原文

我目前正在测试Windows 11计算机上Oracle VM虚拟框上安装的Ubuntu Server上的一些网站。

我需要键入一个IP地址来访问这些站点(例如:192.168.xxx.xxx)。

是否可以使用域名之类的内容访问它们而不是使用IP地址?像mysite1.com,mysite2.com等。

我不是在使用Godaddy或类似地点预订的域名。只是本地测试的名称。在这种情况下如何完成?一切都安装在同一台计算机上。

I'm currently testing a few websites on Ubuntu Server installed on Oracle VM Virtual Box on a Windows 11 machine.

I need to type an IP address to access these sites (eg: 192.168.xxx.xxx).

Is it possible to use something like a domain name to access them instead of using an IP address? Like mysite1.com, mysite2.com etc.

I'm not using domain names booked on godaddy or some place like that. Just names for local testing. How can it be done in this scenario? Everything is installed on the same machine.

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

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

发布评论

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

评论(3

星星的軌跡 2025-02-09 18:18:39

是的,您可以转到 /etc /hosts并应用所使用的IP以及所需的域名:

示例。

打开:

sudo nano /etc/hosts

应用:

192.168.x.x mysite.com

重新启动服务器。

尝试清洁缓存

sudo apt-get install nscd

,现在

sudo service nscd restart 

sudo service dns-clean

Yes, you can go to /etc/hosts and apply IP you are using and the domain name you want:

Example.

Open with:

sudo nano /etc/hosts

apply:

192.168.x.x mysite.com

And restart server.

TRY CLEAN CACHE

sudo apt-get install nscd

AND NOW

sudo service nscd restart 

or

sudo service dns-clean
清音悠歌 2025-02-09 18:18:39

要重申您的设置,您有一个在Windows 11上运行的Ubuntu Server Guest VM(在VirtualBox中)。由于您提到了192.168.xx IP范围,所以我会假设访客VM位于您的“桥接” Vbox网络适配器上本地网络可以ping。我还必须假设您正在使用的IP地址已成功地将您从Windows 11主机连接到Ubuntu Guest。这一切正确吗?您的VM是否具有可以到达互联网上流行网站的桌面和Web应用程序? Ubuntu OS是否使用DHCP或静态IP分配?

简短的答案是,您可以使用域名而不是IP地址。如果您没有成功连接到IP地址,则切换到域名将无济于事。您必须首先满足所有网络依赖关系。
选择用于测试的域名;

您应该看一下RFC 6761。特别是在Secion 6中; 6.1-6.5

.in-addr.arpa.
        10.in-addr.arpa.  21.172.in-addr.arpa.   26.172.in-addr.arpa.
    16.172.in-addr.arpa.  22.172.in-addr.arpa.   27.172.in-addr.arpa.
    17.172.in-addr.arpa.  30.172.in-addr.arpa.   28.172.in-addr.arpa.
    18.172.in-addr.arpa.  23.172.in-addr.arpa.   29.172.in-addr.arpa.
    19.172.in-addr.arpa.  24.172.in-addr.arpa.   31.172.in-addr.arpa.
    20.172.in-addr.arpa.  25.172.in-addr.arpa.  168.192.in-addr.arpa.
.test.
.localhost.
.invalid.
.example.com.
.example.net.
.example.org.

您可能必须创建/修改Windows用来拦截DNS的IP/主机映射的\ Windows \ System32 \ eett \ ett \ hosts文件。如果您使用的是Linux/Unix客户端,则/etc/nsswitch.conf和/etc/hosts文件可以为您覆盖DNS。这可能在Windows 11上的位置或可能不在同一位置,但截至Windows 10 21H2,它仍然存在。

To restate your setup, you have one Ubuntu server guest VM (in VirtualBox) running on Windows 11. Because you mentioned the 192.168.x.x IP range I will assume the guest VM is on a "bridged" vbox network adapter that any device on your local network can ping. I also have to assume the IP address(es) you are using are successfully connecting you from your Windows 11 host to your Ubuntu guest. Is all this correct? Does your VM have a desktop and a web application that can reach popular sites on the internet? Does the Ubuntu OS use DHCP or a static IP assignment?

The short answer is yes, you can use domain names instead of IP addresses. If you are not successful connecting to the IP address, switching to domain names will not help you. You have to have all the network dependencies satisfied first.
To choose a domain name for testing;

You should take a look at RFC 6761. Specifically at secion 6; 6.1 - 6.5
https://www.rfc-editor.org/rfc/rfc6761.html

.in-addr.arpa.
        10.in-addr.arpa.  21.172.in-addr.arpa.   26.172.in-addr.arpa.
    16.172.in-addr.arpa.  22.172.in-addr.arpa.   27.172.in-addr.arpa.
    17.172.in-addr.arpa.  30.172.in-addr.arpa.   28.172.in-addr.arpa.
    18.172.in-addr.arpa.  23.172.in-addr.arpa.   29.172.in-addr.arpa.
    19.172.in-addr.arpa.  24.172.in-addr.arpa.   31.172.in-addr.arpa.
    20.172.in-addr.arpa.  25.172.in-addr.arpa.  168.192.in-addr.arpa.
.test.
.localhost.
.invalid.
.example.com.
.example.net.
.example.org.

You may have to create/modify the \windows\system32\drivers\etc\hosts file that Windows uses to intercept asking DNS for IP/host mapping. If you are using a linux/unix client, the /etc/nsswitch.conf AND /etc/hosts files could override DNS for you. This may or may not be in the same location on Windows 11 but as of Windows 10 21H2 it was still there.

橘香 2025-02-09 18:18:38

将您的网站添加到 /etc /hosts文件中:

192.168.... mysite.domain

Add your sites to /etc/hosts file like this:

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