Changing the host file

Changing the host file


Overview


When registering for oauth, some services (like Google) do not allow specifying IP Addresses for Redirect URI's. They expect a hostname from which the request will originate. In this article we will discuss modifying the hosts file on your local machine to map a known IP Address to a hostname. You may then use this hostname instead of the IP Address to browse to Matillion or any other service that is accessible via that IP Address. Please note that this change is local to the machine where the changes are made.


Linux

  1. Open a terminal window.
  2. Open the hosts file in any text editor.
  3. For example, using nano: 
    sudo nano /etc/hosts
  4. Enter the appropriate user password.
  5. Change the file's contents as you require.
  6. Close the file by pressing Control+X.
  7. When asked if you want to save your changes, enter y (yes).


Windows 8 & 10

  1. Press the Windows key or click the Start Menu to bring up the search function.
  2. Type in 'notepad'. (Alternately browse to it through Start Menu→Windows Accessories→Notepad)
  3. Right-click Notepad and select Run as administrator.
  4. From Notepad, use File→Open and browse to the file:
    c:\\Windows\\System32\\Drivers\\etc\\hosts
  5. Change the file's contents as you require.
  6. Click File→Save to save your changes.


Windows 7 & Vista

  1. Browse to Start Menu→All Programs→Accessories.
  2. Right-click 'Notepad' and select Run as administrator.
  3. If you have UAC enabled, click Continue to pass the UAC window.
  4. From Notepad, use File→Open and browse to the file:
    c:\\Windows\\System32\\Drivers\\etc\\hosts
  5. Change the file's contents as you require.
  6. Use File→Save to save your changes.


OSX 10.0 to 10.12

  1. Open /Applications/Utilities/NetInfo Manager.
  2. Allow editing of the NetInfo database by clicking the padlock in the bottom-left corner of the window.
  3. Enter the appropriate user password.
  4. In the second column of the browser view, select the node named machines.
  5. The third column contains entries for -DHCP-, broadcasthost, and localhost.
  6. Select localhost.
  7. Repeat this loop for every additional host entry that you want to add:
    1. Use Edit→Duplicate.
    2. A confirmation alert appears. Click Duplicate.
    3. A new entry called localhost copy appears, and its properties are shown below the browser view.
    4. Double-click the value of the ip_address property and enter the IP address of the other computer.
    5. Double-click the value of the name property and enter the hostname you want for the other computer.
    6. Click the serves property and select Delete from the Edit menu.
    7. From the File menu, select Save.
    8. A confirmation alert appears.
    9. Click Update this copy.
  8. Select Quit from the NetInfo Manager menu.


OSX 10.12 to 10.6

  1. Open Applications→Utilities→Terminal.
  2. Open the hosts file by entering this below into the terminal window:
    sudo nano /private/etc/hosts
  3. Enter the appropriate user password.
  4. Edit the hosts file as below. Lines beginning with the hash symbol (#) are comments. Others describe default hostname mappings (e.g. 127.0.0.1 – local host).
  5. Enter any new mappings after the default mappings.
  6. Save the hosts file by pressing Control+X and answering y (yes).
  7. Flush the DNS cache using the following command in the terminal window:
    dscacheutil -flushcache