Using your home IP as a residential proxy with a Raspbery


#1

A Raspberry is very wel suited to be used as a proxy server so you can use your home IP as a residental proxy in social media software.

Choosing a Raspberry:

Above you see the Raspberry 3b. The first thing you notice are the 4 (normal size) USB ports, the ethernet port, a micro USB port for power and a normal size HDMI port. This Raspberry has everything we need.
There are also other Raspberry’s we can use. Below you can see the Raspberry Pi Zero.

There are 2 versions, 1 with and 1 without WIFI. I use several of these myself. The one without WIFI can be used together with a “Micro USB 2.0 RJ45 Ethernet LAN Network Adapter 100 Mbps” like the one below.

I buy them on Aliexpress. They are cheap, usually about $4. If you buy them make sure that your adapter is supported by Linux. The ones with a chip called “RTL8152” are supported. A direct link (which works at this moment) is: https://nl.aliexpress.com/item/Micro-USB-2-0-To-RJ45-Ethernet-LAN-Network-Card-Adapter-100Mbps-For-Tablet-PC-For/32685366475.html

If you look at the Raspberry Zero you will see that the setup is more complicated and you need some extra adapters and cables. The HDMI port is small, you will need an adapter to connect it with your monitor. There are also only 2 micro USB ports. One is used for power. The other you need to connect your network adapter and keyboard. For this you will need a USB HUB (powered).

What to choose?

The Raspberry 3b is easy to setup. But with a price of $35 not the cheapest option. The Raspberry Zero’s are cheaper, the one without WIFI is about $5, the one with WIFI is about $10. But the Raspberry Zero is more difficult to setup and you need a lot of extra adapters and cables. If you are planning to use only 1 Raspberry I advice you to choose the Rasberry 3b. If you are planning to use a lot of Raspberry’s it can be worth it to invest in all the extra things you need for the setup of the Zero.

In this manual I will show you the setup of a Raspberry 3b.

Note: I assume that you are able to use SSH and a Linux text editor.

The Raspberry boots from a Micro SD card. For this you will need a bootimage called NOOBS. My supplier sells SD cards with NOOBS already on it. If your supplier doesn’t you can do it youself and use this manual: https://towardsdatascience.com/raspberry-pi-3-for-the-first-time-50634b115620 The part you need starts with “Format your micro SD card (FAT format)”.

I connected the Raspberry with a HDMI cable to my monitor, a keyboard, mouse and an ethernet cable are also connected. The micro SD card with NOOBS is in the card reader. Connecting the power supply will let the Raspberry boot.

I was surprised. My Raspberry booted directly without questions. I remember from the past that I was able to select if I wanted to install the desktop or not. Anyway, I have the desktop in front of me. You can check if everything works correctly by visting some websites using the browser.

The desktop is something you do not really need if you want to use the Raspberry as a proxy server only. But if you have more plans it can be a nice thing to have.

First we are going to enable SSH and change the password. We open the terminal (option in the top bar). There we enter the command:

sudo raspi-config

In advanced options we enable SSH, and in the same list we see the option to change the password.

After doing this we can remove the HDMI cable, the keyboard and mouse from the Raspberry. We will continue the setup using SSH.

Port forwarding in the ADSL/Cable modem/router.

Our setup will look like this:

Server or VPS with social media software -> Internet -> ADSL/Cable modem/router at home with external IP 123.123.123.123, internal IP 192.168.178.1 and port forwarding enabled -> ethernet cable -> Raspberry with internal IP 195.168.178.234.

It is a bit hard to explain, the setup will depend on your modem. Mine looks like this:

As you can see all incoming traffic to ports 22 (SSH) and 3129 (the proxy) are forwarded to the internal IP of the Raspberry. In addition I also made this IP a “Reserved IP addresses” in the DHCP section of the modem.

Now we should be able to login to the Raspberry from our Windows computer using SSH!

I use the Bitvise SSH client. It is free and works fine. We connect to the IP of our modem 123.123.123.123 with SSH using the login name “pi” and the password we configured before.

Install 3proxy:

-First update your software with the commands:

sudo apt-get update
sudo apt-get upgrade

-install an editor. I love joe.

sudo apt-get install joe

To install the other software we need to enter the commands:

sudo apt-get -y install fail2ban software-properties-common
sudo apt-get install build-essential libevent-dev libssl-dev
cd /etc
sudo wget https://gettraffic.pro/docs/3proxy-0.8.11.tar.gz
sudo tar zxvf 3proxy-0.8.11.tar.gz
sudo mv 3proxy-0.8.11 3proxy
cd 3proxy

We have to edit proxy.h with the command;

sudo joe src/proxy.h

Here we add the line:

#define ANONYMOUS 1

You can put it above the other lines starting with #define

Compile and install the software:

