Android usbnet networking setup - Android Q&A, Help & Troubleshooting

Hello there!
I have android 10 based device and I have troubles with configuring usbnet device automatically.
I've modified kernel config, added `CONFIG_USB_USBNET=y` etc. Now I have usb0 device, and I can assign ip and routing to it, but it seems that there is another layer of networking setup in android: utility named ndc.
I tried next script:
```
ip link set usb0 up
ip addr add 192.168.1.2/24 dev usb0
ndc network create 101
ndc network interface add 101 usb0
ndc network route add 101 usb0 192.168.1.0/24
ndc network default set 101
```
Now I can ping device on the other side of usb0 interface but I'm losing wlan0 connection. Sure I can do next:
```
ndc network interface add 101 wlan0
ndc network route add 101 wlan0 0.0.0.0/0 10.0.0.1
ndc resolver setifdns wlan0 8.8.8.8 8.8.4.4
```
I also tried to modify default ROM:
uncomment in frameworks/base/core/res/res/values/config.xml
```
<string translatable="false" name="config_usb_ethernet_iface_regex">usb\\d</string>
<!-- Configuration of Ethernet interfaces in the following format:
<interface name|mac address>;[Network Capabilities];[IP config];[Override Transport]
Where
[Network Capabilities] Optional. A comma seprated list of network capabilities.
Values must be from NetworkCapabilities#NET_CAPABILITIES_* constants.
[IP config] Optional. If empty or not specified - DHCP will be used, otherwise
use the following format to specify static IP configuration:
ip=<ip-address/mask> gateway=<ip-address> dns=<comma-sep-ip-addresses>
domains=<comma-sep-domains>
[Override Transport] Optional. An override network transport type to allow
the propagation of an interface type on the other end of a local Ethernet
interface. Value must be from NetworkCapabilities#TRANSPORT_* constants. If
left out, this will default to TRANSPORT_ETHERNET.
-->
<string-array translatable="false" name="config_ethernet_interfaces">
<!--
<item>eth1;12,13,14,15;ip=192.168.0.10/24 gateway=192.168.0.1 dns=4.4.4.4,8.8.8.8</item>
<item>eth2;;ip=192.168.0.11/24</item>
<item>eth3;12,13,14,15;ip=192.168.0.12/24;1</item>
-->
<item>usb0;13,14,15;ip=192.168.1.2/24;8</item> #this line
</string-array>
```
But no luck usb0 interface remain unconfigured after boot.
After that I can ping both usb0 peer and wlan0 direct gateway but default route(0.0.0.0/0) not working. Don't understand why...
In general, I have 2 questions:
1. how to automate IP configuration for usb0 network in time of building ROM?
2. how to make usb0 and wlan0 play well together? Ideally without creating new network via ndc etc.
3. Are there any manuals about network configuration?

Related

[Q] Problem with openvpn on Archos 101

