Wildcard Subdomains in /etc/hosts

This post illustrates how you use a DNS forwarder to manage wildcard subdomains so that you don’t have to explicitly list each subdomain in /etc/host file.


When trying to map multiple subdomains (ex: a.localhost, b.localhost, c.localhost, d.localhost) to the same IP, it is not possible to do the following in /etc/hosts:

# /etc/hosts *.localhost

Rather, each subdomain has to be explicitly defined:

# /etc/hosts a.localhost b.localhost c.localhost d.localhost

It requires you to babysit and manage these wildcard subdomains over time, but you do have a good job security.



Install a DNS forwarder using Homebrew.

brew install dnsmasq

Create a configuration to map the wildcard subdomains to the same IP.

sudo bash -c \
  'echo "address=/localhost/" > /usr/local/etc/dnsmasq.d/localhost.conf'

Restart the service.

sudo brew services restart dnsmasq

Create /etc/resolver directory.

sudo mkdir -p /etc/resolver

Create a custom DNS resolver where the file name is the domain name.

sudo bash -c \
  'echo "nameserver" > /etc/resolver/localhost'


Flush the DNS cache first.

sudo killall -HUP mDNSResponder

Verify that ping command on each subdomain resolves to the correct IP.

$ ping -c 1 a.localhost
PING a.localhost ( 56 data bytes

$ ping -c 1 b.localhost
PING b.localhost ( 56 data bytes

$ ping -c 1 a.b.c.localhost
PING a.b.c.localhost ( 56 data bytes

Chromebook: Using Logitech Unifying Receiver


If you have a decent Logitech keyboard/mouse, chances are you might also have a Logitech Unifying Receiver, which is a small USB dongle that allows multiple Logitech devices to be connected to a single computer. This is useful if your institution disables the Bluetooth connectivity on the institution-managed Chromebook. However, if your institution also prevents you from installing Logitech Unifying for Chrome extension, how can you still get this to work on your Chromebook without thinking about quitting your job?


The trick here is to use your Mac/Windows computer to get the devices added to the Logitech Unifying Receiver first before transferring the USB receiver to your Chromebook.

Attach the Logitech Unifying Receiver to your Mac/Windows computer. If your modern computer only has USB-C ports, use a “USB-C to USB” adapter.

Install Logitech Options.

From Logitech Options, add the keyboard/mouse as Unifying devices by clicking on the ADD UNIFYING DEVICE button.

Once added, attach the USB receiver to your Chromebook.

Note: If your keyboard/mouse has the multi-device switch, you can use the same set of devices on both Mac/Windows computer and Chromebook. In this case, you may configure Switch #1 using Bluetooth (for Mac/Windows computer) and Switch #2 using Logitech Unifying Receiver (for Chromebook).

macOS Big Sur: Poor Screen Quality When Connecting to Old Monitor via HDMI


You have a shiny Mac laptop running macOS Big Sur. This laptop is connected to an old external monitor via HDMI. The screen quality looks pixelated and fuzzy.

Running font smoothing (as below) doesn’t fix the problem:

defaults -currentHost write -g AppleFontSmoothing -int 3

You are poor enough to buy a new 4K monitor.


The usage of HDMI seems to fool macOS Big Sur, thinking your old monitor is a glorious new TV. This causes macOS to use YPbPr instead of RGB mode.

The fix is to perform Extended Display Identification Data (EDID) override to force macOS to use RGB mode.

Some instructions on the web are inaccurate. There’s no need to reboot into Recovery Mode to disable System Integrity Protection (SIP) via csrutil first.

Instead, run the following command:

sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
cd /Library/Displays/Contents/Resources/Overrides
sudo curl -O https://gist.githubusercontent.com/ejdyksen/8302862/raw/patch-edid.rb
sudo ruby patch-edid.rb

Reboot the laptop.