How to configure static IP in Genymotion emulator via adb?
0
votes
0
answers
1105
views
I need to configure Genymotion emulator (Android backed by VirtualBox). I need to setup static IP for eth0. The full list of commands i need to apply:
su
ifconfig eth0 10.152.152.12 netmask 255.255.192.0
ip rule add from all lookup main pref 0
busybox route add default gw 10.152.152.10
ndc resolver setnetdns 100 localdomain 10.152.152.10
I use adb that is included in Genymotion tools.
adb devices
shows that device 192.168.8.101:5555 is connected
adb -s 192.168.8.101:5555 shell
let me enter the shell. I can run ifconfig in that shell - it will show that eth0 is assigned 192.168.8.101.
But entering the first command from list:
ifconfig eth0 10.152.152.12 netmask 255.255.192.0
hangs the window with Android screen (opened when I started VM) and closes adb session and
adb devices
shows that 192.168.8.101:5555 offline
I guess that I've changed IP that is used by adb to control emulator device - therefore I lost the control of VM (both the console/screen of Android and adb session). So I tried some other way to start adb session using adb usb
that shows output: restarted to usb
But adb devices
after that shows that connected device has IP 192.168.8.101 nevertheless.
**How can I both preserve control over emulator VM and change to needed static IP with ifconfig?**
**Updated:**
I added additional network adapter in VirtualBox's Network Settings (Internal network). That is I added additional interface because eth0 is used for adb connection and likely for displaying Android console/screen launched by Genymotion manager.
Then I invoked aforementioned list of commands but for eth2
(not eth0
). The last command ndc resolver setnetdns 100 localdomain 10.152.152.10
says 500 0 Command not recognized
- I see that different versions of Android have different flavor of this command. So, It works - ipleak.net shows Tor IP, not mine. But - the settings are restored to factory settings after restart and DNS may reveal my IP(since ndc resolver
fails). So now I need to make commands persistent and apply the last ndc resolver
command. The version of Android is 12
Asked by Vlad
(141 rep)
May 27, 2023, 10:16 AM
Last activity: May 28, 2023, 09:05 AM
Last activity: May 28, 2023, 09:05 AM