Кол-во просмотров: 249
Обновлено 27.11.2025
Unbound — это легкий, высокопроизводительный рекурсивный DNS-резолвер, который можно использовать для повышения скорости и безопасности разрешения DNS. FreeBSD включает Unbound в свою базовую систему, что упрощает настройку и конфигурирование. Это руководство поможет вам установить, настроить и защитить Unbound как локальный DNS-резолвер на FreeBSD.
1. Understanding Unbound
Unbound — это проверяющий, кэширующий и рекурсивный DNS-распознаватель. При настройке в качестве локального распознавателя он напрямую запрашивает авторитетные DNS-серверы вместо того, чтобы полагаться на вышестоящего поставщика, такого как DNS вашего интернет-провайдера или Google Public DNS. Это повышает конфиденциальность, уменьшает задержку и повышает общую надежность.
Benefits of Using Unbound
- Improved Performance: Caches DNS responses for faster lookup times.
- Better Privacy: Reduces reliance on third-party DNS services.
- Security Features: Supports DNSSEC for secure and validated DNS responses.
- Customizable: Allows fine-tuning of DNS configurations for specific needs.
2. Installing Unbound on FreeBSD
On FreeBSD, Unbound comes pre-installed in the base system. However, if you need additional features or a newer version, you can install it from ports or packages.
Verify if Unbound is Installed
If Unbound is not installed, you can install it using:
3. Configuring Unbound as a Local Resolver
Edit the Unbound Configuration File
The primary configuration file for Unbound is located at:
Use your preferred text editor to modify the configuration file:
Basic Configuration Example
Below is a minimal working configuration for a local resolver:
Explanation of Key Settings
- interface: Specifies which network interfaces Unbound listens on.
- access-control: Defines which IPs can use this resolver.
- root-hints: Points to a file containing root DNS server hints.
- cache settings: Controls how long DNS responses are cached.
- DNSSEC settings: Enables DNS security extensions.
- forward-zone: Specifies upstream resolvers if needed.
4. Fetching Root Hints File
Unbound requires a root hints file for direct resolution. You can download it from the official source:
Update this file periodically to keep it current.
5. Enabling and Starting Unbound
To enable Unbound at boot:
Start the Unbound service:
To check the status:
6. Configuring FreeBSD to Use Unbound as a Resolver
To make FreeBSD use Unbound for DNS resolution, update /etc/resolv.conf:
This ensures all DNS queries go through your local Unbound instance.
7. Testing Your Configuration
To verify Unbound is working correctly, use:
If it resolves successfully, Unbound is functioning correctly.
To check caching, run the same command twice and note the reduced query time on the second attempt.
8. Enabling DNSSEC Validation
Unbound supports DNSSEC to verify the authenticity of DNS responses. Enable it by ensuring these settings are present in /etc/unbound/unbound.conf:
Initialize DNSSEC support:
Restart Unbound:
To verify DNSSEC validation:
Look for the ad (Authenticated Data) flag in the response.
9. Optimizing and Securing Unbound
Blocking Ads and Trackers
Unbound can block ads and trackers by using blocklists. Add entries to /etc/unbound/unbound.conf:
Replace example.com with known ad domains.
Rate Limiting
To prevent abuse, enable rate limiting:
Logging Queries
For troubleshooting, enable logging:
Ensure Unbound can write to this file:
Restart Unbound:
10. Conclusion
Setting up Unbound as a local DNS resolver on FreeBSD enhances speed, security, and privacy. By configuring Unbound properly, enabling DNSSEC, and optimizing settings, you can create a reliable and efficient DNS setup tailored to your needs. Regular maintenance, such as updating root hints and monitoring logs, ensures continued performance and security.
With this setup, your FreeBSD system can now resolve domain names efficiently without relying on external DNS providers.
Источник: https://www.siberoloji.com/how-to-configure-unbound-as-a-local-dns-resolver-on-freebsd/