How to enable proxy on Linux in VirtualBox

H

At my work, I installed Linux Ubuntu on VirtualBox but when I run the virtual machine, I could not get on the internet. After some time, I finally got it working and I would like to share my solution with you.

First, you have to question yourself: could the proxy be the problem or my VirtualBox settings? In my case, it was the proxy. If you’re not behind a proxy, I’m sorry but this tutorial is not for you 🙁 If you do, you are a lucky guy 😀 let us start!

Luckily, we don’t need to change VirtualBox settings. I just use NAT as network adapter. So all the configuration will be done in Ubuntu.

First, startup your Ubuntu VirtualBox, then press Ctrl + Alt + T and the terminal will open. Enter the following commands:

sudo -i
nano /etc/bash.bashrc

At the bottom of that file, add the following lines:

export http_proxy=http://username:password@proxyserver.net:port
export https_proxy=http://username:password@proxyserver.net:port

After you did that, press Ctrl + O, Enter, Ctrl + X. Next, we do the same in another file.

nano /etc/environment

At the bottom of that file, add the following lines:

export http_proxy=http://username:password@proxyserver.net:port
export https_proxy=http://username:password@proxyserver.net:port

After you did that, press Ctrl + O, Enter, Ctrl + X again. Finally, we need to manipulate the last file:

nano /etc/apt/apt.conf

Add the following lines:

Acquire::http::Proxy "http://username:password@proxyserver.net:port";
Acquire::https::Proxy "http://username:password@proxyserver.net:port";

Again, press Ctrl + O, Enter, Ctrl + X and you’re done! :D. Now reboot and enjoy internet.

NOTE! At the https settings, you need to add a http url and not the https url

6 comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tag Cloud

Categories