Ubuntu – Using ap-hotspot to share a proxy connection

14.04hot-spot

I know I can use ap-hotspot to configure a wifi hotspot in normal connection. But what is I'm connected to internet via a socks proxy? How can I share internet to my mobile devices then?

Best Answer

The ap-hotspot solution is slightly out of date and has the added disadvantages of being complicated and incompatible with socks proxies. A simpler solution is to use ubuntu's built in network-manager to create the hotspot as detailed by http://ubuntuhandbook.org/index.php/2014/09/3-ways-create-wifi-hotspot-ubuntu/

TCP traffic from the hotspot can be passed through the ssh -D socks proxy using redsocks. With redsocks installed and configured one can use iptables to redirect all traffic from the wifi hotspot to redsocks which then passes it through the socks proxy.

For instance if your wifi hotspot is on the 10.42.0.1/24 subnet and the incoming redsocks port is 12345 issue:

sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t nat -A PREROUTING -s 10.42.0.0/24 -p tcp -j REDIRECT --to-ports 12345

For a detailed set of instructions visit http://abidmujtaba.blogspot.com/2016/07/ubuntu-create-wifi-hotspot-access-point.html