apt get behind proxy

Over time, I have often come across the need to configure apt get to work behind a proxy in network labs. Today we will show you how to do this.

apt get behind a proxy

First, we will get the proxy address and the port that is being used.

In our case, the proxy address is “172.24.0.254” and the port used is “3128“.

Therefore, to configure apt get on the machines that are behind this proxy, we will follow the following steps.

First, we will open a terminal and then type the command below to access the apt configuration directory.

cd /etc/apt

Next, we will create the apt.conf file using a text editor. To do this, we will use the command below.

sudo nano apt.conf

Inside the “apt.conf” file we will insert the lines below.

Acquire::http::proxy "http://172.24.0.254:3128";
Acquire::https::proxy "https://172.24.0.254:3128";

The lines above are indicating that we will use the proxy with the address “172.24.0.254” and port “3128” for apt get updates and installations.

In your network, replace the addresses and ports based on your proxy information. Example:

Acquire::http::proxy "http://IP_do_seu_proxy:porta_do_seu_proxy";
Acquire::https::proxy "https://IP_do_seu_proxy:porta_do_seu_proxy";

And after that, update the repositories with the command below and then try to install a package.

sudo apt update

See also:

How to use Ngrok

Install ubuntu 24 on virtualbox

How to X11 Forwarding using SSH

Install SSH server Windows 11

What is IPv6

https://askubuntu.com/questions/257290/configure-proxy-for-apt

Juliana Mascarenhas

Data Scientist and Master in Computer Modeling by LNCC.
Computer Engineer