On my Ubuntu PC, I need to use 10.0.2.2
instead of 127.0.0.1
to be able to let Android emulator to connect to web server running on localhost
. So wondering how can I define the new IP?
I edited /etc/hosts and added
10.0.2.2 localhost
10.0.2.2 subdomain.localhost
Instead and restarted the hosts using /etc/init.d/hostname.sh
. But ifconfig still does not show the new ip. How can I fix this?
You don't need to change /etc/hosts or machine hostname. These are just for name resolution. You need to bring up a loopback interface with this ip. So we will bring a copy of loopback (lo:1) with this ip:
Then you can use ifconfig to see if its up. It will appear like:
You can use ssh to this ip.
To make this permanent you can add it to /etc/rc.local .