routing difference between linux and Android (Lollipop) - Android General

I'm trying to set up a lollipop-TV-box with wlan and lan adapter as a router the way I did it with a Linux-box, but it doesn't work
I tried it the Linux-way on a linux-Machine with a shell-script. The wlan-net is 192.168.0.x the lan is 192.168.1.x. The wlan-ip in the Android/Linux router is 192.168.0.13 the lan in the same device is 192.168.1.2, the connected lan-client-ip is 192.168.2.4
the routing is Internet-(Wifi)-Gateway 192.168.0.1->Android/Linux-Box 192.168.0.13/192.168.1.2->192.168.2.4 and vice-versa
on lan-client:
ip route:
default via 192.168.1.2 dev eth0 proto static metric 1024
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.4
on Android/Linux-Router
192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.13 metric 600
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.2 metric 100
I also enabled forwarding and set the forward-tables with iptables
With the Linux-Box as a router everything works like a charm, with Android not, when I ping the lan-ip of the client from the Android box (ping 192.168.1.4) the reply is network unreachable from the external internet-server
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
From 84.116.198.82: icmp_seq=7 Destination Net Unreachable
From 84.116.198.82: icmp_seq=8 Destination Net Unreachable
From 84.116.198.82: icmp_seq=17 Destination Net Unreachable
I have to specify the interface with ping -I eth0 192.168.1.4, then it works, although this should already be specified by the local routes, like if the local request is routed over the public gateway. Looks like in Android the local routing is overriden by a hidden route to the default gateway.
So, what is the difference?

Related

What api decide whether connect to internet?

hi,ALL.
I have two ppc,A and B, A create a bluetooth PAN access point,B connect to A(especial reason,only B connect to A,not A connect to B).B have two network adapter,And B use NAT service.
A ip 192.168.0.1
mask 255.255.255.0
gateway 192.168.0.2
B ip 192.168.0.2
mask 255.255.255.0
gateway none
WiFi ip 192.168.1.2
mask 255.255.255.0
gateway 192.168.1.1 (This interface connect to internet)
Now, On A ppc,a few tool app can connect to internet,but PIE can't connect to internet,I think PIE use ConnMgrConnectionStatus api check status. What api can resolve this problem?

[Q] How to get a local IP of the interface that directly connects to default gateway

-Environment-
1.VPN connection(OpenVPN)
- Default gateway is changed into VPN server IP
- Virtual interface(tunXX) for VPN connection directly connects to a default gateway
2.Interfaces & default gateway
interfaces :
- lo inet addr:127.0.0.1
- wlan0 inet addr:150.149.131.5
- tun0 inet addr:10.8.0.14
default gateway : 10.8.0.2
In this environment, I want to know "10.8.0.14" regardless of the interface name using Android API.
I cound find only a way to get default route IP address below
Code:
mSocket = new Socket(dstAddress, peerPortNum);
mStrMyIPAddr = mSocket.getLocalAddress().getHostAddress();
But, I don not want to use Socket

Problem with VPN tether gateway setup

I have a G930F running Superman ROM rooted on MM with a ported XAA CSC. I have set it up to run a VPN gateway using iptables and ip route. I am able to get tethered devices to connect to the Internet through the VPN if I manually set the IP addresses and DNS servers on the clients connecting. I do however have some devices that do not have the ability to manually set the IP and DNS servers and it's also a pain to set every device up manually. I ran a Wireshark capture and found several ARP requests not being responded to from dhcpd/dnsmasq trying to hand out ip addresses to the clients. My goal is to get DHCP up and running on wlan0 to hand out IP and DNS configuration. I suspect it is not working due to the nature of the changes I've made with iptables and ip route. I'm thinking the dhcp is being forwarded to the tun0 interface. My question is how to exclude the DHCP from being forwarded to the tun0 interface... Or if someone else can come up with a more elegant solution to my problem, as I'm currently reading up on ip and iptables syntax and commands and my current knowledge is fairly basic. The process I'm using to connect my tethered devices is as follows: connect VPN, turn on tether, run commands listed below to connect the wlan0 and tun0 interfaces and connect clients to the phone after manually setting the IP and DNS.
Code:
su
iptables -t filter -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t filter -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
ip rule add from 192.168.43.0/24 lookup 61
ip route add default dev tun0 scope link table 61
ip route add 192.168.43.0/24 dev wlan0 scope link table 61
ip route add broadcast 255.255.255.255 dev wlan0 scope link table 61
Any help would be greatly appreciated!
SystematiQ said:
Any help would be greatly appreciated!
Click to expand...
Click to collapse
Did you ever get this to work nicely? I am very intrigued.
Also, what VPN software are you using? I am using NCP which does most of what I want, though it is frustrating that I can't programmatically control connection/disconnection/profile selection nor even get it to connect at boot.

