V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
littleylv
V2EX  ›  问与答

CentOS Stream 9 经常 “Name or service not known”

  •  
  •   littleylv · 34 天前 · 100 次点击
    这是一个创建于 34 天前的主题,其中的信息可能已经有所发展或是发生改变。

    有没有 linux 服务器大佬帮忙看看问题:

    我有一台电脑装的 CentOS Stream 9 服务器无 GUI 版,网线直连的路由器,设置了固定 ip 。

    网络好的,可以内网连接,也可以访问外网。搭了 PHP 和 Apache 运行着。

    但问题是,时不时的就网络错误,表现为:

    [PDOException] SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

    cURL Error (6) Could not resolve host: xx.xx.com (此处我改了域名 xx )

    他也不是一直不行,就是偶尔,大概 10 分钟左右就会出现一次错误

    # cat /etc/NetworkManager/system-connections/enp4s0.nmconnection
    [connection]
    id=enp4s0
    uuid=(UUID here)
    type=ethernet
    interface-name=enp4s0
    timestamp=1712230701
    
    [ethernet]
    
    [ipv4]
    address1=192.168.2.120/24,192.168.2.1
    dns=192.168.2.1;114.114.114.114;8.8.8.8;
    method=manual
    
    [ipv6]
    addr-gen-mode=eui64
    method=auto
    
    [proxy]
    
    # cat /etc/resolv.conf
    # Generated by NetworkManager
    nameserver 192.168.2.1
    nameserver 114.114.114.114
    nameserver 8.8.8.8
    
    # cat /etc/nsswitch.conf | grep 'hosts'
    #     hosts: files dns
    #     hosts: files dns  # from user file
    # Valid databases are: aliases, ethers, group, gshadow, hosts,
    hosts:      files dns myhostname
    
    # ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 58:11:22:bd:ae:31 brd ff:ff:ff:ff:ff:ff
        inet 192.168.2.120/24 brd 192.168.2.255 scope global noprefixroute enp4s0
           valid_lft forever preferred_lft forever
        inet6 fe80::5a11:22ff:febd:ae31/64 scope link noprefixroute
           valid_lft forever preferred_lft forever
    3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether f4:26:79:f6:9d:43 brd ff:ff:ff:ff:ff:ff
        altname wlp0s20f3
    

    另外一个情况是:dns=192.168.2.1;114.114.114.114;8.8.8.8; 这里如果我不填 192.168.2.1 或把他移到后面,则完全连不上外网(内网是可以)!

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1021 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 22:35 · PVG 06:35 · LAX 15:35 · JFK 18:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.