linux - Ubuntu本地IP地址无法解析

标签 linux ubuntu networking hugo networkmanager

我设置了一个 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

最佳答案

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

关于linux - Ubuntu本地IP地址无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70970772/

相关文章:

android - android虚拟机在ubuntu系统下运行时的错误

ubuntu - rar包不可用..?

java - 声音加载在ubuntu中工作,但在Windows中不工作

algorithm - TCP 慢启动与丢包时的拥塞避免

linux - 模拟物理 USB 设备 Linux

linux - 发送到数据报套接字,不会无限期阻塞

linux - 安装包 : installed grub-efi-amd64 package post-installation script subprocess returned error exit status 255 时出错

java - Tomcat 的接受计数

c - memcpy 和 ntohl 不同的输出

c++ - 一对多IPC