How to forward traffic from eth0 to ppp0 on Android

瀏覽次數:706 次
跳到第一則未讀訊息

Riccardo Bruè

未讀,
2020年11月29日 晚上7:14:132020/11/29
收件者:android-porting
Hi, I am using Android 10 on a custom device. The Android image has been generated by AOSP.
I need to forward the traffico from the eth0 to the ppp0 (LTE module) interface.
I've managed to enable the ppp0 interface by using the pppd script (i.e.: `pppd call my-connection-info`) and I can see that I receive the two DNS server addresses and my public IPv4 successfully.
Now the first weird thing: If I ping to 8.8.8.8 I receive "connect: Network is unreachable" meanwhile if I specify the ppp0 interface with `ping -I ppp0 8.8.8.8` I can successfully ping the target.

Now I want to forward the eth0 traffic to the ppp0, to do so I've tried the following commands:

    $ echo 1 > /proc/sys/net/ipv4/ip_forward
    $ iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

But the PC on the other end of the eth0 interfce still prompts "From 192.168.10.1 icmp_seq=xxx Destination Net Unreachable" where 192.168.10.1 address is the Android device (which acts like a gateway).

This is the content of `netstat -rn` command:

    Kernel IP routing table
    Destination Gateway Genmask Flags   MSS Window  irtt Iface
    0.0.0.0         10.64.64.64     0.0.0.0         UG        0 0          0 ppp0
    10.64.64.64     0.0.0.0         255.255.255.255 UH        0 0          0 ppp0
    192.168.10.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0

This is the output of `netstat -rn`:

    default via 10.64.64.64 dev ppp0 
    10.64.64.64 dev ppp0 proto kernel scope link src 10.53.117.129 
    192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.1 

This is the output of `iptables -L` (which I've flushed with `iptables -F`, `iptables -X` and `iptables -t nat -F`):

    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination


Which is the issue here? Thank you.
回覆所有人
回覆作者
轉寄
0 則新訊息