大网数据广告活动
服务器运维问答

Bind9 forward to another external IP

· 52CE 我爱测

I have set up a DNS server using bind9 and will forward any DNS request to 1.1.1.1. It working fine with the resolving of DNS requested by users. Note that my DNS resolver is residing in a VPS and not locally in my network. The i…

问题原文

原帖链接 · BindNoob · CC BY-SA 4.0

I have set up a DNS server using bind9 and will forward any DNS request to 1.1.1.1. It working fine with the resolving of DNS requested by users. Note that my DNS resolver is residing in a VPS and not locally in my network.

The issue is that if i would want to redirect a domain 'blocksite.com' to another external IP 100.100.100.200, how can i configure it ?

It will be something like ISP censoring prohibited website and redirect it to another IP (blocked warning page) when user tries to access to the website.

Please help.. much thanks in advance.

已采纳解答

原帖链接 · Esa Jokinen · CC BY-SA 4.0

It's possible to add a zone for the domain, but the feature you are probably looking for is called Response Policy Zones (RPZ). With an RPZ, you can add a single zone that can lie about the domains / hostnames you would like to block.

Response Policy Zone (RPZ) Rewriting

BIND 9 includes a limited mechanism to modify DNS responses for requests analogous to email anti-spam DNS blacklists. Responses can be changed to deny the existence of domains (NXDOMAIN), deny the existence of IP addresses for domains (NODATA), or contain other IP addresses or data.

Response policy zones are named in the response-policy option for the view or among the global options if there is no response-policy option for the view. Response policy zones are ordinary DNS zones containing RRsets that can be queried normally if allowed. It is usually best to restrict those queries with something like allow-query { localhost; };. Note that zones using masterfile-format map cannot be used as policy zones.

options {
    // . . .
    response-policy { zone "rpz"; };
}

zone "rpz" {
    type master;
    file "rpz.db";
    allow-query { 127.0.0.1; };
};

Then you can add the domain to the rpz.db file with an A record to your warning page server:

$TTL 3600
@ IN SOA localhost. root.localhost. ( 2 3H 1H 1W 1H )
@ IN NS localhost.
blocked.example.com. IN A 192.0.2.1

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。