No route to host

muhu

New Member
Joined
Oct 21, 2022
Messages
14
Reaction score
2
Credits
204
I have a CentOS 7 system (no GUI) and logging in with ssh (Putty) from a Windows system. When I log in two IPs are listed, i.e.

IP Address: 10.13.226.120/22
IP Address: 192.168.10.8/24

The connection I established is through the 10.13.226.120 address which I set to DHCP. There is a second network adapter in the system which seems to be that 192.168.10.8 address. I did a "sudo yum install apt" but that produced the error:

http://192.168.10.4:8765/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to 192.168.10.4:8765; No route to host" Trying other mirror.

For some reason it tried to use that 192.168.10.4 address. That's despite the fact that when I do a nmcli d that other network interface is listed as unavailable. I even did a sudo ifdown enp0x31f7. So how can I make CentOS to use the 10.13.226.120 address? And is that 8765 port causing some additional issues?

Note that I am a complete Linux beginner.
 


Moving this to Linux Networking

Chris Turner
wizardfromoz
 
Most likely your Host settings are incorrect. Check your /etc/hosts file entries, may be the URL which You're requesting, is pointing to your localhost. It is showing "curl#7-failed to connect"
If the URL is not listed in your /etc/hosts file, then try to execute following command to understand the flow of Curl Execution for the particular URL:
Code:
curl --ipv4 -v "https://example.com/";
 
The entries in /etc/hosts are

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

The issue seems to be that "sudo yum install apt" is trying to access "http://192.168.10.4:8765/repodata/repomd.xml" but the 192.168.10.4 address is invalid. I think (not sure) it should be 10.13.226.120, i.e. the IP address of the computer on which I execute this command.
 
When you have two interfaces, (which are typically on two different subnets)
You need to have a default gateway. Usually you will only have a default gateway on one of these two interfaces.

What is the output of netstat -nr

One of your interfaces should have a destination of 0.0.0.0
If both do, then you have to set a route priority.
Give interface 1 a lower priority number than interface 2 if interface 1 is the one going out to the internet.

1666756317684.png



For example traffic will try to go out an interface with a priority of 1 before it will try to go an interface of 50.
You can use negative numbers. -999 above means try to go through this interface before any other.
 
netstat -nr shows the following:

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.13.224.1 0.0.0.0 UG 0 0 0 enp0s31f6
10.13.224.0 0.0.0.0 255.255.252.0 U 0 0 0 enp0s31f6

enp0x31f6 seems to be correct as nmcli d give me

enp0s31f6 ethernet connected enp0s31f6
enp0s31f7 ethernet unavailable --
lo loopback unmanaged --

So I don't get where this 192.168.10.4 address is coming from in

http://192.168.10.4:8765/repodata/repomd.xml: [Errno 12] Timeout on http://192.1 68.10.4:8765/repodata/repomd.xml: (28, 'Connection timed out after 5001 millisec onds')
Trying other mirror.

My config file for this network adapter is below. I think it listed an IP address before but I removed that and did a systemctl restart network.

TYPE=Ethernet
BOOTPROTO="dhcp"
PREFIX=24
DEFROUT=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUT=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
DEVICE=enp0s31f6
NAME="enp0s31f6"
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
 
CentOS 7. Been a while since I've used that. Just about forgotten about ifcfg files.
If you're using network-manager you really don't even need the ifcfg files.

What is output of

ip addr

and

nmcli con show
 
Here is what ip addr and nmcli con show prints

[[username]@[IP] ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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: enp0s31f7: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 00:04:5f:44:24:31 brd ff:ff:ff:ff:ff:ff
3: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:04:5f:44:a3:cd brd ff:ff:ff:ff:ff:ff
inet 10.13.226.120/22 brd 10.13.227.255 scope global noprefixroute dynamic enp0s31f6
valid_lft 683867sec preferred_lft 683867sec
inet6 fe80::a37b:b1e8:5e0a:9a20/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[[username]@[IP] ~]$ nmcli con show
NAME UUID TYPE DEVICE
enp0s31f6 [UUID1] ethernet enp0s31f6
Wired connection 1 [UUID2] ethernet --
enp0s31f7 [UUID3] ethernet --
 
When I log in two IPs are listed, i.e.

IP Address: 10.13.226.120/22
IP Address: 192.168.10.8/24

Hmmm... where are you seeing this?
 
"sudo yum install apt"

I doubt apt is in any default CentOS repo. Perhaps you have created another repo file?

http://192.168.10.4:8765/repodata/repomd.xml: [Errno 12] Timeout on http://192.1 68.10.4:8765/repodata/repomd.xml: (28, 'Connection timed out after 5001 millisec onds')

I should have read this part better before.

Can you give output of ...

grep enabled /etc/yum.repos.d/*repo

Normally you get the error above from a repo server.
 
The two lines of "IP Address: ..." were listed before I disabled the second network card. Now when logging in via ssh it only shows on IP:

CentOS Linux release 7.5.1804 (Core)
Kernel 3.10.0-693.21.1.rt56.639.el7.x86_64
Revision B

System information as of: Wed Oct 26 22:48:01 GMT 2022

IP Address: 10.13.226.120/22
System load: 0.00
Memory usage: 3.5%
System uptime: 1 day, 53 minutes
Usage on /: 20%
Local Users: 1
Processes: 217

Below is what the grep shows.

/etc/yum.repos.d/[CompanyName]Install.repo:enabled=1
/etc/yum.repos.d/CentOS-CR.repo:enabled=0
/etc/yum.repos.d/CentOS-Debuginfo.repo:enabled=0
/etc/yum.repos.d/CentOS-fasttrack.repo:enabled=0
/etc/yum.repos.d/CentOS-Media.repo:enabled=0
/etc/yum.repos.d/CentOS-Sources.repo:enabled=0
/etc/yum.repos.d/CentOS-Sources.repo:enabled=0
/etc/yum.repos.d/CentOS-Sources.repo:enabled=0
/etc/yum.repos.d/CentOS-Sources.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/CentOS-Vault.repo:enabled=0
/etc/yum.repos.d/EfficiOS-RHEL7-x86-64.repo:enabled=0
/etc/yum.repos.d/epel.repo:enabled=0
/etc/yum.repos.d/epel.repo:enabled=0
/etc/yum.repos.d/epel.repo:enabled=0
/etc/yum.repos.d/epel-testing.repo:enabled=0
/etc/yum.repos.d/epel-testing.repo:enabled=0
/etc/yum.repos.d/epel-testing.repo:enabled=0
 
How about ...

grep 192.168.10 /etc/yum.repos.d/*repo

and

echo $HTTPS_PROXY

You may have to try that command without the S or in lower case.
 
That gives me

[...@... ~]$ grep 192.168.10 /etc/yum.repos.d/*repo
/etc/yum.repos.d/[Company]Install.repo:baseurl=http://192.168.10.4:8765/
[...@... ~]$ echo $HTTPS_PROXY

And here is that 192 IP but I am not sure what those repo files are and how an IP in there makes this a default IP to go out to the internet.

[...@... yum.repos.d]$ cat [Company]Install.repo
[[Company]repo]
name=[Company] Install Repo
baseurl=http://192.168.10.4:8765/
enabled=1
gpgcheck=0
mirrorlist_expire=never
timeout=5
 
In that company repo file.
Change the enabled = 1 to enabled = 0.
It won't hurt anything because it's not a default vendor repo.
If it turns out, you do need it, you can always re-enable it later.

Then do a
yum clean all

Then try to search or install something.
yum install lsof

It should work now.
 
I did set enabled=0 and then

[...@... yum.repos.d]$ yum clean all
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>

What is confusing is that it talks about Red Hat when I have CentOS 7.5.1804 (Core). Maybe CentOS is based on Red Hat.

I then did a "sudo yum install lsof" as well as "sudo yum install libssl-dev" but both gave me the same message as above, i.e. There are no enabled repos. When I execute the yum repolist all I get a long list with everything set to disabled. I put the output in an attachment as the list is pretty long. I did some googling on this but everything seems to refer to Red Hat and I don't want to mess up the system by doing something wrong.
 

Attachments

  • output1.txt
    5.9 KB · Views: 220
Yes CentOS, AlmaLinux, OracleLinux, ScientificLinux, RockyLinux, and a few others are Based on Redhat.
Which is itself based on Fedora.

I would enable the CentOS repos, and probably the epel repo's also.
But leave the "Company" repo disabled.
 
I am running into other troubles but enabling all the CentOS (except the media one) and epel repos did the trick. No I don't get that error with the 192 IP address anymore and it seems it did indeed download packages from the internet. Thanks a lot for the help!!!
 
If you were helped to satisfaction, you can edit your first post and change the headline to say [SOLVED] (or similar).
 

Staff online

Members online


Latest posts

Top