Hi,
Last week I received my Archos 101. In general it is great. Even better is this forum
I installed urukdroid (thanks to the project-team!). I tried to use openvpn but it failed and I am not sure about the reason.
The server-configuration is
...
ifconfig-pool 10.10.10.120 10.10.10.130
push "route 10.10.10.1"
route 10.10.10.0 255.255.255.0
ifconfig 10.10.10.1 255.255.255.0
push "route-gateway 10.10.10.1"
push "route 10.10.10.0 255.255.255.0"
...
As the Archos is the only device it would get IP 10.10.10.120.
BUT: ifconfig shows:
inet addr.: 10.10.10.255 Bcast: 10.255.255.255 Mask 255.0.0.0
That did (and cannot) work. No ping to home network possible.
When I called route it looked fine (I used redirect-gateway).
When I send the command
ifconfig tap0 10.10.10.120 broadcast 10.10.10.1 netmask 255.255.255.0
from Archos Terminal I had at least access to my home network. But all route entries are gone.
Who has an idea what I am doing wrong? I checked it in the last day again and again... If there is no solution: is it possible to 'save' the entries from route and restore it after my manual change of ifconfig? I would like to do it via script, as my home network I only reachable via dyndns.
Thanks and best regards!
I used the OpenVPN Howto Quickstart and had no problems.
macemoneta said:
I used the OpenVPN Howto Quickstart and had no problems.
Click to expand...
Click to collapse
Yes, I know the guide. I did the same with my ubuntu-netbook and it works directly.
And I think, it would work also on the Archos, if the openvpn/ifconfig on Archos accept the 10.10.10.120. But the IP is changed to 10.10.10.255 and that did not fit.
Where the h*** did the 255 instead of 120 come from?
I noticed the same problem...
No idea where it comes from, but as a workaround, you can put a script somewhere containing a suitable "ip addr add x.x.x.x/y dev z" statement, and reference that in the .conf file as "up scriptname".
Note that you need to add "--script-security 2" to the openvpn commandline to make that work. I added that to the OPENVPN_CFG variable in /etc/uruk.conf/openvpn.
regards
Patrick
This is the openvpn configuration I use for my Archos 101 (on the server). I'm not having any problems, using openvpn 2.1.1:
Code:
port 1194
dev tun
tls-server
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/[COLOR="Blue"]<my host>[/COLOR].crt
key /etc/openvpn/keys/[COLOR="blue"]<my host>[/COLOR].key
dh /etc/openvpn/keys/dh1024.pem
mode server
ifconfig 10.8.0.1 10.8.0.2
ifconfig-pool 10.8.0.4 10.8.0.255
push "route 10.8.0.1 255.255.255.255"
client-config-dir ccd
push "redirect-gateway def1"
push "dhcp-option DOMAIN [COLOR="Blue"]<my domain>[/COLOR]"
push "dhcp-option DNS [COLOR="blue"]<my dns server>[/COLOR]"
keepalive 10 60
inactive 3600
route 10.8.0.0 255.255.255.0
user openvpn
group openvpn
persist-tun
persist-key
verb 4
I examined the situation a bit further.
The problem comes from the ifconfig command that openvpn calls itself:
Code:
/system/bin/ifconfig myvpn \
192.168.x.41 \
netmask 255.255.255.0 \
mtu 1500 \
broadcast 192.168.x.255
This is only used when tap interfaces are involved, which is the case in my setup, but not in the setup macemoneta is showing. caesar68: do you also use tap interfaces?
I can reproduce the problem by just using that ifconfig command again.
When I list the IP-address-to-set as the last argument, instead, it works, i.e.
Code:
/system/bin/ifconfig myvpn \
netmask 255.255.255.0 \
mtu 1500 \
broadcast 192.168.x.255 \
192.168.x.41
A quick scanning of the openvpn manpage, does not suggest a way to override the ifconfig command that is used, but it does give an option --ifconfig-noexec which suppresses its calling.
Unfortuntely, when I just pack the is-working-after-the-interface-is-up ifconfig command into an up script with this option, it just gives me an error SIOCSIFNETMASK (Cannot assign requested address) - even if the same commandline works when I run it over an already upped interface... Probably because the interface then already had an IP address...
No problem, though, ifconfig is obsolete anyway, let us just use ip link and ip addr, which are fortunately available under Uruk.
So, caesar68, the clean solution would be to have
--script-security 2 on the openvpn commandline, e.g. via OPENVPN_CFG in /etc/uruk.conf/openvpn
in your myvpn.conf file:
Code:
ifconfig-noexec
up-delay
up-restart
up /etc/openvpn/myvpn-on-up
a corresponding script /etc/openvpn/myvpn-on-up, executable, with content
Code:
#! /system/bin/sh
ip link set $dev mtu $tun_mtu up
ip addr add $ifconfig_local/$ifconfig_netmask \
broadcast $ifconfig_broadcast \
dev $dev
Works For Me
Thanks for the explanation and the workaround, brian_o'fish. Why are you using tap though? Tap provides an Ethernet bridge, so you'll be transporting packets that really don't need to be sent to your Archos (reducing available bandwidth). Tun is layer 3 routed, so only traffic destined for either endpoint goes over the VPN connection.
macemoneta said:
Why are you using tap though?
Click to expand...
Click to collapse
That's what the server I'm using, is configured to do, as it provides transparant bridged LAN access via VPN, and that is what I want, as I am the admin of said LAN and VPN.
If the low level of broadcasts we have, ever increases or appears to be a problem to me, I'll set up an additional tun server, but for now it is simply not an issue.
Anyway, good hint in general!
Hi all!
Thanks a lot for your comments. Yes I am using tap. I would like to have access to my home network (storage etc.). Therefore I want to use the brigde functionality. And that works only when I changed the ifconfig manually afterwards. But the route is distroyed then and packages to the internet are not routed secure thru my home-network.
@ brian_o'fish: Thanks for the advise. I will try that the next days. In the moment I am happy to read, that I am not the only one with the problem (and maybe to stupid to use openvpn - but on the netbook it works).
I have never worked with tun. Maybe I could check, if that is also a workaround.
I will keep you informed, but I am on a trip the next days.
Thanks again!
*** Update ***:
I didn't work neither with tap nor with tun. Meanwhile I tried to run VPNC. I had some trouble, but it works now.
caesar68 said:
I didn't work neither with tap nor with tun.
Click to expand...
Click to collapse
Did you try the approach I described with tap, and can tell where / how it failed?

[Q] Change MTU on TouchPad?

