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”) 能够通过squid等代理服务器接入互联网。配置文件为/etc/dnf/dnf.conf,格式如下:

  1. proxy=http://URL:PORT/ – 代理服务器的URL地址。URL地址必须完整,包括TCP端口号。如果代理服务器需要用户名和密码认证。请再添加下边两行。
  2. proxy_username=YOUR-PROXY-USERNAME-HERE (optional)- 用户名。
  3. proxy_password=YOUR-SUPER-secrete-PASSWORD-HERE (optional) –密码。

配置:通过代理服务器使用dnf

首先,以管理员身份登录或以管理员身份执行:
# vi /etc/dnf/dnf.conf
或者
$ sudo vi /etc/dnf/dnf.conf
再文件的最后,加入以下内容:

proxy=http://server1.cyberciti.biz:3128
proxy_username=vivek
proxy_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

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: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.

转载于:https://my.oschina.net/chipo/blog/2870064

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值