How to forward traffic from eth0 to ppp0 (AOSP embedded project) - Networking

I am using Android 10 on a custom device (Variscite imx8). The Android image has been generated by AOSP.
I need to forward the traffico from the eth0 to the ppp0 (Quectel 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. I've added the following routing table with priority 25000 so that I'm able to ping 8.8.8.8 without specifying the interface:
Code:
ip rule add prio 250000 from all lookup 25000
ip rule add table 25000 default via <my-public-ip> dev ppp0
Now I want to forward the eth0 traffic to the ppp0, to do so I've tried the following commands:
Code:
$ 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:
Code:
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:
Code:
default via 10.64.64.64 dev ppp0
10.64.64.64 dev ppp0 proto kernel scope link src <my-public-ip>
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):
Code:
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.

Related

isdn > linux-pbx > SIP > BT-Bridge > XDA2

Hi,
today i received my first ISDN call on my MDA2
- get you ISDN-Card working under Linux
- install asterisk
- install bluez
- install brctr
- BluetoothGPS.cab
- install X-Lite on the XDA2
Code:
/etc/asterisk/modem.conf
[interfaces]
context=remote
driver=i4l
stripmsd=1
dialtype=tone
mode=immediate
msn=YourMSN
device => /dev/ttyI5
/etc/asterisk/sip.conf
[general]
[olli]
type=friend
username=olli
host=dynamic
canreinvite=no
add somthing like:
exten => 500,2,Dial(SIP/olli)
[from-sip]
exten => olli,1,Dial(SIP/olli)
exten => olli,2,Hangup
in the /etc/asterisk/extensions.conf
Give the XDA a static IP and connect to the
Bluez(0) Network Accesspoint.
Than configure the BT-Bridge:
Code:
modprobe usb-uhci
modprobe uhci
modprobe usbcore
mount /proc/bus/usb/
modprobe bluez
modprobe l2cap
modprobe bnep
modprobe sco
modprobe rfcomm
modprobe hci_usb
hcid
sdpd
pand -s -r NAP -M
ifconfig eth0 down
ifconfig eth0 0.0.0.0
ifconfig bnep0 0.0.0.0
brctl addbr pan0
ifconfig pan0 192.168.1.19
brctl addif pan0 eth0
brctl addif pan0 bnep0
route del default
route add default gw 192.168.1.1 dev pan0
brctl showmacs pan0
ping the XDA.
Install X-lite
configure:
user: olli (see sip.conf)
sip-proxy: IP of the astrisk server
mark sent internal IP
Now your can receive IP and PSTN calls.
PSTN by dialing your MSN+500 from any phone.
Has anybody an idea how to configure asterisk
to forward SIP-Calls from the xda to PSTN ?
bye Olli
The XDA a static IP and connect to the
Bluez Network Accesspoint. how is the other?
_________________
Ip pbx

[How to] Change DNS server on Android phones

