`

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

    本文将详细介绍如何通过安装`dnsmasq`服务并进行相应的配置来实现Ubuntu系统内的DNS缓存功能。 #### 二、安装dnsmasq dnsmasq是一款轻量级的DNS代理服务,它能够提供DNS缓存功能以及简单的DHCP服务。首先需要安装...

    dnsmasq.deb

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

    dnsmasq 源码

    下面将详细探讨dnsmasq的核心功能、工作原理以及源码分析。 **一、dnsmasq的主要功能** 1. **DNS服务**:dnsmasq作为一个本地DNS缓存服务器,它可以缓存来自互联网的DNS查询结果,减少对远程DNS服务器的依赖,提高...

    设置UbuntuDNS缓存linux服务器应用-电脑资料.pdf

    设置 Ubuntu DNS 缓存 Linux 服务器应用 - 电脑资料设置 Ubuntu DNS 缓存 本文档主要介绍了如何在 Ubuntu 系统中设置 DNS 缓存服务器,提高 DNS 解析速度。下面是该文档中的知识点总结: 1. 安装 dnsmasq 软件包:...

    dnsmasq 2.8.9 源代码

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

    dnsmasq,dhcp dns源码

    此外,dnsmasq还可以设置为只对特定的域名进行解析,提高了网络的安全性。 **DHCP(Dynamic Host Configuration Protocol)**是一种自动分配IP地址和其他网络配置信息的协议。在dnsmasq中,你可以配置它作为DHCP...

    dnsmasq-2.66.tar.gz

    你可以在这里设置DNS查询转发、DHCP范围和其他选项。 6. **启动与管理**:根据你的系统,可能需要使用`systemd`、`init.d`或类似的服务管理工具来启动、停止或重启dnsmasq服务。 7. **测试与调试**:启动dnsmasq后...

    ubuntu下,关于firefox打开网页慢

    为了提高 Firefox 在 Ubuntu 下的浏览速度,可以通过安装名为 `dnsmasq` 的软件来实现 DNS 缓存功能。`dnsmasq` 是一款轻量级的 DNS 代理服务器,它不仅可以提供 DNS 解析服务,还可以通过缓存功能加速域名解析过程...

    dnsmasq学习

    2. `domain=`:设置本地域,所有未明确解析的域名都将被视为该域的一部分,方便处理内部网络的主机名。 3. `server=`:定义上游DNS服务器,dnsmasq将向这些服务器发送未在本地解决的DNS查询。 4. `dhcp-range` 和 ...

    dnsmasq-2.62.tar.gz

    dnsmasq在这样的设备上运行,可以帮助优化网络设置,并为无线客户端提供DNS和DHCP服务。 在"dnsmasq-2.62"这个压缩包中,我们可以期待找到以下文件: 1. `README`:包含项目的基本信息、安装指南和使用注意事项。 2...

    dnsmasq-2.59.tar.gz

    dnsmasq是一款轻量级的DNS服务器和DHCP服务器,适用于小型网络环境,如家庭或小型办公室。它设计简洁,易于配置,并且能够提供DNS缓存和DNS转发服务,帮助提升网络性能,减少对互联网DNS服务器的依赖。dnsmasq版本...

    dnsmasq 源代码

    dnsmasq的DHCP服务可以灵活配置,例如限制特定MAC地址的IP分配,或者设置IP地址的租约时间,这使得它在家庭和小型网络环境中非常实用。 除了核心功能外,dnsmasq还包含了一些辅助功能,如TFTP服务器(用于传输配置...

    dnsmasq.tar.gz-2.75

    dnsmasq源码

    dnsmasq-2.85.tar.xz

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

    ubuntu下创建热点的脚本

    `hostapd`是一个用于将无线网卡设置为接入点模式的软件,而`dnsmasq`则作为一个轻量级的DNS和DHCP服务器,帮助分配IP地址给连接到热点的设备。 首先,让我们深入了解如何手动配置这个过程,以便理解`ap.sh`脚本可能...

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

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

    安卓dnsmasq

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

    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目前已经...

    ubuntu拔插网线或usb网卡导致dns服务丢失的解决办法.docx

    然而,在 Ubuntu 系统中,dnsmasq 服务有一个 bug,那就是它会修改 /etc/resolv.conf 文件,从而导致 DNS 服务丢失。 要解决这个问题,可以按照以下步骤操作: 1. 使用 sudo 权限编辑 /etc/NetworkManager/...

    dnsmasq-2.80.tar.xz

    openwrt中的dl目录文件,编译工具链、目标平台的软件包等需要下载的文件

Global site tag (gtag.js) - Google Analytics