fedora linux中的dnf使用代理服務器連接軟件源更新rpm包

原文地址:https://www.cyberciti.biz/faq/how-to-use-dnf-command-with-a-proxy-server-on-fedora/

我的Fedora Linux工作站只能通過集團公司的代理服務器上網。我怎樣才能使用dnf呢?我應該如何配置dnf呢?
Dnf軟件源(“repos”) can be accessed through standard proxy servers such as Squid or any other proxy server. You need to configure the proxy server in /etc/dnf/dnf.conf file as follows:

  1. proxy=http://URL:PORT/ – Proxy serer URL to the proxy server that yum should use. You must set a complete URL, including the TCP port number. If your corporate proxy server requires a username and password, specify these by adding following two settings in dnf.conf file.
  2. proxy_username=YOUR-PROXY-USERNAME-HERE (optional)- Your proxy server username to use for the proxy URL.
  3. proxy_password=YOUR-SUPER-secrete-PASSWORD-HERE (optional) – Your proxy server password for this proxy URL.

Configuration: Using dnf with a proxy server

First, login as root user and type (open the Terminal app if you are using GUI based Fedora workstation):
# vi /etc/dnf/dnf.conf
OR
$ sudo vi /etc/dnf/dnf.conf
Add/append/edit the following settings in [main] section:

proxy=http://server1.cyberciti.biz:3128
proxy_username=vivek
proxy_password=secretePasswordHere

Save and close the file. Here is my complete working config /etc/dnf/dnf.conf file:

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
proxy=http://server1.cyberciti.biz:3128
proxy_username=vivek
proxy_password=secretePasswordHere

Please note that defining a proxy server, username, and password in dnf.conf file means all users connect to the proxy server with those details when using dnf command:
# dnf update
# dnf install foo

How do I enable proxy access for a specific user such as root user only?

Linux and UNIX-like system has environment variable called http_proxy. It allows you to connect text based session and applications via the proxy server. Type the following command at shell prompt:
# export http_proxy="http://server1.cyberciti.biz:3128"
OR
# export http_proxy="http://PROXY=USERNAME=HERE:PROXY=PASSWORD=HERE@URL:PORT"
# export http_proxy="http://vivek:[email protected]:3128"

Feel free to add the above line in the to your shell profile file such as ~/.bash_profile. See how to set or export: http_proxy with special characters in password on a Unix or Linux based system for more information.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章