Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How i can set iptables rule like this on my rooted Android phone:

iptables -t nat -A PREROUTING -i wlan0 -s -p tcp --dport 80 -j DNAT -–to-destination

... since Android iptables implementation doesn't support protocol by name and DNAT?

share|improve this question
up vote 3 down vote accepted

According to this question on Stack Overflow

  1. iptables is available in Android source distribution.
  2. Users of retail Android devices cannot access iptables binary. Even Android OS itself cannot access that binary. This is hard-coded in Android. Many devices also don't have iptables at all.
  3. The only way to access iptables binary is to build your own Android images. Check out Once you get comfortable with that process, check out

iptables is a default module in , you can use netfilter to write c code to handle that.

For example, you can create an android project, and write a JNI file, use ndk-build to compile that, and then push the executable to the android file system to execute. And in the mobile end, you can adb shell to it, directly use iptables command as a root user, just like in Linux.

To check if your device supports iptables:

Issue the following command in ADB shell or in Terminal Emulator:

iptables -L -t nat

Alternatively you could try the beta of IP Tables app on Google Play to see if it does what you want.

There is also Droid Wall that you could try. It supports scripts that may help, e.g.

$IPTABLES -A "droidwall" --destination "" -j RETURN
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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