sudo make -f Makefile.Linux
sudo make -f Makefile.Linux install

Download 3proxy.cfg

sudo wget https://gettraffic.pro/docs/3proxy.cfg

We have to edit 3proxy.cfg:

sudo joe 3proxy.cfg

Change the line;

users root:CL:passwd

Where you replace the word passwd with the password you want to use for your proxies. This can be another password than the password you use for logging into your Raspberry.

You can delete all the lines starting with “proxy” and replace them with 1 line:
proxy -p3129 -a

I commented out the logging part, to save the SD card.

Finally your 3proxy.cfg will look like this:

change the permissions of 3proxy.cfg with the command:

sudo chmod 700 3proxy.cfg

Setup/Download the other config files:

cd /etc/3proxy/scripts/rc.d/
sudo mv proxy.sh saved-proxy.sh
sudo wget https://gettraffic.pro/docs/proxy.sh

Now we can start our proxy server with the command:

sudo sh /etc/3proxy/scripts/rc.d/proxy.sh start

It should give the output “Starting 3Proxy”. If it doesn’t then there is a problem somewhere in your config files.

Let’s add it to autorun, so after a reboot of your Raspberry it will run by itself:

sudo joe /etc/rc.local

and add line:

sh /etc/3proxy/scripts/rc.d/proxy.sh start

This line has to be added above the line “exit 0”.

The best way to check if everything is alright is by doing a full reboot of your Raspberry and checking if everything still works after the reboot.:

sudo shutdown -r now

And that is it!

You can use your proxy with port number; 123.123.123.123:3129
In the example I used the port number 3129. It can be better to change it to something else. Of course you will have to change it everywhere, in the modem with port forwarding, in 3proxy.cfg etc.

Some people have home IP’s which are not static. After a reboot the IP will change, and you will not be able to connect to your Raspberry anymore. Fortunately there is a solution for that. We will use no-ip.com to make a domain name and update the DNS with a script every time our IP changes.

-Make an account at no-ip.com
-Create a hostname like “abc123.ddns.net

It will look like this:

After this you can install a script on your Raspberry that will update the DNS at no-ip with your changing home IP. The manual is on https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client-on-ubuntu/

Now you will be able to use your proxy with abc123.ddns.net:3129

I hope it is clear to everyone :sunglasses:


#2

Nice share @dimitri

Just a suggestions since you made such a nice guide…

Perhaps you should sell ready made images?


#3

Cool and useful )


#4

Before somebody else tries to steal your work, claim it as their own and take advantage of free content, specifically. But hey, where would that ever happen?

Also nice work :sunglasses:


#5

Great Guide @dimitri , did you think about hosting the sh and config file on github? Might be a bit less risk if your hosting will be compromised one day.


#6

Thanks for the share,
though I don’t need it, I know a lot of people on the forum that will love this!


#7

Great stuff thank you.


#8

Will be trying this out later today. Thank you


#9

Excellent guide, thanks Dimitri :grinning::ok_hand:

I’ve been using a similar setup with some other hardware instead of PI’s, but I might just have to do a cost analysis and see if this is a better option. How does the Raspberry hold up to random power cuts? We get a few of those around here.

This is a useful site for when you need to do port forwarding on an unknown router:
https://portforward.com/router.htm

Usually between that site, youtube, and the ISP site, I can figure how to configure an unknown router. I’ve seen a few fiddly ones.


#10

Nice guide. I am sure this will help a lot of people :slight_smile:

How does raspberry pi zero work with the microusb adapter? Are they stable? It is clear that it will never be the same as a native network port, but just curious.


#11

We do not have power cuts here. I cannot remember the last time that happened. But I do know that I can pull the plug without much problems :wink: It boots from a SD card. Till now no bad things happened.


#12

It is ethernet over USB2. I once tried, and it did about 20 mbits. It is not much, but enough for IG.

The next step is a Raspberry as a mobile proxy server :blush:


#13

And 4 times as much as my home w-lan :smiley:


#14

@dimitri why not using the same hub method? :sweat_smile:


#15

Do you have a 5 mbits internet connection at home?


#16

I do. These mobile proxies work with the Raspberry as a server.

It is eactly the same setup as above. Only wvdial and ppp added.


#17

yes Internet is horrible where I live :smiley:
I am paying for 40 but it barely ever happens to be that high


#18

got ya , by the way, isn’t those modems speed above 20MBps?


#19

Probably you are right. But data is expensive here. I found data plans, unlimited but capped at 128 kpbs :roll_eyes: for 9 Euro a month.

128 kbps isn’t much, but with Instagram it works fine. Still have to test how much accounts I can use with each modem. I now have about 5 accounts on each. It is slow, but actions are done. And likes are also no problem.


#20

What I meant is, that you said your modems are running at 20Mbps~ , but isn’t their max speed much higher? )