I am attempting to establish point-to-point communication between a Pixel C tablet
and an embedded device.Pixel C tablet is running Marshmallow 6.0.1. I have the devices
physically connected by USB.They will use this usb to communicate using standard web services.
In the configuration, the embedded device is acting as the "server" but unfortunately does not
support DHCP. I need to create a static IP address and disable DHCP on the tablet side.
I was able to establish an ethernet connection with LAN(DHCP) but the Pixel C does not provide the
capability to disable DHCP and modify ethernet settings.This appears to be changed for Marshmallow.
My question is, is there a procedure to create a static IP address and also disable DHCP on
the Pixel C(Marshmallow 6.0.1)? If not, can we restore the settings that were available on
previous versions of Android?
csd
If you long press on the network connection, you can select "Modify the network".
Then, select "Advanced Options" and "Ip parameters". Here you can choose "Static".
I did it on my Pixel C due to Wifi problems but I'm french and menus are in french.
Hope it helps
SamSam
Need root android device:
on android phone:
ifconfig rndis0 192.168.42.129 up
ip route add default via 192.168.42.1 dev rndis0
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to 192.168.42.1:53
on linux pc do this:
ifconfig usb0 192.168.42.1 up
Related
Is there any way to set a static IP address to Android device if the device is connected to a network via ethernet cable using ethernet to USB adapter?
I tried connecting to device via ADB and then changing IP address using $ ifconfig eth0 x.x.x.x command, but I got ifconfig:ioctl 8916: Permission denied as an answer.
Nope, there is no way to set it on common devices. You need rooted device, which allows you to run ifconfig eth0, thats the only way (valid up to Android 13). By default eth0 will obtain IP using DHCP, if there is no DHCP available - it just won't work. In "your" network you may assign some particular IP for particular MAC (also ensure that MAC address of ethernet isn't randomized like for Wi-Fi starting Android 10, but it shouldn't be on Linux level)
I am currently using an API 18 (Jelly Bean) device, and it does not support ADB over Bluetooth by default (No option available in developers option for wireless debugging) I have to connect my device with my Laptop using Bluetooth Personal Area Network which is Bluetooth tethering of my phone. Can anyone help me with starting a TCP open port my phone so that I can connect ADB using the adb tcpip "open_port_no" and adb connect <phone_ip_address>:open_port_no commands?
I have already tried some apps from playstore to do so but they all failed.
You need to enable the TCP port first by connecting a USB cable to your phone and setting it from the console on your PC/Mac:
adb tcpip 4455
Now turn on the Bluetooth on your phone and enable tethering.
You need to use the IP address of your phone. It will most likely be 192.168.44.1 since this is the default. If not:
You can get this using a few methods depending on your computer type:
ifconfig
ipconfig /all
route | grep default
Then connect to your phone from your computer using:
adb connect 192.168.44.1:4455
You should get a response:
connected to 192.168.44.1:5555
This works perfectly for me. Sorry for the late response :) I was just looking for the same thing and happened upon the solution. Sharing is caring.
How can I simply forward a port from the Android emulator (127.0.0.1:5555) to my LAN (192.168.1.102:5555)?
I don't think I can change the IP address of the emulator so the only way I see I can do this is by forwarding that port to the network.
I just want to access my powerful PC emulator from my laptop through adb.
If you want to forward the port, you have to change its number. You should not be allowed to listen to 5555 from 2 applications (you application and the forwarder).
I don't know about android emulator, but you can probably configure it (and your firewall) to accept incoming connections from your LAN (and not only from localhost).
If you still want to perform a port redirect you can use netcat (installed on most baseline unix/linux systems, you can find ports for Windows from google)
e.g. redirect incoming connections on port 8080 to local service on port 5555
nc -L 127.0.0.1:5555 -p 8080 -vvv
I want to debug my android application, I connect the android device to my PC using the USB cable. In my application there is a button to connect with localhost, ip for localhost is 10.0.2.2 and the port is 8080, I have read that when debugging on mobile, the ip 10.0.2.2 is the localhost for android device and not for my PC, so what changes should I make to the ip instead of 10.0.2.2? or do I have to make another change?
In this case my android device is sony ericsson xperia arc s.
Google has added support in Chrome 29 and higher to use reverse port forwarding to access a website hosted on your local development machine through the USB cable on Chrome for Android. Setup instructions can be found at the following URL:
Android Remote Debugging - Reverse Port Forwarding
Tools for Web Developers - Access Local Servers
As of desktop Chrome 30 Reverse Port Forwarding is no longer an experimental feature in Chrome. It can be accessed by typing about:inspect in the address bar of your PC, and by clicking the "Enable port forwarding" check box and clicking the "Configure port forwarding" button located to the top right of the window.
Once that is done, connect your mobile device via USB. Open Chrome on your mobile device to localhost:8000 (or whichever port you have configured on your local server).
The Reverse Port Forwarding functionality will make sure that your Android device now sees your PC's localhost.
As 10.0.2.2 is your system (pc)'s local host address (from emulator only). Actually android doesn't recognized localhost in url. so 10.0.2.2 is for that meant. Also for android device loopback address is 127.0.0.1.
Your url with 10.0.2.2 is correct. Also you can use Static IP of your system.
Just check for
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
in your application's manifest file.
EDIT:
Here you are using port 8080 so, try with adb command on your host machine.
adb forward tcp:8080 tcp:8080
Also please elaborate on this line "i want to debugger my application on my mobile".
Note:
If you are going to test on real device use your Network IP of system (PC).
For that you need to make some changes in your xampp server... Assign 1 static IP address to your system and then you need to put your xampp server in online mode. after that you can use that ip address in your android application instead of 10.0.2.2. Works fine for me as i am using my localhost with my android application.
You can share your Mac's Internet connection over Wi-Fi. Then your Android app can connect to a Servlet running on the Mac with HTTP over Wi-Fi. The steps are:
Run System Preference on Mac
Goto "Sharing" tab
Turn on "Internet Sharing"
Select "Ethernet" in the "Share your connection from" combo
Select "Wi-Fi" in the "To Computers Using" list box
Use "Wi-Fi Options..." button to configure Wi-Fi security. Now your Mac is a Wi-Fi server, and it is sharing its Ethernet Internet connection.
Configure your Android device's Wi-Fi to connect to your Mac (in Settings command)
On your Mac, goto the Network tab in System Preferences, and select Wi-Fi in list to find out the IP address of your Mac on the Wi-Fi network (for me it was 169.254.66.223)
In your Android App you can now connect to the Servlet in your Mac with "http://169.254.66.223:8080/YourServer/YourServlet"
I think you have two options
The first one is using 10.0.2.3 when you use your real android device.it works for me.
Your Second opt is creating hotspot from your pc and connect your android device to the hotspot.
Find the ip address using cmd type "ipconfig" replace localhost with the ip address.
Thanks.
Is it possible to have both 3G and Wifi connections up and running? I want to transmit at the same time through both interfaces.
However, I've noticed that when Wifi is up, 3G is going down. Actually, it seems that the routing table is updated on on/off of the interfaces.
Route table UMTS on / Wifi on
a.b.c.1 dev rmnet0
a.b.c.0/24 dev rmnet0 src a.b.c.2
default via a.b.c.1 dev rmnet0
Route table Wifi on / UMTS on
192.168.1.0/24 dev eth0 src 192.168.1.147
default via 192.168.1.1 dev eth0
With wifi on I have run:
ip link set rmnet0 up
ip route
192.168.1.0/24 dev eth0 src 192.168.1.147
a.b.c.0/24 dev rmnet0 src a.b.c.2
default via 192.168.1.1 dev eth0
When I saw that I thought that I have managed to put both devices up and running. However, this is not the case. When I ping a public internet address (a.b.c.3), in case 1) and 2) everything goes well. In case 3) I get no answer.
Where on earth does Android set that only one device can be available at a time? How can I make both interfaces to be up and available, like on an ordinary Linux box?
P.S.: I have tried the solution in [1] to enable the data connection when wifi is on, and no way.
[1] How to enable data connection on Android 2.3
[2] How to block calls in android --> using ITelephony to get the telephonyService.enableDataConnectivity(); but I get an exception.
This is not going to be possible... unless you are will to go to great lengths to make it work. You are essentially asking for you device to become a router.
To do this you will need to find a program (sorry can't remember any names at the moment) that will accomplish this on a normal linux distro. Then recompile it to fit the Android OS and install is into the native system.
This explanation may make a little more sense to you. If you go to your ADB shell and run netcfg (or ifconfig to verbose this) you will see the devices networking options. You can run an ifconfig command to set the device or change its state - but you cannot have multiple devices route data to and from the phone at the same time I wouldn't think.
This would be my best guess...