I try to iptables -A OUTPUT -p tcp --sport 5228 -j DROP but it comes to failure messages:
FIX ME! implement getprotobyname() bionic/libc/bionic/stubs.c:378
I have an rooted device and busybox on it. Strange is that if I see the rules list of iptables this port is in it. I´m not sure does it work? What is my problem?
Seems like a known bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=558415
It lists workarounds if you're interested.
Use protocol numbers (-p 6) instead of names (-p tcp):
iptables -A OUTPUT -p 6 --sport 5228 -j DROP
See this answer for more info:
getprotobyname error iptables
Related
I am using Genymotion emulator for Testing My proxy.So I need use iptables to redirect all tcp data to my proxy Port.
when I use
iptables -t nat -N REDSOCKS
it prints 'can't initialize iptables table `nat': Table does not exist (do you need to insmod?)'
But when I use
iptables -L
it prints the default table 'filter' complete chains.
'nat' and 'filter' are default tables in netfilter, Why nat table does not exist?
Users of retail Android devices cannot access iptables binary. Even Android OS itself cannot access that binary.
Source.
A few general things about routing with iptables.
Dont forget to enable routing .
sudo sysctl net.ipv4.ip_forward=1
or
echo 1 > /proc/sys/net/ipv4/ip_forward
and
iptables -t nat -A PREROUTING -i $device -p tcp --dport $srcPortNumber
-j REDIRECT --to-port $dstPortNumber
For example, in Android, the PID of a process 1234 is using ports 2222,2223,2224. Now I have a PID 1234. I was wondering how to find out port numbers 2222, 2223, 2224 which the process is using?
I have tried using netstat -anp just as the way in Linux, but that didn't work. netstat -anp in ADB shell has the same effect as just netstat, which is without any command arguments.
You can either use busybox netstat -pt or cat /proc/1234/net/tcp
Try to check my github repository, https://github.com/LipiLee/netstat.
I updated toolbox's netstat in Android source code(https://android.googlesource.com/platform/system/core/+/master/toolbox/netstat.c).
UPDATE: The toolbox's netstat was replaced with toybox's netstat in Android M version. So the netstat in toolbox was removed in the Android source tree.
I have had searched in API reference for a class/method to enable USB tethering, but found none. I wonder if it's still possible.
For information, I use a rooted HTC Wildfire with Cyanogenmod 7 and Android 2.3.7.
If it's not possible, I'm interested for a Java sample code to do it.
Not using the built in APIs (as you've checked), which simply means no, not if you're not willing to do a bit of work.
If, however, you are using Beanshell, JRuby or Rhino, then as per the SL4A FAQ ("API bridge?" question), "you can invoke Java calls directly" suggesting to "See the documentation for those interpreters" for how to do so (though I couldn't find it). However on the Unofficial Releases page, it states that:
"Beanshell and Rhino can both directly access the android api.
However, many Android api calls required a context, which, due to the
way they are run, these interpreters don't have. A solution is being
sought... suggestions appreciated."
And as per this answer, I believe a Context is required, though I may be wrong.
Finally, your last option would be to clone the source code for whatever interpreter you're using and add the call(s) your require. Quoting the FAQ again; "The RPC layer is easy to extend." and there's even a little walkthrough for it.
Good luck!
If you have root enabled, you by just try to do it whithoug SL4A or Android. I use this script:
#!/system/bin/sh
iptables -D droidwall-3g -m owner --uid-owner 0 -j RETURN
iptables -I droidwall-3g -m owner --uid-owner 0 -j RETURN
iptables -t nat -D POSTROUTING -o rmnet0 -j MASQUERADE
iptables -t nat -I POSTROUTING -o rmnet0 -j MASQUERADE
echo 1 > /sys/class/usb_composite/rndis/enable
ifconfig usb0 192.168.42.129 up
echo 1 > /proc/sys/net/ipv4/conf/usb0/forwarding
echo 1 > /proc/sys/net/ipv4/conf/rmnet0/forwarding
Maybe for other devices (mine is SE Xperia X10) you need to adjust things like /sys/class/usb_composite/rndis/enable.
I have downloaded the Android kernel sources from http://source.android.com/source/building-kernels.html
I have then started the emulator and wanted to play with iptable rules but I get this following error. Is the iptable package not fully installed? why is NAT table missing?
Initially I had started following http://randomizedsort.blogspot.de/2011/03/porting-iptables-1410-to-android.html#comment-form_8482839589527760177 to install iptables, but having seen iptablesv1.4.11.1 on the adb shell, I had abandoned the idea. Has anybody tried porting iptables on newer android kernel sources??
adb shell
# su root
# iptables -t nat -A OUTPUT -p tcp --dport 8000 -j REDIRECT --to-port 8080
FIX ME! implement getprotobyname() bionic/libc/bionic/stubs.c:450
iptables v1.4.11.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
Please advise!
Use protocol numbers (-p 6) instead of names (-p tcp):
iptables -t nat -A OUTPUT -p 6 --dport 8000 -j REDIRECT --to-port 8080
See this answer for more info:
getprotobyname error iptables
I am trying to setup a proxy on an Android device using iptables. We are using Androd 2.3. I don't see iptables in emulator or in our platform build.
Where can I download a prebuilt iptables binary (and all supporting libs it needs) for setting up a NAT like rule?
I like to run it like this eventually:
iptables -t nat -A PREROUTING -p tcp --dport 24 -j REDIRECT --to-port 7060
Thanks
I'm not aware of any pre-built iptables binary that android is supposed to have. That said, you could probably build iptabels for you device using the source code found here.