USB-tether (cell phone to router).Trying to Port-Forward 554 from phone to router

I have a static ip cell phone, LTE service with public address: 25.25.25.25
USB-Tethered to an asus router
Router has WAN address of: 192.168.42.134,
Gateway and DNS is:192.168.43.129,
I Port-Forward 80,8080,554,etc... to Desktop Computer
Desktop Computer has HTTP Server and Darwin Streaming Server
Listening on 80,8080,554
Lan address is:192.168.1.2
I got the http server working by using an app on the cellphone called PortForarder https://play.google.com/store/apps/details?id=at.bherbst.net&hl=en
I forwarded port 8080 for incoming and 80 for target
...in settings I entered rmnet0 (25.25.25.25)for Public Interface (other choices were Lo(127.0.0.1),rndis0(192.168.42.129)
...for Target I entered router (192.168.42.134)
From the Outside (on a different internet connection)I'm able to access my html server with this http://25.25.25.25:8080
My Problem:
The app (portforwarder) is for non rooted phones, it will not let you forward ports lower than 1024,hence I cannot access my smtp stream on port 544
I'm trying to figure if the app uses iptables or routes traffic thru adb for forwarding
there are other portforwading apps for rooted phones that do use iptables (can allow to portforward lower than 1024) but I cannot get them to work with usb-tethering, it just may be I'm not understanding the correct iptable to write.
Can someone help me write an ip table that port forwards 544 from public interface(cell phone) to target host (router)
ca
Homefix said:
I have a static ip cell phone, LTE service with public address: 25.25.25.25
USB-Tethered to an asus router
Router has WAN address of: 192.168.42.134,
Gateway and DNS is:192.168.43.129,
I Port-Forward 80,8080,554,etc... to Desktop Computer
Desktop Computer has HTTP Server and Darwin Streaming Server
Listening on 80,8080,554
Lan address is:192.168.1.2
I got the http server working by using an app on the cellphone called PortForarder https://play.google.com/store/apps/details?id=at.bherbst.net&hl=en
I forwarded port 8080 for incoming and 80 for target
...in settings I entered rmnet0 (25.25.25.25)for Public Interface (other choices were Lo(127.0.0.1),rndis0(192.168.42.129)
...for Target I entered router (192.168.42.134)
From the Outside (on a different internet connection)I'm able to access my html server with this http://25.25.25.25:8080
My Problem:
The app (portforwarder) is for non rooted phones, it will not let you forward ports lower than 1024,hence I cannot access my smtp stream on port 544
I'm trying to figure if the app uses iptables or routes traffic thru adb for forwarding
there are other portforwading apps for rooted phones that do use iptables (can allow to portforward lower than 1024) but I cannot get them to work with usb-tethering, it just may be I'm not understanding the correct iptable to write.
Can someone help me write an ip table that port forwards 544 from public interface(cell phone) to target host (router)
ca
Click to expand...
Click to collapse
Not sure you can, and if you can, not sure it's allowed.
Sent from my SM-S903VL using Tapatalk

USB-tether (cell phone to router).Trying to Port-Forward 554 from phone to router

I have a static ip cell phone, LTE service with public address: 25.25.25.25
USB-Tethered to an asus router
Router has WAN address of: 192.168.42.134,
Gateway and DNS is:192.168.43.129,
I Port-Forward 80,8080,554,etc... to Desktop Computer
Desktop Computer has HTTP Server and Darwin Streaming Server
Listening on 80,8080,554
Lan address is:192.168.1.2
I got the http server working by using an app on the cellphone called PortForarder https://play.google.com/store/apps/details?id=at.bherbst.net&hl=en
I forwarded port 8080 for incoming and 80 for target
...in settings I entered rmnet0 (25.25.25.25)for Public Interface (other choices were Lo(127.0.0.1),rndis0(192.168.42.129)
...for Target I entered router (192.168.42.134)
From the Outside (on a different internet connection)I'm able to access my html server with this http://25.25.25.25:8080
My Problem:
The app (portforwarder) is for non rooted phones, it will not let you forward ports lower than 1024,hence I cannot access my smtp stream on port 544
I'm trying to figure if the app uses iptables or routes traffic thru adb for forwarding
there are other portforwading apps for rooted phones that do use iptables (can allow to portforward lower than 1024) but I cannot get them to work with usb-tethering, it just may be I'm not understanding the correct iptable to write.
Can someone help me write an ip table that port forwards 544 from public interface(cell phone) to target host (router)
ca

Categories

Resources