查看: 4298|回复: 2
收起左侧

建立你自己的dns服务器by dnsmasq

[复制链接]
a939707506
头像被屏蔽
发表于 2016-9-23 12:59:05 | 显示全部楼层 |阅读模式
Host your own DNS, now with 100% more ad block!
One of your essential addons for your web browers is almost definitely some sort of ad blocker. Resources like bandwidth are a precious resource, especially when your ISP is of the many that limit it on a monthly basis. Another great benefit of having ad blocking software is that you risk a much lower chance of being infected by drive by malware, served by ads themselves. Not loading ads also means.. less loading! Why don’t we take the load off our machines even less by removing our ad block extensions?


For what you’ll see in this tutorial, it is assumed you’re working with a clean Debian 8.0 template. First off, we’ll use apt to install dnsmasq, the only requirement for this to work, and tell it to start by default.

apt-get update && apt-get install dnsmasq -y
update-rc.d dnsmasq enable

We’re going to delete dnsmasq’s default configuration file, as it’s way too cluttered for what we’re using it for. After that, we’ll be making our own, much simpler version.

rm /etc/dnsmasq.conf
nano /etc/dnsmasq.conf

**dnsmasq.conf

**

bogus-priv
domain-needed
no-resolv
server=8.8.8.8
server=8.8.4.4
interface=venet0:0
listen-address=127.0.0.1
cache-size=10000
addn-hosts=/etc/pihole/gravity.list
host-record=hostname,127.0.0.1,::1

For options like _interface_, you’ll need to use ifconfig to see what interface lists the IP you want it to be setup on. For _host-record_, simply run `hostname` to know what you should put. What is pihole you might ask? https://pi-hole.net is an open source project written by Jacob Salmela to do the exact same thing we’re doing, but for Raspberry Pi’s on your local network. Creating a blacklist for ads would take ages, so we’re going to take advantage of Pi-Hole’s already created list.

wget https://raw.githubusercontent.co ... e/master/gravity.sh
chmod +x gravity.sh
./gravity.sh

gravity.sh will start populating an extensive blacklist for ad networks, but it shouldn’t take long. Finally, we’ll use sed to change every instance of our virtual machine’s IP with a blackhole, and restart dnsmasq.

sed -i “s/^[0-9\.]\+\s/0.0.0.0 /g” /etc/pihole/gravity.list
service dnsmasq restart

You’re done! I like to take it a step further though, and automate the updating of our blacklist.

apt-get install cron -y
crontab -e

At the bottom of our crontab, enter the following, which will set our blacklist to be updated once every day.

0 5 * * * bash /root/gravity.sh

Inspired, but modified version of David Anson’s https://dlaa.me/blog/post/skyhole tutorial.

@daily on LowEndTalk has contributed this tutorial to the community.
wwdboy
发表于 2016-9-23 13:16:11 | 显示全部楼层
汗,楼主不翻译一下?
西湖网络
发表于 2016-9-30 14:13:57 | 显示全部楼层
楼主的签名不错啊
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2024-4-26 01:45 , Processed in 0.114944 second(s), 16 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表