Files
smartdns/docs/config/ip-rule.md
2023-03-26 17:15:23 +08:00

50 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
hide:
- toc
---
# IP规则
smartdns提供了IP地址黑白名单和忽略相关的结果。
|参数|功能|使用场景|
|---|---|---|
|whitelist-ip|白名单 IP 地址|接受在指定范围内的IP地址设置
|blacklist-ip|黑名单 IP 地址|接受在指定范围外的IP地址设置
|ignore-ip|忽略 IP 地址|不需要某个IP地址或IP地址段时设置。
|bogus-nxdomain|假冒 IP 地址过滤|请求结果包含对应IP地址时返回SOA
## 白名单IP地址
如果想对某个上游限制其返回的IP地址在白名单范围非白名单的地址全部丢弃则可以设置如下
```shell
server -whitelist-ip
whitelist-ip 192.168.1.1/24
```
## 黑名单IP地址
如下想对某个上游限制其返回的IP地址将指定范围的IP丢弃则可设置黑名单如下
```shell
server -blacklist-ip
blacklist-ip 192.168.1.1/24
```
## 忽略IP地址
如果希望使用上游返回的某个IP地址可以配置忽略此IP。
```shell
ignore-ip 1.2.3.4
```
## 假冒IP地址
如果网站不存在时被ISP固定返回某个网段的IP地址的404页面则可以使用此参数比如电信的自定义404页面。则可以通过如下配置让客户端接受到SOA而不是被重定向的ISP的404页面。
```shell
bogus-nxdomain 1.2.3.4
```