markdown 使用dnsmasq在localhost开发中的OS X上的通配符DNS记录

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 使用dnsmasq在localhost开发中的OS X上的通配符DNS记录相关的知识,希望对你有一定的参考价值。

# wildcard DNS in localhost development
- install [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html)
```
$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
```
- edit `/usr/local/etc/dnsmasq.conf`
```
address=/local/127.0.0.1
```
- start **dnsmasq**
```
$ sudo brew services start dnsmasq
```
- any time we change `dnsmasq.conf` we have to re-start **dnsmasq**:
```
$ sudo launchctl stop homebrew.mxcl.dnsmasq
$ sudo launchctl start homebrew.mxcl.dnsmasq
```
- For OS X to _resolve_ requests from `*.local` to **localhost** we need to add a _resolver_:   
```
$ sudo mkdir /etc/resolver
$ sudo touch /etc/resolver/local
```
- edit `/etc/resolver/local`
```
nameserver 127.0.0.1
```
- re-start the computer to enable the _resolver_

===
**REFERENCES**

- [Using Dnsmasq for local development on OS X - Passing Curiosity](https://passingcuriosity.com/2013/dnsmasq-dev-osx/)
- [Using Dnsmasq Configure Wildcard DNS Record on Mac | Ri Xu Online](https://xuri.me/2014/12/13/using-dnsmasq-configure-wildcard-dns-record-on-mac.html)
- [unix - In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain? - Server Fault](http://serverfault.com/questions/118378/in-my-etc-hosts-file-on-linux-osx-how-do-i-do-a-wildcard-subdomain)
- [hostname - Wildcard in /etc/hosts file - Unix & Linux Stack Exchange](http://unix.stackexchange.com/questions/3352/wildcard-in-etc-hosts-file)
- [Mac OS Lion - Wildcard subdomain virtual host - Stack Overflow](http://stackoverflow.com/questions/9562059/mac-os-lion-wildcard-subdomain-virtual-host)
- [How to put wildcard entry into /etc/hosts? - Stack Overflow](http://stackoverflow.com/questions/20446930/how-to-put-wildcard-entry-into-etc-hosts)

以上是关于markdown 使用dnsmasq在localhost开发中的OS X上的通配符DNS记录的主要内容,如果未能解决你的问题,请参考以下文章

docker-dnsmasq使用

linux使用dnsmasq搭建DNS服务器

Dnsmasq MacOS使用介绍

dnsmasq+nginx实现地址转发

使用Dnsmasq搭建本地dns服务器上网

centos7配置dnsmasq