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:
127.0.0.1 local.smartstudy.com
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:
Installation
update; brew install dnsmasq;
Start
sudo brew services start dnsmasq
Restart
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:
/usr/local/etc/dnsmasq.conf
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=127.0.0.1,172.17.7.115 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:
172.17.7.115 yongle.smartstudy.com
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
172.17.7.115
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 yongle.smartstudy.com @127.0.0.1
When you see
yongle.smartstudy.com. 0 IN A 172.17.7.115
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 172.17.7.115
, if not, restart the WiFi connection, OK.
Configure the DNS server locally (Mac Edition)