Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Modifying the hosts file

Sometimes you need to edit the hosts file on your machine because of an attack, to block unwanted connections, to redirect requests to a specific IP, etc. This article explains how to modify the hosts file of your Firefox OS phone. It is located under for example /system/etc on Linux, and just etc/ on newer Mac OSX versions.

Preparing your phone

On the phone, go the Developer settings panel and check:

  • "Remote Debugging" (in Firefox OS 1.4 and above, select "ADB and Devtools" from the select menu)
  • "Console Enabled"

Then plug your phone to your computer.

At this point the steps for modifying the hosts file are the same as for Android. Android developers will quickly settle into the swing of things.

Steps in the terminal

  1. Open a terminal window.
  2. Remount the /system partition on the device to get read-write permissions
    adb remount
  3. Get the hosts file on your computer
    adb pull /system/etc/hosts /tmp
  4. Modify the hosts file in /tmp/hosts as needed and save the file. For example:
    127.0.0.1         localhost
    ip.to.re.direct   hostName
  5. Push the modified hosts file to the device
    adb push /tmp/hosts /system/etc/hosts

This is it; your hosts file should now be updated.

Note: To learn more about ADB? Have a look at the ADB documentation.

 

Document Tags and Contributors

Tags: 
 Contributors to this page: chrisdavidmills, Jeremie, Audrey
 Last updated by: chrisdavidmills,