Using proxy for Raspberry Pi (Raspbian)

  • by

I have using my Raspberry Pi 3 Model B running Raspbian as a torrent box and monitoring latest movies, tv shows for downloading. That’s why it’s not so good to connect without a protection. Also I have in hands a proxy that is transparency, so why not I let the Pi connect to the Internet through that proxy. So today I’ll add proxy Raspberry Pi.

Log in to SSH using pi:raspberry

Type in: curl -sb -H , and note down my current IP address.

Add Proxy Raspberry Pi

There is 3 places that I need to make changes:
1. /etc/environment (if this file doesn’t exist then create ones)

Copy and paste this, change the content with my proxy details:

export http_proxy="http://username:[email protected]_server_address:port/"
export https_proxy="http://username:[email protected]_server_address:port/"

Save the file.

2. /etc/apt/apt.conf.d/10proxy (for apt to connect to repositories through proxy)

sudo nano /etc/apt/apt.conf.d/10proxy

Then add this with my proxy details:

Acquire::http::Proxy "http://username:[email protected]_server_address:port/";
Acquire::https::Proxy "http://username:[email protected]_server_address:port/";

Save the file.

3. nano ~/.bashrc

sudo nano ~/.bashrc

Add this line at the end, of course, with my proxy details:

export http_proxy=http://username:[email protected]_server_address:port
export https_proxy=https://username:[email protected]_server_address:port

The run: source ~/.bashrc

How to check if I have the proxy working?

Create a file nano ~/  with this content:

myip1="$(curl -sb -H"
echo "IPv4 address from ${myip1}"

myip2="$(curl -sb -H"
echo "IPv4 address from ${myip2}"

myip3="$(host | sed -En 's/.*has address (([0-9]*\.){3}[0-9]{3})/\1/p')"
printf "IP address from %s\n" "$myip3"

Make the file executable: sudo chmod +x ~/ .

Run it:

sh ~/

The result should look like:

[email protected]:~ $ sh ~/
IPv4 address from 1xx.1xx.1x.1xx
IPv4 address from 2xxx:660x:xx:xxxx:4xxx:9xxx:xxx0:axxx
IP address from 1xx.1xx.1xx.1xx


Leave a Reply

Your email address will not be published. Required fields are marked *

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