原文地址:https://www.cyberciti.biz/faq/how-to-use-dnf-command-with-a-proxy-server-on-fedora/
我的Fedora Linux工作站只能通过集团公司的代理服务器上网。我怎样才能使用dnf呢?我应该如何配置dnf呢?Dnf软件源(“repos”) 能够通过squid等代理服务器接入互联网。配置文件为/etc/dnf/dnf.conf,格式如下:
首先,以管理员身份登录或以管理员身份执行:
# vi /etc/dnf/dnf.conf
或者
$ sudo vi /etc/dnf/dnf.conf
再文件的最后,加入以下内容:
proxy=http://server1.cyberciti.biz:3128proxy_username=vivekproxy_password=secretePasswordHere
保存文件。比如,我的文件中完整的配置/etc/dnf/dnf.conf:
[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
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:secretePassword@server1.cyberciti.biz: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.