Changing DNS settings for Android Development

 

This relates to any similar development environment. This guide will help you setup your device to work for your development setup either locally or a remote server. No root required.

First I will describe the use case scenario where this is useful:

Live:

codrcg.com

192.3.206.221

(public server)

https://pastebin.com/raw/63dFFz2C

 

Staging / Test:

codrcg.com

10.5.1.143

(internal server)

https://pastebin.com/raw/txav6Yit

 

Local Desktop:

codrcg.com

192.168.1.256

(static desktop ip)

https://pastebin.com/raw/FudTpY1z

 

You’ll notice for each setup I have created pastebin links to where my hosts file is located, the format is “ip hostname” with one per line, just like a windows /etc/hosts file. You will need this in a later step for access to your settings. If you have a web server for static links, that will be even better but optional, I use http://somewebsite.com/dns-settings/live.txt. This allows me to edit without updating my android device.

 

Step 1 – Basic application settings:

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

  • 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.

  • 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

 

 

Step 2 – Creating hosts files:

  • If you do not have your own server, you can use pastebin.com to host your hosts files for use in the next steps.
  • Create a pastebin link for each mode, you can add as many hosts as you need to test like below. Then hit “Create New Paste”

 

  • Click on the Raw button and copy this link somewhere for later use, Repeat steps for each mode.

Step 3 – Setting up the rules:

  • 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.

 

Step 4 – Activating:

  • 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.

 

Step 5 – Testing:

  • The final setup, lets see if I am hitting my dev server.
  • As you can see in the app below, the short url is no longer short, I now get a full url as the dev server doesnt have an api key to tra.li link shortener.
  • Depending on the use-case it may be difficult to detect which server your hitting, You can go back into Daedalus in the menu and select test. Type your domain name and see if the ip matches your dev server.

Add a Comment

Your email address will not be published. Required fields are marked *