Setup Static IP for Android 4.3 on VirtualBox

8.3k views Asked by At

I am using Android 4.3 on VirtualBox, for testing apps. However, I'm running the VM on my computer, which is behind a proxy (without DHCP), so I cannot connect to the Internet from the VM.

What I need to accomplish:

  1. Setup the Android machine to use a static IP (192.168.1.213/24, with gateway 192.168.1.1)
  2. Setup proxy access (proxy is on another server in the network 192.168.1.2 and has user/pass)

Can you please let me know how I can do this? More details on what I'm using:

Not very familiar with available commands in adb (I just know that you can access it with Alt-F1, and hide it with Alt-F7), so I would appreciate more in-detail instructions.

Thank you

Edit: I ran the following commands to setup static IP:

- su

- ifconfig eth0 192.168.1.213 netmask 255.255.255.0 up

- route add default gw 192.168.1.1 dev eth0

This solved requirement 1 (setting up static IP), and now I can ping other computers from my network, so I only need a way to setup a proxy with user/pass (requirement 2)

2

There are 2 answers

0
Bishan On

This article about Android x86: setting-up IP Address using command line may helpful to you.

Proxy setup

sqlite3 /data/data/com.android.providers.settings/databases/settings.db
INSERT INTO system VALUES(99, 'http_proxy', '<proxy_server>:<port>');
ex: INSERT INTO system VALUES(99, 'http_proxy', '192.168.179.202:3128');
0
Devon Dieffenbach On

The above answers only work on Android < 6. If you are using something newer, the following has worked for me

Alt + F1 to get into the shell

settings put global http_proxy <address>:<port>