Domain Name System / Server is the one which takes care of translating the human readable domain names into machine understandable IP addresses. If you are not able to access a particular set of websites either from your laptop /phone, DNS server could be a reason for it. To fix the problem, one has to change the network configurations to use some of the popular DNS servers like Open DNS or Google’s public DNS. On Android phones, changing the DNS server is easy if you are using the static IP. You can do it from Settings > Wireless & network settings > Wi-Fi settings > Advanced (from menu) > check the ‘Use static IP’ option. After that, you will be able to change the DNS servers. However, when you are using dynamic IP (which will be the case most likely), the process is not straight forward. DNS server details will be taken from the DHCP server which assigns the IP.
Here are the steps to be followed to change the (WIFI Connection) DNS servers:
- Android system chooses the DNS servers using the script located at “/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf”
- By default, /system partition is mounted as read-only. Need to re-mount the same in re-write mode.
- Take a backup of the script. Download the modified version of the script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/20-dns.conf). The modified script has two additional lines which will override the DNS server changes. The modified script uses the Google’s public DNS.
- Changes will be applied after restarting the connection /device.
3G Connection:
- Download the wrapper script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/change-dns.sh) This wraps all the commands needed for changing the DNS server in a shell script.
- Download and install an interpreter for executing your shell script from your phone (e.s. scripter from Rom Toolbox)
- Launch the script. Grant the Super permission when asked.
- You just have to run this script whenever you are connecting to your mobile network.
Done. You settings are proper by visiting http://welcome.opendns.com. Remember, the settings will be applicable only for the current session.
By: http://blog.varunkumar.me/2010/09/how-to-change-dns-server-on-android.html?m=1
Or use Set DNS from Market
lol.. I cover my head with ashes!!!
I didn't know about these apps... I apologize!!!
uffapple said:
lol.. I cover my head with ashes!!!
I didn't know about these apps... I apologize!!!
Click to expand...
Click to collapse
your work isn't useless.. it tell me how it work.. thanks
Help
Help, after i did this i can't connect to Wi-Fi anymore. I copied the old 20-dns file and nothing u_u. Pls help
Override DNS for KitKat
uffapple said:
Domain Name System / Server is the one which takes care of translating the human readable domain names into machine understandable IP addresses. If you are not able to access a particular set of websites either from your laptop /phone, DNS server could be a reason for it. To fix the problem, one has to change the network configurations to use some of the popular DNS servers like Open DNS or Google’s public DNS. On Android phones, changing the DNS server is easy if you are using the static IP. You can do it from Settings > Wireless & network settings > Wi-Fi settings > Advanced (from menu) > check the ‘Use static IP’ option. After that, you will be able to change the DNS servers. However, when you are using dynamic IP (which will be the case most likely), the process is not straight forward. DNS server details will be taken from the DHCP server which assigns the IP.
Here are the steps to be followed to change the (WIFI Connection) DNS servers:
- Android system chooses the DNS servers using the script located at “/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf”
- By default, /system partition is mounted as read-only. Need to re-mount the same in re-write mode.
- Take a backup of the script. Download the modified version of the script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/20-dns.conf). The modified script has two additional lines which will override the DNS server changes. The modified script uses the Google’s public DNS.
- Changes will be applied after restarting the connection /device.
3G Connection:
- Download the wrapper script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/change-dns.sh) This wraps all the commands needed for changing the DNS server in a shell script.
- Download and install an interpreter for executing your shell script from your phone (e.s. scripter from Rom Toolbox)
- Launch the script. Grant the Super permission when asked.
- You just have to run this script whenever you are connecting to your mobile network.
Done. You settings are proper by visiting http://welcome.opendns.com. Remember, the settings will be applicable only for the current session.
By: http://blog.varunkumar.me/2010/09/how-to-change-dns-server-on-android.html?m=1
Click to expand...
Click to collapse
Thank you for sharing, but I have to say that the "setprop" method does not work on KitKat (I'm talking about mobile connections).
I wrote an app called "Override DNS for KitKat" to solve this issue. It's on the Play Store.
There's a much more reliable and easier method. Just use this as AFWall custom script or use manually in init.d (replace '$IPTABLES' with 'iptables' and just use the last 2 lines).
Code:
$IPTABLES -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53
$IPTABLES -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53
DualJoe said:
There's a much more reliable and easier method. Just use this as AFWall custom script or use manually in init.d (replace '$IPTABLES' with 'iptables' and just use the last 2 lines).
Code:
$IPTABLES -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53
$IPTABLES -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53
Click to expand...
Click to collapse
The "iptables" commands also works good on my Nexus 4 and Slimkat, thank you!

[Q] adhoc network problem

I have android 4.2.2 ,Nexus 4 I would like to setup adhoc network . Firstly I rooted the device, secondly I tried to create adhoc network in android phone : I create ad hoc network in an android smartphone like below:
[email protected]:/ # ip link set dev wlan0 down
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
[email protected]:/ # ip link set dev wlan0 up
[email protected]:/ # ifconfig wlan0 192.168.65.129
when I typed iwconfig wlan0: the result is:
Qcom:802.11n ESSID:"Test1"
Mode:Ad-Hoc Frequency:2.437 GHz Cell: 02:82:5F:C1:4B:C1
Bit Rate=0 kb/s Tx-Power=0 dBm
RTS thr=2347 B Fragment thr=8000 B
Encryption keyff
Secondly, in my laptop ,I could see "Test1",so I did connect to "Test1" and I configure static ip address 192.168.65.128. in this case ,the smartphone create the ad hoc network and my laptop join it,then I can ping from my laptop to mobile and vice-versa.
However,in other case when : my laptop create ad hoc network
and later in an android mobile ,I tried to join it :
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
But,when I type iwconfig wlan0 ,essid still off/any
Qcom:802.11n ESSIDff/any
Mode:Ad-Hoc Frequency:2.437 GHz Cell: Not-Associated
Bit Rate:0 kb/s Tx-Power=0 dBm
RTS thr=2347 B Fragment thr=8000 B
Encryption keyff
it seems that android mobile can create ad hoc network but can not join existing one.so the same result I found when I try to setup adhoc network between two android mobiles. can anybody tell me what it's wrong here,and if there is any possible solution.
I tried many methods to setup ad hoc network in android ,and only this method that it seems work,but it still something wrong that prevent android phone to join existing ad hoc network.
fadwa.ww said:
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
Click to expand...
Click to collapse
Did you forgot to execute "ip link set dev wlan0 up"?

[Q] USB Ethernet problem with Lollipop (GT-I9506)

Hi,
I'm trying to run my USB Ethernet dongle with my S4 LTE+ Lollipop D6, but aplications in the phone and other computers on the network didn't see that connection.
My tryings:
[email protected]:/ # netcfg eth0 up
[email protected]:/ # netcfg eth0 dhcp
[email protected]:/ # netcfg|grep eth0
eth0 UP 10.0.0.12/24 0x00001043 f0:25:b7:20:af:75
[email protected]:/ # ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=1.96 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=2.05 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=1.87 ms
[email protected]:/ # ping www.google.com
ping: unknown host www.google.com
2|[email protected]:/ # nslookup www.google.com
Server: 8.8.4.4
Address 1: 8.8.4.4 google-public-dns-b.google.com
Name: www.google.com
Address 1: 2a00:1450:4013:c01::93 ea-in-x93.1e100.net
Address 2: 74.125.136.104 ea-in-f104.1e100.net
Address 3: 74.125.136.103 ea-in-f103.1e100.net
Address 4: 74.125.136.99 ea-in-f99.1e100.net
Address 5: 74.125.136.105 ea-in-f105.1e100.net
Address 6: 74.125.136.147 ea-in-f147.
I've found this but it doesn't work also:
ndc network create 100
ndc network interface add 100 eth0
ndc network route add 100 eth0 <GATEWAY>/24
ndc network route add 100 eth0 0.0.0.0/0 <DNS1> <DNS2>
ndc resolver setnetdns 100 localdomain <DNS1> <DNS2>
ndc network default set 100
Any suggestions?
Thx
No body knows?
Hi
Have you tried this:
For Lollipop:
ndc resolver setnetdns eth0 "" 8.8.8.8 8.8.4.4​For Kitkat:
ndc resolver setifdns eth0 "" 8.8.8.8 8.8.4.4
ndc resolver setdefaultif eth0​Works for me on 5.1.1 (was able to ping 8.8.8.8 and 8.8.4.4 but not google.com. after typing this in the terminal, the ping worked !)

[SOLVED]How to OUTPUT only cellular data with iptables not working.

Goal: Only allow outgoing cellular data to specific DNS servers and a specific webserver using cellular mode on rooted android device.
Android phone #1: VkWorld F1 (Chipset. MT6580) running Android 5.1
Android phone #2: HUAWEI Y560-L01 running Android 5.1
Active interfaces on Android #1 when cellular mode is on.
Code:
lo UP 127.0.0.1/8
ccmni0 UP x.x.x.x/x
Active interfaces on Android #2 when cellular mode is on.
Code:
lo UP 127.0.0.1/8
rmnet_data0 UP x.x.x.x/x
This is my current simple iptables for testing on Android #1 and #2
Code:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -d 8.8.8.8 -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT //DNS
-A OUTPUT -d x.x.x.x -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT //webserver
-A OUTPUT -j DROP
These iptables rules works on Android device #2 or any Android phone that has 'rmnet' interface (from my own testing).
These iptables rules DO NOT work on Android device #1 or any Android phone that has 'ccmni' interface (from my own testing)
And if I add or change in my android #1 to
Code:
-A OUTPUT -o ccmni0 -d x.x.x.x -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
it can NOT still contact the destination ip.
However if I add this line before the last -j DROP rule it works
Code:
iptables -A OUTPUT -o ccmni0 -j ACCEPT
but this allows ccmni interface to talk freely to any website and makes my dns and webserver rule pointless.
Once again:
Devices rmnet interfaces = rules works.
Devices with ccmni interfaces = rules do not work.
[EDIT/SOLVED]
I used tcpdump and wireshark to see what might have gone wrong traffic, apparently my traffic had to go through a proxy from my provider that I blocked off in iptables. Why it still works fine with rmnet interfaces I have no clue.
volleb said:
I used tcpdump and wireshark to see what might have gone wrong traffic, apparently my traffic had to go through a proxy from my provider that I blocked off in iptables. Why it still works fine with rmnet interfaces I have no clue.
Click to expand...
Click to collapse
This is because in short it uses a different way to connect and this is only on MSM chipsets see this link while rmnet is and standard android fare

Categories

Resources