Is it possible to change the MTU on the touchpad?
I really want to set up my Motorola triumph for wireless tether and apparently, the MTU has to be set to 1472.
there's a thread here
http://forums.androidcentral.com/motorola-triumph-virgin-mobile/108734-tether-fix-sortof.html
It should be doable in developer mode. I don't have mine here to check, but if the "ip" command is there then you could run
ip link set wlan0 mtu 1472
at a shell prompt. If "ip" isn't available, then try running
ifconfig wlan0 mtu 1472
I'm assuming it's using the standard device naming. You can see the available network devices by running "ip link" or "ifconfig".
cbf123 said:
It should be doable in developer mode. I don't have mine here to check, but if the "ip" command is there then you could run
ip link set wlan0 mtu 1472
at a shell prompt. If "ip" isn't available, then try running
ifconfig wlan0 mtu 1472
I'm assuming it's using the standard device naming. You can see the available network devices by running "ip link" or "ifconfig".
Click to expand...
Click to collapse
is there a program for that? can't seem to find a terminal app
cbf123 said:
It should be doable in developer mode. I don't have mine here to check, but if the "ip" command is there then you could run
ip link set wlan0 mtu 1472
at a shell prompt. If "ip" isn't available, then try running
ifconfig wlan0 mtu 1472
I'm assuming it's using the standard device naming. You can see the available network devices by running "ip link" or "ifconfig".
Click to expand...
Click to collapse
From what I found in my touchpad,
Open WebOS quick install find your touchpad, then click tools, Linux command line, type
ifconfig eth0 mtu 1472
then type
ifconfig
Now it will show your mtu 1472 is set... dont know if it will connect to Ad-Hoc but that will change it. Hope this helps...
This works for me
Just try this it works for my Motorola Photon...
http://code.google.com/p/android-wif...downloads/list
Install it
Run it
Menu-Settings
Change Device-Profile
Select: Samsung Galaxy S
Change Setup-Method
Select NetD (Master)
Back to main screen
Click start tethering... now you will get 2-5 pop ups with errors DONT WORRY just look for the network and disregard the errors on the phone
And now you are good to go. I have used this on my Photon (MoPho) running STOCK rom with root.
Have fun tethering.
@Ion4:
I tried the galaxy S and netD and I SEE IT ON THE TOUCHPAD!!!!
but.... it failed to configure and "Association Failed".. i tried it on my ipod touch and i see AndroidTether but it cannot connect

WiFi and WPA_SUPPLICANT

Hi Guys,
I am stumped on this. I am trying to build in WiFi support for a Freescale IMX6 board running Android 4.2.2 via a RALINK USB WiFi Module. I was able to build the RALINK drivers from my kernel source and the device loads up just fine. I can bring the adpater "up" in netcfg and I can use the iwlist binary to see access points near me.
However, I cannot get Settings.apk to bring up the adapter. When I go to turn WiFi on, logcat shows the following:
E/WifiStateMachine( 2879): Failed to load driver!
E/WifiStateMachine( 2879): DriverFailedState
I can get WPA_SUPPLICANT started manually by running the following command:
wpa_supplicant -dd -Dnl80211 -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf
where /data/misc/wifi/wpa_supplicant has only two lines:
ctrl_interface=wlan0
update_config=1
I also set the following the props just to be sure:
setprop wifi.interface wlan0
setprop wlan.driver.status "ok"
I am stumped, because I am loading the driver manually first, I do not want wpa_supplicant or settings (whatever method it uses) to load any driver. I have rebuild WPA_SUPPLICANT binary with what I think are the correct board settings, but I always get the same error.
Can anyone help?
Since WifiStateMachine is giving the error, do I need to recompile and replace the Java framework on the device?
Is this a sign of WPA_SUPPLICANT not being built correctly?
Is there some other component I am missing??
Thank you!!!

[Q] Ethernet permission

Hi. I have this devices HW:
My Devices: goo.gl/gz4BDs
Adapter: goo.gl/Zhfvpz
I have manualy installed driver for USB adapter to the my MiniPC. Ethernet is launched after boot over new script file: system/etc/eth1.sh
Code:
#!/system/bin/sh
netcfg eth1 dhcp
setprop net.dns1 8.8.8.8
setprop net.dns2 4.4.4.4
route add default gw 1.0.0.1 dev eth1
Android write message ( internet not connection) but internet is working ok. I can browse on the web and applications like speedtest are working ok.
BUT!
I can't download apps from google play (waiting for network), Google Maps don't work and web browser cannot save any files (pdf, zip,...). Over WiFi is everything ok, problems are only over adapter eth1.
Any ideas about problem?
Maybe some permission for eth1 device?

Configure WLAN manually in Android 8.1

Hi all,
In order to keep both WiFi and LTE connections working, I tried to start WiFi connections manually. I found following commands working successfully on a Nexus 4 with Android 4.3 (rooted, with busybox):
netcfg wlan0 up
cd /data/misc/wifi/.
wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
dhcpcd wlan0
However, I met problems when attempting to apply the same methods on a Nexus 6P with Android 8.1 (rooted, with busybox). I run ifconfig instead of netcfg, but I am not sure about following steps.
Should I still use wpa_supplicant? I found it in /system/bin/hw rather than /system/bin. Besides, the configuration file wpa_supplicant.conf has a different format from Android 4.3 (no longer containing ssid and passwords). What is the correct way to assign wlan0 an ssid?
dhcpcd is not available as well. How should I request an IP address for wlan0?
Thanks!

Categories

Resources