Setup Local Development Domain with Public DNS

Did you know that you can point any domain to 127.0.0.1 and it will happily resolve to your local development environment? No more edits to /etc/hosts or complex NS server setups.

For example, if the domain of your project is example.com then you could set the A record of local.example.com to 127.0.0.1. But wait — there is more — you can have unlimited subdomains such as *.local.example.com if your DNS provider supports wildcard A records.

Here is a screenshot of the DNS setup in DigitalOcean that I use for *.wpenv.net domains:

Name server records for local development environment URLs using public DNS

The A record for the root level wpenv.net pointing to a GitHub IP for the repository which has the README about the domain. It is like a landing page for the service.

The important bit is the A record for *.wpenv.net pointing to 127.0.0.1.

Leave a Reply

Reply on Mastodon or search for ️this permalink in your ActivityPub client, and it will show up here too (also follow this blog). Or simply leave a comment below: