I'm working in a lab. There are many windows-PCs in this lab and I'm using one of them.
There is also a proxy server, which allows all of PCs to be able to connect to the Internet.
Now, I have a Red Hat 7 machine, which connected to my PC, meaning that it doesn't connect to the proxy server.
| | | |
| Internet |<--- proxy server |<--- my PC |<--- RHEL7
| | | |
Saying that the IP of my PC that the RHEL7 can ping is a.a.a.a
, the IP of the proxy server that my PC can ping is b.b.b.b
and the used port of the proxy server is 8080
.
Now, I need to make the RHEL7 surf the Internet. Here is what I've done:
1) I do the configuration on my PC as below:
port_forwarding(a.a.a.a, 6113, b.b.b.b, 8080)
2) I do the configuration on the Linux machine as below:
export http_proxy="http://my_name:my_passwd@a.a.a.a:6113/"
export http_proxys="https://my_name:my_passwd@a.a.a.a:6113/"
export ftp_proxys="ftp://my_name:my_passwd@a.a.a.a:6113/"
Now, I can wget www.google.fr
on my RHEL7. My configuration works.
Then, I execute yum makecache
and here is the output:
me@localhost:/etc/yum.repos.d$ yum makecache
Loaded plugins: langpacks, product-id, search-disabled-repos
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): base/x86_64/group_gz | 165 kB 00:00:00
(2/10): base/x86_64/primary_db | 6.0 MB 00:00:02
(3/10): extras/x86_64/primary_db | 165 kB 00:00:00
(4/10): extras/x86_64/filelists_db | 217 kB 00:00:00
(5/10): base/x86_64/filelists_db | 7.3 MB 00:00:03
(6/10): extras/x86_64/other_db | 106 kB 00:00:00
(7/10): base/x86_64/other_db | 2.6 MB 00:00:00
(8/10): updates/x86_64/filelists_db | 4.5 MB 00:00:01
(9/10): updates/x86_64/other_db | 573 kB 00:00:00
(10/10): updates/x86_64/primary_db | 7.6 MB 00:00:03
It seems that yum makecache
works. However, when I execute sudo yum update
, I get an error:
https://mirrors.huaweicloud.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.huaweicloud.com; Unknown error"
Trying other mirror.
https://mirrors.huaweicloud.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.huaweicloud.com; Unknown error"
I've tried all of mirrors here: http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os, but I always get the same error.
BTW, the output of curl -v mirrors.huaweicloud.com
:
* About to connect() to proxy 192.168.120.176 port 6113 (#0)
* Trying 192.168.120.176...
* Connected to 192.168.120.176 (192.168.120.176) port 6113 (#0)
* Proxy auth using Basic with user 'me'
> GET HTTP://mirrors.huaweicloud.com/ HTTP/1.1
> Proxy-Authorization: Basic ejAwNDM2ODgwOnI2Ni0xODE2
> User-Agent: curl/7.29.0
> Host: mirrors.huaweicloud.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 301 Moved Permanently
< via: proxy A
< Date: Fri, 10 Apr 2020 03:49:09 GMT
< Server: CloudWAF
< Location: https://mirrors.huaweicloud.com/
< Set-Cookie: HWWAFSESID=b0be07ce156888de4e; path=/
< Set-Cookie: HWWAFSESTIME=1586490548595; path=/
< Content-Type: text/html
< Cache-Control: public
< Content-Length: 182
< Proxy-Connection: Keep-Alive
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
* Connection #0 to host 192.168.120.176 left intact
Best Answer
My guess is that you only set the proxy for the user "me" when you exported
http_proxy
andhttp_proxy
, thus it works when you executeyum makecache
or the curl with that user.But when you run
sudo yum update
you execute the command as root, so the variables you set for the user "me" are not taken in account, you need to set them for root, or you could add the following inyum.conf
:If that's not the reason you can try adding
-v
to your yum commands to get more informations.