Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

CentOS 6 建置 DNSmasq 的步驟

建立專用使用者

useradd -r -g users dnsmasq

編譯安裝

yum install -y gcc
wget https://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.76.tar.gz
tar zxvf dnsmasq-2.76.tar.gz
cd dnsmasq-2.76
make && make install
cp dnsmasq.conf.example /etc/dnsmasq.conf

修改設定檔

vi /etc/dnsmasq.conf
user=dnsmasq                    # 啟動帳號
group=users                     # 啟動群組
interface=eth0                  # 綁定的網路介面
listen-address=192.168.238.135  # 綁定的 IP
bind-interfaces
resolv-file=/etc/resolv.conf    # 上游域名解析檔
addn-hosts=/etc/hosts           # 額外的 hosts 檔

加入解析記錄

echo "192.168.238.135 www.example.com" >> /etc/hosts

啟動與驗證

/usr/local/sbin/dnsmasq

netstat -tnl | grep 53
# tcp 0 0 127.0.0.1:53        0.0.0.0:*     LISTEN
# tcp 0 0 192.168.238.135:53  0.0.0.0:*     LISTEN

只要 53 埠已成功進入監聽狀態,就代表 DNSmasq 已正常運作。

DNSmasq 的優點是設定極輕量,同時具備 DNS 轉發與 DHCP 能力,很適合內部網路或測試環境使用。

原文出自「唯愛丶琳」部落格:https://love11forever.blog.51cto.com/11313259/1783784

Copyright © Linux教程網 All Rights Reserved