Set gateway in ethernet - Android Q&A, Help & Troubleshooting

Hi,
I have a Android 7 phone with Ethernet in the USB port, android with dhcp get the IP addres but not gateway IP.
I need to set the gateway to Connect another IP but the command give this error
route add -host 10.x.x.x netmask 255.255.255.240 10.y.y.y
route: resolving 'netmask'
Can hoy help me with the sintaxis?
Greetings

Related

[Q] Android USB reverse tethering: How to fool the apps

USB reverse tethering = Cellphone gets network connection from PC via USB.
I know how to do USB reverse tethering except for one problem: Many Android apps will check network connection using the code below before doing any useful work:
Code:
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
The problem is that, when using USB reverse tethering, the above code will report no network connection. However, there IS a network connection (which is the USB reverse tethering itself), and ping, wget and all programs not doing this stupid check work well.
So the question is: How can I hack the system to let this network connection check return success (so that I can fool these apps)?
BTW. I use Cyanogenmod 7. And any solution specific to this MOD is also welcome.
Hello,
Could you please tell me how did you do the USB reverse tethering? Since on USB connection there is no option to do that under CM 7.1?
...
Thank you. Unfortunately the binary /system/bin/netsharing is not part of CM7.1, apparently it exists with Sense ROM. How do you manage to run it under CM7.1?
Sense ROM has the reverse USB tether built-in ("Internet passthrough"), maybe if the 2 commands could be executed, thanks to existing HTC NDIS driver doing NAT inside the PC it will work?
I've tested in CM7 that netsharing is not needed. Just execute the rest of the commands will be OK. Of course you need to do NAT on the PC because what you've setup is just a small LAN with private IP addresses.
Thank you for your input.
What I understand:
1- connect the phone via USB cable, choose charge only
2- Assuming my router has IP 192.168.1.1:
So I have to type these commands, could you confirm?
Code:
echo 4 > /sys/devices/platform/msm_hsusb/usb_function_switch
route add default gw 192.168.1.1
ifconfig usb0 192.168.1.1 mtu 500 up
But then how to do the NAT thing is out of my knowledge!
In fact what I want is when there is no router (since mine is wireless) with available Internet connetion
(ADSL line down). So I have to use USB 56kbps modem with telephone line to access Internet from the PC (running XP).
And I would like to plug the Android phone with USB cable and allow the phone to access Internet (Internet sharing
with the PC). I am not sure of the operations to do then.
Sorry but I don't know how to set up NAT on Windows XP... I use Linux and a simple iptables command suffices:
Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

USB Tether

(Asuming all drivers are installed and you have a hotspot plan or you are able to use hotspot with no problems)
Android 2.3.6
4.5.141.MB860.Att.en.US
Phone connected to usb and USB tether turned on, computer not connected to internet
Windows is connected to "Unidenfied Network" and there's no internet access. You must set manually ip.
open command promp and execute "adb shell ifconfig" (or android terminal on phone and execute ifconfig)
Find interface "usb1"
[*]Find "inet addr" and write somewhere the value (mine is 192.168.42.129)​[*]Find "Mask" and write somewhere the value (mine is 255.255.255.0)​
Click on network icon, Open Network and Sharing Center.
At the left, click "Change adapter settings"
Right click on the atrix network adapter (find a network adapter with the text "remote NDIS adapter..."; select "Properties"
Click on "Internet Protocol Version 4"
Click in "Properties" button
Click on "Alternate Configuration"
Click on "User Configured"
IP Address: Pick an ip address. Same value as phone except for last number (if phone ip is 192.168.42.129 you could pick 192.168.42.130 for example)
Subnet mask: Same as Phone (mine is 255.255.255.0)
Default Gateway: same ip addres as phone
Prefered DNS Server: 208.67.222.222
Alternate DNS Server: 208.67.220.220
You can also use Prefered DNS Server: 8.8.8.8 and leave alternate in blank
Click ok and save/apply changes
Wait a while and windows will connect to phone and internet will work
------------------
Also if mobile hotspot not working change current apn settings and delete "apn type".

SSH over USB from Android to RaspberryPi

So there are many topics covering both SSH tethering and SSH reverse tethering, but they were not helpful for me. Below, I'll quickly explain what I want. Hope you can help me. Thanks.
It's easy to SSH from Windows/Linux/OSX to Android through USB but I want the reverse. My raspberrypi's IP for USBnet is 192.168.2.2, so when I am in Windows, I can easily install RNDIS driver, set IP for Windows to 192.168.2.1 and gateway 192.168.2.2 and SSH from Windows to Android. The reverse in also possible by following this guide for example. BUT, what I want is SSH from my Android to my raspberrypi through USB OTG with:
Raspberry Pi : 192.168.2.2
Android: 192.168.2.1
Any help is appreciated.

[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?

Android usbnet networking setup

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?

Categories

Resources