`

Ubuntu下面的Dnsmasq设置

阅读更多
A DNS server resolves domain names into IP addresses. So when you request “yahoo.com” for example, the DNS server finds out the address for the domain, and sends your request the right way.

You can run a DNS cache on your computer. This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement.

The following instructions are for someone with a broadband internet connection, where the computer gets it’s local IP address using DHCP from the router in your home or office.

Install dnsmasq in Ubuntu

Dnsmasq is a lightweight, easy to configure, DNS forwarder and DHCP server. It is designed to provide DNS and optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP for network booting of diskless machines.

First you need to make sure that Universe repository is enabled in your sources.list file

Install dnsmasq Using the following command

sudo apt-get install dnsmasq

uncomment the following line (remove “#” in the beginning) in the file /etc/dnsmasq.conf

listen-address=127.0.0.1

Now edit

/etc/dhcp3/dhclient.conf

and make sure the section below exactly like this, especially the line that says “prepend domain-name-servers 127.0.0.1;”

#supersede domain-name “fugue.com home.vix.com”;
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the

/etc/resolv.conf

file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider). Adding the “prepend” option as we did above ensures that “127.0.0.1″ will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 - your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the “127.0.0.1″. I hope that explains things.

Now open the file

/etc/resolv.conf

in your text editor. It probably looks like:

search yourisp.com
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

The 127.0.0.1 is missing right now since you haven’t renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:

search yourisp.com
nameserver 127.0.0.1
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

Now you need to restart the dnsmasq using the following command

sudo /etc/init.d/dnsmasq restart.

Now you are running a local DNS cache.

Testing Your Local DNS Cache

If you want to measure your speed improvement, type the command

dig yahoo.com

You will see something like “;; Query time: 38 msec” there.

Now type the command again, and you should see something like:”;; Query time: 2 msec”
分享到:
评论

相关推荐

    Ubuntu配置DNS

    Ubuntu配置DNS,设置Ubuntu DNS缓存 1. 安装dnsmasq: # 安装dnsmasq的软件包 [linuxidc@linuxidc-Ubuntu ~] $ sudo apt-get install "dnsmasq" 2.设定dnsmasq接管本机的DNS解析请求: # 修改dnsmasq的配置文件 ...

    dnsmasq.deb

    找了好久才找到能在ubuntu下跑的dnsmasq包,用于分配DNS,搭配hostapd可以发射wifi

    dnsmasq 2.8.9 源代码

    文件名: dnsmasq-2.89.tar.xz Dnsmasq 为小型网络提供网络基础设施:DNS、DHCP、路由器通告和网络引导。它被设计为轻量级且占用空间小,适用于资源受限的路由器和防火墙。它还广泛用于智能手机和便携式热点的网络...

    dnsmasq.tar.gz-2.75

    dnsmasq源码

    dnsmasq,dhcp dns源码

    dnsmasq,dhcp dns源码

    dnsmasq-2.85.tar.xz

    dnsmasq-2.85.tar.xz dnsmasq-2.85.tar.xz dnsmasq-2.85.tar.xz

    dnsmasq为某个域名配置单独的DNS.txt

    dnsmasq为某个域名配置单独的DNS.txt

    dnsmasq-2.59.tar.gz

    dnsmasq-2.59.tar.gz

    安卓dnsmasq

    这是个安卓使用的dnsmasq,文件复制到system/bin,需要配置文件

    dnsmasq学习

    dnsmasq开源代码,是个不错的源码学习资料,绝对适合你了解网络方面的知识

    dnsmasq 源码

    实现了域名解析的功能,集成了dhcp和fttp服务器功能。

    dnsmasq-2.62.tar.gz

    dnsmasq-2.62.tar.gz

    dnsmasq-2.66.tar.gz

    dnsmasq-2.66.tar.gz源代码,省去了去官网下载且下载慢的痛苦

    ubuntu下,关于firefox打开网页慢

    上网慢 真正的原因,仔细观察会发现,主要在...在ubuntu下面就要花费一番功夫了。 所以需要装一个 叫做 dnsmasq的软件,它能提供dns解析的功能。 当然,改造一下,也能提供dns缓存的功能。 具体操作 : 安装dnsmasq

    Automatic-dnsmasq-update:自动dnsmasq更新

    自动dnsmasq更新 自动dnsmasq更新 该脚本将自动更新pgl.yoyo.org的列表。... 下载*您需要设置运行权限。 curl -o dnsmasq.sh https://raw.githubusercontent.com/MLWALK3R/Automatic-dnsmasq-update/master/dnsmasq.sh

    dnsmasq-2.48-6.el6.i686.rpm

    dnsmasq-2.48-6.el6.i686.rpm

    dnsmasq-2.65-1.el6.rfx.x86_64.rpm

    安装openstack,很多人在下载dnsmasq-2.65-1.el6.rfx.x86_64.rpm的时候出错,因此我们可以手动下载,再进行安装,安装指令:rpm -Uvh dnsmasq-2.65-1.el6.rfx.x86_64.rpm

    dnsmasq-chinadns:dnsmasq 的补丁版本,可过滤掉一些虚假 IP

    我建议您使用 dnsmasq 的系统默认设置。 例如,在 Debian GNU/Linux 上,只需将/etc/init.d/dnsmasq中的DAEMON变量更改为/path/of/dnsmasq-chinadns/src/dnsmasq 。 然后使用命令sudo service dnsmasq restart重新...

    CentOS 7 最新版 dnsmasq-2.80-99.el7.centos.x86_64.rpm

    dnsmasq-2.80-99.el7.centos.x86_64.rpm,那个2.80-1或者2.80-99是修订号,我随便写的99,写2.80-1是为了方便大家能搜索到。 这个文件适用于CentOS最新的dnsmasq,最新2.8版本,修复了之前的漏洞,CentOS 7目前已经...

    pxe-installer:将 Ubuntu 14.04 设置为 OS 安装的 PXE 服务器

    将 Ubuntu 14.04 服务器设置为用于操作系统安装的 PXE 服务器。 provision.sh 脚本执行的步骤包括: 安装所需的包 安装和配置 Nginx 到服务器启动文件 为 NAT 配置 ufw 配置dnsmasq(DHCP服务器、DNS服务器、TFTP...

Global site tag (gtag.js) - Google Analytics