Good morning gentlemen, my RPi 2 is a working access point with two WiFi dongles (each with its own range of IP addresses); the RPi is also connected via LAN cable to my modem.

It offers the most basic service of access point/proxy: it takes incoming connections on both WiFi interfaces and send data to my modem via LAN cable, to the outside Internet.

So far so good: now I want to make my RPi a QOS manager: not only it will send and receive data, but it will give priority to some particular type of connections (e.g., streaming over SMTP).

A program of mine will do so, but I tested it only on my laptop and now I will put my program in my RPi. My program accepts incoming connections on a fixed port (8000): on my laptop, I installed a plugin on my browser which redirects traffic on port 8000, and it seems to work all fine.

Now I'm going to put it on RPi, but I don't know how to redirect traffic from both WiFi dongles to my program on port 8000.

I lack of knowledge about routing, but I think this can be accomplished with two iptables rules, somethink like:

iptables -t nat -A PREROUTING -i wlan0 -p tcp -j REDIRECT --to-port 8000
iptables -t nat -A PREROUTING -i wlan1 -p tcp -j REDIRECT --to-port 8000

Yet, these two rules does not seem to apply: running my program on my RPi with the two iptables rules shows no output, so connections are not really redirected to port 8000, to which my program is actually listening.

I saw some examples where redirecting needs a --dport flag too, but I don't know what this port would be.

These are my current iptables rules on RPi:

-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan1 -o eth0 -j ACCEPT

Your Answer

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

Browse other questions tagged or ask your own question.