user800666
user800666

Reputation: 171

Mapping a hostname to an IP address on Android

I know that I have to edit the /system/etc/hosts to map an IP address to a host name, but it seems that I can't edit the file. Is it because my android phone is not rooted?

Kindly advise. Thanks.

Upvotes: 17

Views: 33760

Answers (3)

ldrrp
ldrrp

Reputation: 704

You can use the following guide and application to setup rules for specific domains.

  • Download (Daedalus) and open the application.
  • Click on the menu then click “Servers”

menu

  • Click the add button and add the two google servers “8.8.8.8” and “8.8.4.4”, You can substitute these for your preferred DNS provider as well.

dns settings

  • Activate these dns servers in the menu by clicking on “Settings”
  • Then select Google and Google 2 from the settings. Also activate Advance settings and select the two following options in the image below

settings

  • Back to the menu now, Click on “Rules”.
  • Add a new rule for each development mode, Live, staging, dev. Filename is not crucial, just make something up.
  • Hit sync rule before leaving to make sure the file is downloaded.

    rules

  • Tap and activate the mode you wish to be in, You can activate more than one at a time so be careful as this will override one or the other.

  • In the menu go to home, and hit the “Activate” button.

activate

Source: https://silocitylabs.com/post/2018/03/02/changing-dns-settings-for-android-development/

Upvotes: 18

rurouni
rurouni

Reputation: 2445

Why do you need to edit the hosts file?

You can simply add your host to a local DNS (e.g. the DNS announced by a local DHCP-Server in your Wifi-Network) or even in the real global DNS.

Upvotes: -6

Ramya K Sharma
Ramya K Sharma

Reputation: 743

Try to remount using adb and edit the file

Upvotes: -4

Related Questions