On my development machine I’ve always used the good old
/etc/hosts
file to point test domains like newsite.test
to a local IP. This approach works fine but it’s a bit cumbersome to manage.Mostly because of these reasons:
Mar 20, 2018 Then type /private/etc/hosts and press Go. This will locate the hosts file in the ‘etc’ folder. 2) Copy the file onto your desktop, and then double-click the copied file to edit it. In the open text file, add your line of alternative IP addresses just as you would in Terminal: First the rerouted IP address and then the corresponding domain. Sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist. My hosts file looks like this.% cat /private/etc/hosts ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. The hosts file contains domain name to IP address mappings. These mappings mimic the function of a DNS server, and allow you to “trick” your computer into associating a domain name with a particular IP address. To use the hosts file to bypass DNS for your domain: Open the hosts file in a text editor. The location of the hosts file depends. Jul 03, 2017 Microsoft kept the hosts file alive in Windows networking which is why it varies very little whether used in Windows, macOS, or Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax. Use the following instructions if you’re running MacOS X 10.6 through 10.12: On your computer, select Applications Utilities Terminal to open a Terminal window. Enter the following command in the Terminal window to open the hosts file: sudo nano /private/etc/hosts When you are prompted, enter your domain user password. Edit the hosts file. How to Edit the Mac Hosts File. There are actually two ways to edit the Mac Hosts file. You can use Terminal or a standard text editor. The method you use is up to you. Using the Terminal. The simplest way to edit the Hosts file is by using the built-in UNIX terminal in OS X or macOS.
- a new entry is required for every domain you need
- your list of hosts can become so long that the file becomes hard to read
- making changes requires administrator rights
There’s a well-known tool to help us improve host name management: dnsmasq. Dnsmasq is a lightweight DNS forwarder that’s easy to install and configure.
Update: In this post I’ll show you how to configure dnsmasq to set up and manage dnsmasq and your local domains easily. I wrote a separate blog post that explains how to manage dnsmasq without the need for administrative rights every time you make a change.
Let’s dive right in!
- Configure as default DNS resolver in macOS
Install dnsmasq
The easiest way to install dnsmasq (on macOS) is using the Homebrew package manager. If you don’t have Homebrew installed, follow the instructions on their site.
Homebrew will output the command to have dnsmasq start after a reboot. If you’re running one of the latest macOS versions, it should look like this:
What does “Still waiting for root device” means? Its very simple, it means that the source from which you’re booting is not detected properly in other way it can be explained as the operating system was not able to locate a driver/kext for your Hard disk/DvD Drive/USB. The OS X Comes with the latest drivers that supports SATA out of the box. El capitan still waiting for root device. Aug 12, 2013 I speak for all of us in saying Thank You, D. Dec 01, 2012 then 'still waiting on root device' repeating over and over. This problem appears to be somewhat random (i.e. Restarting over and over, at some point it won't appear). Also I did just have good luck fixing this by removing 3 of 4 sticks of ram, perhaps good to try. Jan 10, 2018 Hello, I am trying to install Sierra zone on a E6520 laptop, el capitan works perfectly on that laptop but with Sierra zone it remain stuck on still waiting for root device Sierra. I have no clue where to start, thanks a lot for your help.
Configure dnsmasq
Its default configuration file is located at
/usr/local/etc/dnsmasq.conf
and contains examples of its most prominent features. Open that file and add this line all the way at the bottom:This will instruct dnsmasq to include all files that end with
.conf
in the /usr/local/etc/dnsmasq.d
directory as additional configuration files. This way we can keep our custom configuration better organised.Make sure the directory exists and create our first config file:
Time to create our own routing rules! Let’s assume we always want to return the
127.0.0.1
IP for any *.test
domain. Using the address
directive we can match these domains and return the right IP:Open our new configuration file
/usr/local/etc/dnsmasq.d/development.conf
and add the previous address
directive to it.Save all files and restart dnsmasq to apply the changes:
Configuring My Hosts File For Https Macos Free
We can verify our changes using the dig command by querying our local dnsmasq instance:
Need to move Bookmarks, Extensions & Add-Ons to another Mac; Text of website is missing the charakters x, y, z but only in lower case where x is not simply missing but replaced by 'If I start Firefox by clicking a link in another application or operating system a window without Menu Bar items is opened; Disable. Download Mozilla Firefox, a free Web browser. Firefox is created by a global non-profit dedicated to putting individuals in control online. Get Firefox for Windows, macOS, Linux, Android and iOS today! How to fix firefox for mac catalina. How to Fix Firefox Keeps Crashing on Mac. When your Firefox crashing constantly, don't panic! We will help you get over this issue and fix in no time. Here are some steps recommended by Mozilla in order to fix firefox keeps crashing problems. 2.1 Update Firefox Browser. The crashing problem can also be caused by bugs on the current.
We should get an answer back that points to
127.0.0.1
:;; ANSWER SECTION:
foobar.test. 0 IN A 127.0.0.1
foobar.test. 0 IN A 127.0.0.1
You can also route multiple domains at once. I often work on this Vagrant box which needs a
joomla.box
domain and a changing number of .test
domains. These .test
domains are added dynamically so I don’t want to be editing /etc/hosts
each time.The following one-liner takes care of all these at once:
You can then add multiple
address
directives to deal with different situations. For example:This will forward
foobar.test
to 127.0.0.1
(localhost), while joomla.box
and mysite.test
will go to 33.33.33.58
(the Vagrant box).The Google Assistant runs on macOS with the help of an app called Mac Assistant which is still in the beta development. But it works great! Moreover, you can contribute to this project development at GitHub. Download the Mac Assistant latest release here. Jul 04, 2017 Mac Assistant runs in the menu bar. The first time you click the menu bar icon, you’ll be asked to sign into your Google account. After that, you’ll see a microphone in the pop-up window. Tap it to start talking to Google Assistant. You can also trigger the assistant. May 25, 2017 Once you have downloaded the MacAssistant app, extract the zip file and move the app to your application directory.; Next, double click to open the app. This won’t open any window but the app will run in the background. Check for Google Assistant icon in menu bar. Click on it and this will take you to the login page. Google assistant for macos.
Configure as default DNS resolver in macOS
To complete our set up we need to tell macOS to use dnsmasq for its DNS queries. There are two methods we could consider:
Hosts File Windows 10
- Send all DNS queries to dnsmasq.
- Send only DNS queries for
*.test
and*.box
domains.
1. Send all DNS queries to dnsmasq
The first method is easy to do: set the system’s DNS server to
127.0.0.1
through System Preferences.This requires some more changes to dnsmasq’s configuration to ensure you can still browse the web. We can solve this by adding alternate DNS servers. Add the following to your
/usr/local/etc/dnsmasq.conf
file:In this example we’ve added the OpenDNS servers to query for internet domains. Restart dnsmasq (
sudo brew services restart dnsmasq
) to apply the changes.This configuration makes your system entirely dependent on dnsmasq for domain name resolution. It’s usually best to keep relying on the DNS servers given to you by your network’s router through DHCP.
Because of this I wouldn’t recommend this method and instead opt for the next one:
2. Only send .test and .box queries to dnsmasq
On most UNIX-like systems the
/etc/resolv.conf
file determines how DNS queries are made. When you make changes to the DNS Servers in macOS’s System Preferences, this file is re-generated.For that reason we don’t want to edit it directly. We can however add separate resolver files inside the
/etc/resolver/
directory. Make sure it exists before continuing:The name of each configuration file will correspond to the top-level domain name, so create the file
/etc/resolver/test
for .test
domains and add this line:This instructs the DNS resolver to send all queries for domains ending in
.test
to the nameserver at 127.0.0.1
. Do the same for /etc/resolver/box
.Sometimes it can take a little while before the new configuration is applied. We can check that our new resolvers are registered with the
scutil --dns
command. The output should list our top-level domains and their configured nameserver:resolver #8
domain : box
nameserver[0] : 127.0.0.1
.
resolver #9
domain : test
nameserver[0] : 127.0.0.1
domain : box
nameserver[0] : 127.0.0.1
.
resolver #9
domain : test
nameserver[0] : 127.0.0.1
Testing
Time to take dnsmasq out for a spin! We can test if everything is working as expected with the
ping
command:The output should mention the IP addresses you’ve configured for your local domains.
Once this configuration is in place, you can use any domain you want and it will point to the right IP. No more messing around in
/etc/hosts
!To make things even easier to manage, you could get rid of the
sudo
requirement when restarting dnsmasq to pick up new changes. I’ve explained how you can set this up in another post titled Run dnsmasq on a different port.