Possible DNS issue when using yum: "Could not resolve host: (every mirror); Unknown error" Centos 7

8,487

Check if your firewall is blocking the queries or responses:

sudo firewall-cmd --list-all

You can try to disable de firewall to check for sure if that's the cause:

sudo systemctl stop firewalld

If the firewall is the issue, you should allow the DNS service, allowing TCP/UDP traffic to/from the port 53.

Share:
8,487
Dillon
Author by

Dillon

Originally from a small town in the middle of nowhere. Trying to increase my experience and become a better programmer before graduating University.

Updated on September 18, 2022

Comments

  • Dillon
    Dillon over 1 year

    Some specifications and background information: Running Centos Linux release 7.2.1511 (core), Static IP address, Dedicated server machine not configured by me, also I have very little linux experience.

    I am trying to set up the server to host a tomcat web application that uses a MySQL database. However whenever I try to install the required software I get a "Could not resolve host error". I have tried multiple suggestions and the solutions in a previous similar question: Could not resolve host. However none seem to work.

    I can successfully ping my local host 127.0.0.1, but not googles public nameserver 8.8.8.8. When I try ping 8.8.8.8 and the public-gateway address there is 100% packet loss. Which in the previous question's answer indicates the local network configuration is wrong and you'll have to check the configuration. Below is the local network configuration:

    Network information

    [xxxx]$ nmcli d
    DEVICE  TYPE      STATE      CONNECTION
    enp3s0  ethernet  connected  enp3s0
    lo      loopback  unmanaged  --
    
    [xxxx]$ ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        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: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    

    My etc/resolv.conf file contains

    nameserver 8.8.8.8 
    nameserver 127.0.0.1
    

    host google.com simply results in: -bash: host: command not found This is also the case with the nslookup and dig commands.

    Output:

    [xxxx]$ sudo yum update
    Loaded plugins: fastestmirror
    http://ca.mirror.babylon.network/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: ca.mirror.babylon.network; Unknown error"
    Trying other mirror.
    http://mirror.netaddicted.ca/CentOS/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirror.netaddicted.ca; Unknown error"
    Trying other mirror.
    etc...
    

    firewall-cmd --list-all

    [xxxx]$ firewall-cmd --list-all
    public (default, active)
      interfaces: enp3s0
      sources:
      services: dhcpv6-client http https ssh
      ports: 10000/tcp
      masquerade: no
      forward-ports:
      icmp-blocks:
      rich rules:
    

    google's public nameserver ping failure

    [xxxx]$ ping 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    ^C
    --- 8.8.8.8 ping statistics ---
    8 packets transmitted, 0 received, 100% packet loss, time 6999ms
    

    Local gateway ping failure

    [xxxx]$ ping xxx.xxx.xx.xxx
    ...
    11 packets transmitted, 0 received, 100% packet loss, time 9999ms
    

    Further specification and update: The server is connected to a larger network managed by an IT department. I am currently contacting one of the IT employees to ensure the firewall is open for this server.

    I hope this is relevant and useful information. Thanks in advance for you time. I will update the question once I know if the problem was on the IT staff side and the firewall configuration.

    Final Update: This error was in fact due to the firewall configuration. Once the IT staff allowed access there was no longer any issue.

  • Dillon
    Dillon almost 6 years
    Thanks, Leo I suspect it is a firewall issue and am going to contact the IT security department to ensure they are allowing the server access through the firewall while I update the system. The firewall-cmd --list-all command doesn't show anything being blocked so I suspect it is the firewall handled by the University staff which I will just have to wait for them to configure to allow the server access.
  • Leo
    Leo almost 6 years
    You are welcome. It might very well be that. I hope you solve it soon, if you do and found my answer helpful please accept it later. Regards