I have a laptop with linux installed on it. The laptop has two network interfaces: eth0 and wlan0. Normally I surf the Internet through eth0, and I've successfully set up a hotspot in linux for my kindle to use. Important codes are as follows:

# Enable NAT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/ap-hotspot.conf

Usually I would like to surf the Internet through an encrypted socks5 proxy:, and I want the proxy system-wide, so I installed redsocks, which can redirect all the TCP connections to the socks5 proxy. Important codes are as follows:

#redsocks requires all the data to be redirected to port 12345, and the socks5 address and port( has been written to redsocks's configuration file.
sudo iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-port 12345

So far, It seems everything works great. My kindle can connect to the hotspot, and I can surf the Internet through a system-wide proxy in linux. The problem is, my kindle bypasses the socks5 proxy and connects to the Internet directly. So how to make my kindle go through the proxy when using the hotspot? I mean, how to do it in linux, because there's no way to set up a proxy in my kindle.

migrated from serverfault.com Dec 26 '14 at 19:24

This question came from our site for system and network administrators.

  • Did you get a solution for this problem? – Kamal Aug 11 '15 at 14:57

I have not had any experience with hostapd, but chances are that it modifies the routing table (and maybe even iptables).

after you start hostapd, it may be a good idea to run

netstat -nr

iptables -t nat -L

iptables -t filter -L

and try to work out where the packets are heading.

then, crank up your redsocks and have a new look at the full iptables setup

let me know those outputs, i may be able to help


I have a similar set up. wlan0 is connected to the internet (through my router) while wlan1 acts as a hotspot (Access Point) for my Android phone. wlan1 is set up with ipv4 address that is my phone gets ip address in the 10.0.0.x range.

The iptables rule I use to pass all traffic from my phone through redsocks is:

sudo iptables -t nat -A PREROUTING -s -p tcp -j REDIRECT --to-ports 12345

As far as I understand it this rule basically takes all tcp traffic from any source device with address and redirects it to the 12345 port which passes it through redsocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.