V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
raysonlu
V2EX  ›  程序员

localhost 不能指定任意 ip

  •  
  •   raysonlu · Apr 15, 2019 · 2869 views
    This topic created in 2580 days ago, the information mentioned may be changed or developed.

    以前搞个内网的虚拟机,然后修改 hosts 里面的 localhost 为那个虚拟机的内网 ip,就能使用 localhost 访问虚拟机的服务了,甚至在宿主机 ping localhost 也是显示指向虚拟机内网 ip

    但前几天重启了电脑后发现就不行了

    首先重启后,发现访问 localhost 失败,ping 一下发现指向了::1,后来看了这篇文章 https://blog.csdn.net/ambertian/article/details/70238020 修改了策略后,ping localhost 指向了 127.0.0.1,但我的 hosts 文件一致没有改,里面一致写着一行 192.166.22.3 localhost

    hosts 里面的其他映射设置都正常,唯独 localhost 这个不行!!!

    问了问旁边的同事,大家都是 win10,他的也是无法改 localhost 指向的 ip,windows 不能修改 localhost 指向的 ip 了么?那我之前用的是假 win ?

    求助!求助!

    2 replies    2019-04-16 09:19:34 +08:00
    ysc3839
        1
    ysc3839  
       Apr 15, 2019
    Windows 10 的 hosts 文件里有写:
    # localhost name resolution is handled within DNS itself.
    下面的两行 localhost 也是注释了的。
    raysonlu
        2
    raysonlu  
    OP
       Apr 16, 2019
    @ysc3839 但我之前的的确确可以改到 localhost 的指向,甚至可以指向 docker 的地址使 localhost 访问 docker 容器。假如现在我要强行改的话,有无这样的操作?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3317 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:32 · PVG 08:32 · LAX 17:32 · JFK 20:32
    ♥ Do have faith in what you're doing.