Ubuntu: Proxy on Ubuntu



Question:

The goal is to have Ubuntu machine act as a proxy for another machine on WAN. What is the simplest way to accomplish that?

To explain in more detail: There are two machines on the same WAN, but one of them can access the Internet and another one can't. It's possible to talk from one machine to another, though. So the point is to set up the proxy server on the Internet-able machine (having Ubuntu installed).

Note: This is not about using one machine as the bridge on the same LAN, that can be done easily, this is a different approach (as i understand it).


Solution:1

The very easy solution is to install a Proxy server package, such as polipo. For a single machine serving internet to one other device that is probably all you need to do.

sudo apt-get install polipo

Then just configure the polipo service to allow connections from the other device, for example un-comment and change the following lines in the /etc/polipo/config file:

proxyAddress = "0.0.0.0"

allowedClients = 192.168.56.0/24

Then restart the polipo server to update its configuration:

sudo /etc/init.d/polipo restart

The more complicated part is to convince your other device(s) to use the polipo proxy server. Setting a proxy depends entirely on the software on the non-directly connected machine.


Solution:2

My scenario involved the same thing with the only exception that the other machine (needing internet) was an Android tablet in my case. I used iptables for routing. It is an easy and out-of-the-box solution on Ubuntu/Debian platforms. Here is a sample routing script that you can run on the internet-enabled machine:

#Instead of ppp0, use the interface you use to access the internet  #Instead of wlan0, use the interface connected to your "internet-needy" machine  #####Enable Forwarding:  sysctl -w net.ipv4.ip_forward=1  iptables -P FORWARD ACCEPT    ###########Create NAT rules using IPTables  iptables --table nat --delete-chain  iptables --table nat -F  iptables --table nat -X  iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE  iptables -A FORWARD -i ppp0 -o wlan0 -j ACCEPT -m state --state RELATED,ESTABLISHED  iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT  ###########    #Allow through firewall  iptables -A OUTPUT --out-interface wlan0 -j ACCEPT  iptables -A INPUT --in-interface wlan0 -j ACCEPT  

Once you run this script, your ubuntu machine acts as a router between the internet-needy machine and the internet, forwarding the internet packets to and fro between them.

Just keep in mind that routing happens at a much lower level than proxying and thus is better in performance. The only disadvantage is that you can't do such things as filter out content or user-authentication based on the proxy client. However, if you just want internet-sharing with good performance, I recommend this method.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »