Posted on
Administration

Configuring proxy settings for DNF/YUM

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Configuring Proxy Settings for Package Managers on Linux

When working in environments where internet access is regulated through a proxy server, it can be a challenge to configure all aspects of a Linux system to adhere to the strict access controls. Among the various configurations required, setting up package managers such as APT (used in Debian and Ubuntu), DNF (used in Fedora and CentOS), YUM (legacy manager for older Red Hat/CentOS systems), and Zypper (used in openSUSE) is crucial to ensure software and updates can be smoothly installed without direct internet access. Here’s how you can configure proxy settings for these various package managers.

1. APT (Advanced Package Tool)

APT is widely used in Debian-based distributions. Here’s how you set up the proxy settings for APT:

  • Create or Edit APT Configuration File:
sudo nano /etc/apt/apt.conf.d/01proxy
  • Specify the Proxy URL: If your proxy server is http://proxy.server.com:PORT/:
Acquire::http::Proxy "http://proxy.server.com:PORT/";
Acquire::https::Proxy "https://proxy.server.com:PORT/";

Save and close the file. APT will now use this proxy setting for all future updates and installations.

2. DNF (Dandified YUM)

DNF is the next-generation version of YUM and is default in newer Fedora distributions, and several newer versions of CentOS:

  • Edit DNF Configuration:
sudo nano /etc/dnf/dnf.conf
  • Add the Proxy Settings:
proxy=http://proxy.server.com:PORT/

If your proxy requires authentication:

proxy_username=your-username
proxy_password=your-password

Save the configuration file. DNF will now respect these proxy settings.

3. YUM (Yellowdog Updater, Modified)

Although DNF has largely replaced YUM, some older distributions still use YUM:

  • Configure the YUM Proxy Setting:
sudo nano /etc/yum.conf
  • Insert the Proxy Information:
proxy=http://proxy.server.com:PORT/

For authenticated proxy:

proxy_username=your-username
proxy_password=your-password

After saving the file, YUM will use the specified proxy settings.

4. Zypper

Zypper is the command line interface of the ZYpp package manager, used in openSUSE:

  • Edit Zypper Manager Configuration:
sudo nano /etc/zypp/zypp.conf
  • Add Proxy Settings:
proxy=http://proxy.server.com:PORT/

Further, specify proxy settings for FTP and HTTPS if necessary:

proxy_ftp=ftp://proxy.server.com:PORT/
proxy_https=https://proxy.server.com:PORT/

For networks requiring authentication, configure the user credentials in the same config file.

By ensuring these settings are correctly configured, you can seamlessly manage and update system packages even behind a corporate or organizational proxy server. Always ensure you have the correct proxy address and necessary credentials before adjusting configuration files. Misconfiguration could disrupt regular package management on your system. For security, also ensure that credentials stored in these configuration files are appropriately secured and access to these files is restricted to root or superuser only.