Alternative to defining aliases in /etc/hosts?

本秂侑毒 提交于 2020-01-05 04:35:07

问题


Is it possible, without editing the /etc/hosts file, tell my computer redirect to 127.0.0.1 every time I visit domain1.com or domain1.com through the web browser as well as when I request the content of the same pages through curl?


回答1:


Run a DNS server/resolver on your machine, configure to forward every query that it can't resolve to the DNS resolvers upstream and set /etc/resolv.conf to direct all queries to the locally running resolver.

Then in the local resolver add entries for the domains you want to blackhole toward localhost.

There are several of options to chose from. The currently most popular caching resolver is unbound, but you can also use dnscache for it.



来源:https://stackoverflow.com/questions/40438487/alternative-to-defining-aliases-in-etc-hosts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!