Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Dnsmasq configuration

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

First of all, tell me about my environment.

Centos 6.7

[root@oldboy ~] # uname-r

2.6.32-573.el6.x86_64

Step one:

Before installing dnsmasq, configure static ip for the native machine

[root@oldboy ~] # cat/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=192.168.10.253

NETMASK=255.255.255.0

GATEWAY=192.168.10.2

[root@oldboy ~] # ifconfig eth0 | sed-n '2p'

Inet addr:192.168.10.253 Bcast:192.168.10.255 Mask:255.255.255.0

First of all, make sure you have access to the Internet.

[root@oldboy ~] # ping www.baidu.com-c 4

PING www.a.shifen.com (61.135.169.121) 56 (84) bytesof data.

64 bytes from 61.135.169.121: icmp_seq=1 ttl=128time=4.14 ms

64 bytes from 61.135.169.121: icmp_seq=2 ttl=128time=16.6 ms

64 bytes from 61.135.169.121: icmp_seq=4 ttl=128time=20.5 ms

Step 2:

[root@oldboy ~] # yum install dnsmasq-y

Loaded plug-ins: fastestmirror, security

Set up the installation process

Loading mirror speeds from cached hostfile

* base:mirrors.aliyun.com

* extras:mirrors.aliyun.com

* updates:mirrors.aliyun.com

Resolve dependencies

-- > perform transaction check

-> Package dnsmasq.x86_64 0RU 2.48-16.el6_7 willbe installation

-- > complete dependency calculation

Dependency resolution

=

Package architecture version repository size

=

Installing:

Dnsmasq x8631 64 2.48-16.el6_7 updates 149k

Transaction summary

=

Install 1 Package (s)

Total downloads: 149k

Installed size: 293 k

Download the software package:

Dnsmasq-2.48-16.el6_7.x86_64.rpm | 149 kB 00:06

Run rpm_check_debug

Perform transaction testing

Transaction test was successful

Execute a transaction

Installing: dnsmasq-2.48-16.el6_7.x86_64 1 Compact 1

Verifying: dnsmasq-2.48-16.el6_7.x86_64 1 Compact 1

Installed:

Dnsmasq.x86_64 0VOR 2.48-16.el6_7

Over!

Step three

Edit [root@oldboy ~] # vim / etc/dnsmasq.conf

Only two changes are needed.

Modify 90 lines

Listen-address=127.0.0.1192.168.10.253

192.168.10.253 is the native ip, the dns address of the client

Modify 432 lines

Cache-size=10000

Set dns cache, cache size, set on demand

Step 4:

[root@oldboy ~] # cat / etc/resolv.conf

; generated by / sbin/dhclient-script

Search localdomain

Nameserver 223.5.5.5

Nameserver 202.106.46.151

223.5.5.5 is Ali DNS

202.106.46.151. For the dns of the local operator, add it by yourself. You can specify the upstream dns.

Step five

Next, start the service and set it to boot

[root@oldboy ~] # / etc/init.d/dnsmasq start

Starting dnsmasq: [OK]

[root@oldboy] # chkconfig-- level 3 dnsmasq on

[root@oldboy ~] # chkconfig-- list | grep dnsmasq

Dnsmasq 0: off 1: close 2: close 3: enable 4: close 5: close 6: close

[root@oldboy ~] #

Step six

Set the client dns to our dnsmasq server address and test

Note twice;; Query time: 20 msec interval between two times

[root@oldboy ~] # dig www.baidu.com

; DiG9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6 www.baidu.com

;; global options: + cmd

;; Got answer:

;;-> > HEADERHEADER

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report