Dernière activité 10 months ago

這份 dnsmasq 設定檔 用於 管理 DNS 和 DHCP 服務,提供 本機網路名稱解析、靜態 IP 配置、DNS 轉發、快取與封鎖特定域名。它設定了 Google、Hinet 作為上游 DNS,開啟 DNS 查詢日誌,並定義 DHCP 位址範圍、靜態 IP 綁定與特定域名解析。適用於 內部網路架構、加速 DNS 解析、提升隱私安全及廣告封鎖 等場景。

Révision 37bebe0c99d00ff7636a23837ba3b996ef048350

dnsmasq.conf Brut
1bogus-priv # Block fake private IP responses
2no-resolv # Ignore /etc/resolv.conf for upstream DNS
3dns-forward-max=150 # Limit parallel DNS queries to 150
4clear-on-reload # Clear cache when dnsmasq reloads
5domain-needed # Ignore queries without a domain name
6no-negcache # Do not cache negative (non-existent) DNS responses
7no-poll # Do not poll /etc/resolv.conf for changes
8strict-order # Use upstream DNS servers in the order they are listed
9
10# AdGuard DNS 封鎖廣告和追蹤器。
11# server=94.140.14.14 # AdGuard DNS (primary) - Standard DNS with no filtering
12# server=94.140.15.15 # AdGuard DNS (secondary) - Standard DNS with no filtering
13
14# AdGuard DNS 封鎖廣告、追蹤器、成人內容,並在可能的情況下啟用安全搜尋和安全模式。
15# server=94.140.14.15 # AdGuard DNS (primary) - Filters ads and trackers
16# server=94.140.15.16 # AdGuard DNS (secondary) - Filters ads and trackers
17
18# server=1.0.0.1 # Cloudflare DNS (secondary)
19# server=1.1.1.1 # Cloudflare DNS (primary)
20
21server=8.8.8.8 # Use Google DNS as an upstream server
22server=168.95.1.1 # Use Hinet DNS as an upstream server
23server=8.8.4.4 # Use Google DNS as an upstream server
24
25listen-address=127.0.0.1,192.168.88.1 # Listen on localhost and the specific network interface
26# cache-size=1000 # Set DNS cache size to 1000 entries
27cache-size=5000 # Cache up to 5000 DNS entries for high traffic
28all-servers # Forward DNS queries to all upstream servers
29
30log-queries # Log all DNS queries
31log-dhcp # Log all DHCP requests and responses
32# log-facility=/var/log/dnsmasq.log # Save logs to /var/log/dnsmasq.log
33log-facility=/dev/null # Disable logging by sending logs to /dev/null
34
35dhcp-range=192.168.88.100,192.168.88.200,24h # DHCP range with a 24-hour lease
36dhcp-option=1,255.255.255.0 # Subnet mask: 255.255.255.0
37dhcp-option=3,192.168.88.1 # Default gateway: 192.168.88.1
38dhcp-option=6,192.168.88.1 # DNS server: 192.168.88.1
39dhcp-option=15,local # DNS domain name: local
40dhcp-lease-max=151 # Maximum number of DHCP leases: 151
41dhcp-leasefile=/var/lib/misc/dnsmasq.leases # File to store DHCP lease information
42
43dhcp-host=00:0c:29:aa:bb:cc,192.168.88.10,infinite # Static IP for Application Server
44dhcp-host=00:0c:29:dd:ee:ff,192.168.88.11,infinite # Static IP for Version Control Server
45dhcp-host=00:0c:29:11:22:33,192.168.88.12,infinite # Static IP for Database Server
46dhcp-host=00:0c:29:44:55:66,192.168.88.13,infinite # Static IP for Web Proxy
47
48address=/example.com/192.168.88.10 # Route all requests for example.com to 192.168.88.10
49address=/test.local/127.0.0.1 # Map test.local to localhost
50address=/ads.example.com/0.0.0.0 # Block ads.example.com by pointing to an invalid IP
51address=/#/192.168.88.1 # Redirect all unknown domains to 192.168.88.1
52
53txt-record=example.com,"v=spf1 include:_spf.google.com ~all"
54txt-record=_acme-challenge.example.com,"abcdef1234567890"
55txt-record=test.local,"Test TXT Record for Internal Use"
56
57host-record=example.com,192.168.88.10 # Map example.com to 192.168.88.10
58host-record=server.local,192.168.88.20,192.168.88.30 # Map server.local to two IPs for load balancing
59host-record=test.local,fe80::1 # Map test.local to IPv6 address fe80::1
60
61srv-host=_sip._udp.example.com,sipserver.example.com,5060,10,60
62srv-host=_sip._udp.example.com,backup.example.com,5060,20,30
63srv-host=_ldap._tcp.example.com,ldap.example.com,389,5,50
64srv-host=_xmpp._tcp.example.com,xmppserver.local,5222,10,100
65