【问题标题】:Ubuntu local IP address does not resolveUbuntu本地IP地址无法解析
【发布时间】:2022-02-03 20:00:04
【问题描述】:

我设置了一个 Hugo 网络服务器,它监听 localhost:30000。 ubuntu机器地址为192.168.2.137。

当我这样做时:

curl http://localhost:30000/ -> OK
curl http://127.0.0.1:30000/ -> OK

但是,

curl http://192.168.2.137:30000/ -> curl: (7) Failed to connect to 192.168.2.131 port 30000: Connection refused

这可能是什么原因?

我的 /etc/netplan/00-installer-config.yaml 看起来像:

network:
version: 2
renderer: NetworkManager
ethernets:
  enp0s3:
    dhcp4: false
    addresses: [192.168.2.137/24]
    gateway4: 192.168.2.1
    nameservers:
      addresses:
        - 8.8.8.8
  lo:
    renderer: networkd
    match:
      name: lo
    addresses:
      - 192.168.2.137/24

我还在 /etc/hosts 中添加了一个条目:

192.168.2.137 localhost

【问题讨论】:

    标签: linux ubuntu networking hugo networkmanager


    【解决方案1】:

    你说它是在 localhost 上监听的,所以如果你使用其他接口它不会工作,这是正常的。您应该监听所有接口或监听 enp0s3 接口。

    【讨论】:

      猜你喜欢
      • 2020-08-06
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 2014-10-13
      • 1970-01-01
      • 2020-09-13
      • 2015-09-14
      相关资源
      最近更新 更多