Configure the DNS server locally (Mac Edition)

Source: Internet
Author: User

As a front-end developer, will encounter cookie the use of the situation, common such as: login, rights control, video playback, graphics verification code, and so on, the local developer on the PC will use the modified hosts way to add to the local domain name, to obtain cookie the same domain name. Such as: 

But in the mobile side of the time, this trick is not good, Apple mobile phone in the case of no jailbreak can not be modified, is it for hosts this to let their love machine more prison? The answer should be negative. So how do we deal with this problem? The perfect solution is to configure the DNS service for the local area network. So I looked up a series of documents, summed up this article, stepped on a little pit, hope Yimeimei do not step on the repeated, because I use the Mac, so some of the following commands and the Mac party, other systems are similar, only write system commands may be different, nonsense not much to say, June and detailed look:

update; brew install dnsmasq;  
sudo brew services start dnsmasq  
sudo brew services restart dnsmasq  
Stop it
stop dnsmasq  
View DNSMASQ's Run
ps aux | grep dnsmasq  
Find running parameters
/usr/local/opt/dnsmasq/sbin/dnsmasq --keep-in-foreground -C /usr/local/etc/dnsmasq.conf
Locate the Run configuration file:
Edit him, here with vim:
vim /usr/local/etc/dnsmasq.conf  

Do the following things, remove the following comments, and modify, the specific configuration is what to do, there will be said later:

no-resolv  no-poll  listen-address=, addn-hosts=/etc/dnsmasq.hosts 
Add custom Hosts File dnsmasq.hosts
vim /etc/dnsmasq.hosts  

Add the domain name you need to fill in the corresponding relationship, such as: 

Restart your DNS server, boot code in the article said, as of now, your Mac local DNS configuration is OK, but for other devices with the LAN, you need some action.

Modify the DHCP for the router

Configure DNS  

Standby DNS is configured as a general-use DNS server.

LAN devices need to re-connect WiFi, and then you can use your local DNS service, detection is successful, you can use the dig command, as you can on this machine:

dig @ 

When you see    0   IN  A 

Description success, this should be the end, but if there is a LAN device is not connected, you can check the DNS of the device is contained , if not, restart the WiFi connection, OK.

Configure the DNS server locally (Mac Edition)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.