According to this question on Stack Overflow
- iptables is available in Android source distribution.
- 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.
- The only way to access iptables binary is to build your own Android images. Check out http://randomizedsort.blogspot.com/2010/08/building-android-and-linux-kernel-for.html. Once you get comfortable with that process, check out http://randomizedsort.blogspot.com/2011/03/porting-iptables-1410-to-android.html.
iptables
is a default module in aosp, 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 adb 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 "192.168.0.1" -j RETURN