Skip to Content
Linux 经典实例:第二版
book

Linux 经典实例:第二版

by Carla Schroder
February 2023
Intermediate to advanced
579 pages
8h 36m
Chinese
China Electric Power Press Ltd.
Content preview from Linux 经典实例:第二版
420
16
man 8 networkmanager
16.6
Dnsmasq
配置为局域网的
DNS
服务器
问题
如何将
Dnsmasq
配置为局域网的
DNS
服务器?
解决方法
/etc/hosts
中的所有主机都需要静态
IP
地址,
Dnsmasq
会自动将这些地址送入
DNS
/etc/hosts
中必须包含
Dnsmasq
服务器的静态
IP
地址。在以下示例中,
/etc/
hosts
不仅记录了
Dnsmasq
服务器,还包括备份服务器和内部网络服务器:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
192.168.43.81 dns-server
192.168.43.82 backups
192.168.43.83 https
利用
DHCP
配置静态主机
关于如何利用
DHCP
管理静态
IP
地址分配,请参见
16.12
节。
下面,我们来配置
Dnsmasq
。首先,通过改名的方式禁用默认的配置文件,然后新
建一个空文件,并将原来的文件作为参考:
$
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf-old
$
sudo nano /etc/dnsmasq.conf
复制以下配置,将第二个
listen-address
替换成你的服务器
IP
地址,并使用你自己
的域名。在我们的示例中,上游名称服务器是
OpenDNS
,但你可以使用任何想要的
服务器。
Dnsmasq
默认会查找
/etc/resolv.conf
,但明确指定也无妨:
# global ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana
Essential Linux Device Drivers

Essential Linux Device Drivers

Sreekrishnan Venkateswaran
Mastering FreeBSD and OpenBSD Security

Mastering FreeBSD and OpenBSD Security

Paco Hope, Bruce Potter, Yanek Korff
Advanced Linux Programming

Advanced Linux Programming

Mark Mitchell, Jeffrey Oldham, Alex Samuel

Publisher Resources

ISBN: 9787519869724