1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Leshy DNS Server Configuration Example
[]
# Address to listen on for DNS queries
= "127.0.0.1:15353"
# Default upstream DNS servers (used when no zone matches)
= ["8.8.8.8:53", "8.8.4.4:53"]
# What to do when route addition fails:
# - "servfail": Return SERVFAIL to client
# - "fallback": Continue and return DNS response (default, recommended)
= "fallback"
# Enable automatic config reload when this file changes
# When enabled, Leshy will:
# - Watch this config file for changes
# - Reload configuration automatically
# - Remove routes for deleted zones
# - Start tracking new zones
= true
# DNS response cache settings (global defaults)
# cache_size: max entries, 0 = disabled (default: 1000)
# cache_min_ttl: minimum TTL in seconds (default: 60)
# cache_max_ttl: maximum TTL in seconds (default: 3600)
# cache_negative_ttl: TTL for NXDOMAIN / empty responses in seconds (default: 30)
= 1000
= 60
= 3600
= 30
# Route aggregation: group DNS-resolved IPs into wider CIDR prefixes
# to reduce kernel routing table size. Value is the prefix length (e.g. 24 = /24).
# Unset or 32 = disabled (each IP gets its own /32 route).
# Recommended: 22 (1024 IPs per aggregate) or 24 (256 IPs per aggregate).
# route_aggregation_prefix = 24
# Example Zone 1: Corporate VPN with device-based routing
# Routes traffic through a VPN tunnel device that may connect/disconnect
[[]]
= "corporate"
= "dev" # Route via network device
= "/run/vpn/corporate.dev" # File containing device name (e.g., "tun0")
= ["internal.company.com", "jira.company.com"]
= ["corp"] # Matches any domain containing "corp"
# Per-zone cache TTL overrides (optional, falls back to [server] defaults)
= 30
= 600
# Rich dns_servers format — per-server cache TTL overrides:
[[]]
= "10.44.2.2:53"
= 10
= 300
[[]]
= "10.44.2.4:53"
# inherits zone → global defaults
# Example Zone 2: EU VPN with static gateway
# Routes traffic through a fixed gateway (always-on VPN)
[[]]
= "eu"
= [] # Empty = use default_upstream
= "via"
= "192.168.169.1" # Static VPN gateway IP
= ["chatgpt.com", "github.com"]
= ["openai", "anthropic"]
# Example Zone 3: Office network
# Simple dns_servers format still works:
[[]]
= "office"
= ["192.168.1.1:53"]
= "via"
= "192.168.1.254"
= ["office.local", "printer.local"]
= []