共享主机上域的IP地址
我在共享托管提供商上拥有域名。如何使用 Python 查找我的域的直接 IP 地址?
是否可以使用 IP 地址而不是网站本身发布到我的域上的脚本?
谢谢。
I have domain on a shared hosting provider. How do I find the direct IP address of my domain using Python?
Is it possible to post to a script on my domain using the IP address and not the website itself?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜IP应该是静态的,所以你真的需要多次查找它吗?
您需要指定域名,以便网络服务器知道要使用哪个主机配置(如果您没有专用 IP 或您的主机是该网络服务器的默认主机)
I guess the IP should be static so do you really need to look it up more than once?
You need to specify the domain name so that the webserver knows which host configuration to use if you don't have a dedicated IP or your host is the default for that webserver
将为您提供域的 IP 地址(作为字符串)。
但是,如果它是共享主机,我认为您不太可能通过 IP 访问您的主机 - 很可能您会拥有类似 Apache 的 VirtualHost 指令 限制您只能“看到”对您的域的请求。对 IP 地址的请求将由某些默认配置提供服务。
很大程度上取决于您托管的性质。
will get you the ip address (as a string) of your domain.
However, if it's shared hosting I would think it highly unlikely that you'll be able to access your hosting via the ip - most likely you'll have something like Apache's VirtualHost Directive in place which limits you to only 'seeing' requests to your domain. Requests to the IP address will be served by some default configuration.
Would very much depend on the nature of your hosting.
一个奇怪的请求...
要查找域名,请执行以下操作:
关于发布到 IP 地址:
我认为它不会以正常方式工作(例如通过浏览器),因为该地址下可能有许多网站。
但是,我想如果您将客户端套接字连接到站点的 IP 地址,但仍然在 HTTP 主机请求标头中发送网站名称,那么您可以使用编程语言(例如 Python)以非常手动的方式完成此操作。
我不知道这是否提出的问题多于它所回答的问题,我也不知道你为什么要执行上述任一操作,但事实就是如此。
祝你好运!
A curious request ...
To look up a domain name, do something like this:
Regarding posting to the IP address:
I don't think it would work in the normal way (like from a browser), because there will probably be many sites held under that address.
But, I guess you could do it in a very manual way, using a programming language (e.g. Python), if you connected a client socket to the site's IP address, but still sent the website's name in the HTTP Host request header.
I don't know if that poses more questions than it answers, and I don't know why you'd want to do either of the above, but there it is.
Good luck!