OpenWrt AdGuardHome AdBlock DoH DoT ペアレンタルコントロール

:flag_jp: Japanese notation
![OpenWrt_icon.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/0b0bc5ce-e281-3732-a9f3-2c8a76b889a5.png)


# こちらに統合しました
https://qiita.com/site_u/items/c6a50aa6dea965b5a774

![config.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/ebcf1227-8809-3fad-ba47-5e44a04ccac6.png)

# はじめに
::: note
### 初心者対応構成
- スクリプトでの自動設定
- [UCI (ttyd)](https://openwrt.org/docs/guide-user/base-system/uci)、[Webコンソール (LuCi)](https://openwrt.org/docs/guide-user/luci/start)、[ファイラー (SFTP)](https://openwrt.org/docs/guide-user/services/nas/sftp.server)にて比較作業がおススメ:exclamation:
:::

::: note
### デバイスアクセス
#### [PowerShell](https://learn.microsoft.com/ja-jp/powershell/scripting/what-is-windows-powershell?view=powershell-7.4)の開始
- キー入力：**`Win`+`x` > `a` > `はい`**

#### [UCI（SSH）アクセス](https://openwrt.org/docs/guide-quick-start/sshadministration)
```powershell:powershell:初期設定用
ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-rsa root@192.168.1.1
```
- root@192.168.1.1's password:`初期値：パスワード無し`

<details><summary>OpenSSHのインストールが無い場合:exclamation:</summary>

- 機能の確認
※Windows 10 Fall Creators Update(1709)以降標準搭載
```powershell:powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
```
- 機能のインストール
```powershell:powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
```
---

:::

::: note alert
### 以下排他利用推奨

- AdGuardとAdBlock
- AdGuardとDNS over HTTPS (DoH)
- AdGuardとDNS over TLS (DoT)
- DNS over HTTPS (DoH)とDNS over TLS (DoT)

AdGuardはフラッシュ容量12M程度は最低限必要
フラッシュ容量が小さい場合AdBlock推奨
:::

# [AdGuardHome](https://openwrt.org/docs/guide-user/services/dns/adguard-home)

<details><summary>設定</summary>

::: note
### ワンコピペ自動スクリプト
これ一つで以下の以下の機能を満たす(おススメ)
- 広告ブロック
- ペアレンタルコントロール
- DNS over HTTPS (DoH)
- DNS over TLS (DoT)

**[前提条件](https://openwrt.org/docs/guide-user/services/dns/adguard-home#prerequisites)**
  - 少なくとも 50MB の空き RAM
  - 少なくとも 100MB のディスク/フラッシュ空き容量 (フラッシュ/ストレージ要件を参照)
  - より高性能なルーター、つまりプロセッサ クロック速度が高いデュアルコアを推奨します

スクリプト
- [adguard-config.sh](https://github.com/site-u2023/config-software/blob/main/adguard-config.sh)
  - [adguard.sh](https://github.com/site-u2023/config-software/blob/main/adguard.sh)

インストール
- adguard
- [htpasswd](https://github.com/site-u2023/config-software/blob/main/htpasswd)
- [libaprutil](https://openwrt.org/packages/pkgdata_owrt19_7/libaprutil)
- [libapr](https://openwrt.org/packages/pkgdata/libapr)
- [libexpat](https://openwrt.org/packages/pkgdata/libexpat)
- [libuuid1](https://openwrt.org/packages/pkgdata_owrt19_7/libuuid1)

アドイン
- [AdGuard Japanese filter](https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_7_Japanese/filter.txt)
- [280blocker](https://280blocker.net/)

**スクリプト実行**
```sh:SSH: /etc/config-software/adguard-config.sh
mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/adguard-config.sh https://raw.githubusercontent.com/site-u2023/config-software/main/adguard-config.sh; sh /etc/config-software/adguard-config.sh
```
※強制終了：Ctrl+c
※LANインターフェイス名=`lan`
:::

::: note
### AdGuardHome自動構成の設定内容
利用可能サイズ確認
- フラッシュ
※参考利用フラッシュ: WXR-5950AX12 71.3M - 60.0M = 11.3M
```sh:SSH: 
df -Th | fgrep 'overlayfs:/overlay' | awk '{ print $5 }'
```
- メモリー
```sh:SSH: 
free | fgrep 'Mem:' | awk '{ print $4 }'
```

- インストール
  - [パッケージインストール](https://openwrt.org/packages/pkgdata/adguardhome)
  - ~~[ネイティブインストール](https://github.com/AdguardTeam/AdGuardHome?tab=readme-ov-file)~~
~~[Releases](https://github.com/AdguardTeam/AdGuardHome/releases)~~
~~※最新バージョン自動設定~~

```sh:SSH: 
#! /bin/sh
# Backup
cp /etc/config/network /etc/config/network.adguard.bak
cp /etc/config/dhcp /etc/config/dhcp.adguard.bak
cp /etc/config/firewall /etc/config/firewall.adguard.bak
# Check version & Install
OPENWRT_RELEAS=$(grep 'DISTRIB_RELEASE' /etc/openwrt_release | cut -d"'" -f2 | cut -c 1-2)
if [[ "${OPENWRT_RELEAS}" = "24" || "${OPENWRT_RELEAS}" = "23" || "${OPENWRT_RELEAS}" = "22" || "${OPENWRT_RELEAS}" = "21" ]]; then
  opkg update
  opkg install adguardhome
  exit
elif [[ "${OPENWRT_RELEAS}" = "SN" ]]; then
  apk update
  apk add adguardhome
  exit
fi
```

- インストール確認
```sh:SSH:
AdGuardHome -s status
```

- デバイス設定
```sh:SSH: 
service adguardhome enable
service adguardhome start
NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1] }')
echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"
uci set dhcp.@dnsmasq[0].noresolv="0"
uci set dhcp.@dnsmasq[0].cachesize="1000"
uci set dhcp.@dnsmasq[0].rebind_protection='0'
uci set dhcp.@dnsmasq[0].port="54"
uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="${NET_ADDR}"
uci -q delete dhcp.lan.dhcp_option
uci -q delete dhcp.lan.dns
uci add_list dhcp.lan.dhcp_option='6,'"${NET_ADDR}" 
uci add_list dhcp.lan.dhcp_option='3,'"${NET_ADDR}"
for OUTPUT in $(ip -o -6 addr list br-lan scope global | awk '{ split($4, ip_addr, "/"); print ip_addr[1] }')
do
	echo "Adding $OUTPUT to IPV6 DNS"
	uci add_list dhcp.lan.dns=$OUTPUT
done
uci commit dhcp
/etc/init.d/dnsmasq restart
# DNSインターセプト@IPTables(ファイアウォール3)
# IPV4
uci set firewall.adguardhome_dns_53='redirect'
uci set firewall.adguardhome_dns_53.src='lan'
uci set firewall.adguardhome_dns_53.proto='tcp udp'
uci set firewall.adguardhome_dns_53.src_dport='53'
uci set firewall.adguardhome_dns_53.target='DNAT'
uci set firewall.adguardhome_dns_53.name='Adguard Home'
uci set firewall.adguardhome_dns_53.dest='lan'
uci set firewall.adguardhome_dns_53.dest_port='53'
# IPV6
uci set firewall.adguardhome_dns_53.family="any"
uci commit firewall
/etc/init.d/firewall restart
#reboot
```

- 疎通確認
```sh:SSH: 
nslookup one.one.one.one localhost

```

- [AdGuardHomeログイン](https://github.com/AdguardTeam/AdGuardHome/wiki)
  - [192.168.1.1:3000](http://192.168.1.1:3000)
  - QRコード : 192.168.1.1:3000
![QR_063146.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/9ea275eb-06f7-91ac-fd17-862d4919ea2c.png)
  - QRコード : 192.168.1.1:8080
![QR_063231.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/024def81-6fa6-e8d0-6c1c-865d4c7b6360.png)

- 初期設定
  - 管理用ウェブインターフェイス
    - `すべてのインターフェイス`　ポート`8080`※80以外の任意
  - DNSサーバ
    - `すべてのインターフェイス`　ポート`53`
  - ユーザー名　`任意`
  - パスワード　`任意`
  - パスワード(確認用)　`任意`

- [AdGuardHome設定](https://openwrt.org/docs/guide-user/services/dns/adguard-home#web_interface)

- 直接設定ファイルに記述する場合
```sh:SSH: 
# サービス停止
service adguardhome stop
```
```sh:SSH: 
# 設定ファイルに記述
vi /etc/adguardhome.yaml
```
```sh:SSH: 
# サービス開始
service adguardhome start
```

- DNS設定
  - 上流DNSサーバ
[既知のDNSプロバイダーの一覧](https://adguard-dns.io/kb/ja/general/dns-providers/)
```yaml:yaml: 上流DNSサーバ
# LAN domain intercept
[/lan/]127.0.0.1:54
[//]127.0.0.1:54
# DNS-over-QUIC
quic://unfiltered.adguard-dns.com
# DNS-over-TLS
tls://1dot1dot1dot1.cloudflare-dns.com
tls://dns.google
# DNS-over-HTTPS(coercion HTTP/3)
h3://dns.cloudflare.com/dns-query
h3://dns.google/dns-query
h3://unfiltered.adguard-dns.com/dns-query
# DNS-over-HTTPS
# https://dns.cloudflare.com/dns-query
# https://dns.google/dns-query
# https://unfiltered.adguard-dns.com/dns-query
# NTP service
[/jp.pool.ntp.org/]1.1.1.1
[/pool.ntp.org/]1.0.0.1
[/jp.pool.ntp.org/]2606:4700:4700::1111
[/pool.ntp.org/]2606:4700:4700::1001
```

- ブートストラップDNSサーバ
```yaml:yaml: ブートストラップDNSサーバ
1.1.1.1
1.0.0.1
2606:4700:4700::1111
2606:4700:4700::1001
```

- プライベートリバースDNSサーバー
```yaml:yaml: プライベートリバースDNSサーバー
192.168.1.1:54
```
- [x] プライベートリバースDNSリゾルバを使用
- [x] クライアントのIPアドレスの逆解決を有効にする

- DNSブロックリスト
  - ブロックリストに追加する
    - カスタムリストを追加する
      - 新しいブロックリスト

- フィルターリスト
  - [AdGuardフィルターリスト（adguard.com）](https://adguard.com/kb/ja/general/ad-filtering/adguard-filters/)
  - [AdGuardフィルターリスト（GitHub）](https://github.com/AdguardTeam/AdguardFilters)
  - [280blocker](https://280blocker.net/)
  - [豆腐フィルタ](https://github.com/tofukko/filter)
  - [なんJ AdGuard部](https://wikiwiki.jp/nanj-adguard/)

- AdGuard Japanese filterの参考手順
```yaml:yaml: 名称を入力
AdGuard Japanese filter
```
```yaml:yaml: リストのURLまたは絶対パスを入力してください
https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_7_Japanese/filter.txt
```

- 280blockerの参考手順
```yaml:yaml: 名称を入力
280blocker
```
```yaml:yaml: リストのURLまたは絶対パスを入力してください
https://280blocker.net/files/280blocker_domain_ag_202307.txt
# `202307`は翌月の年月を入力
```

- 豆腐フィルタの参考手順
```yaml:yaml: 名称を入力
豆腐フィルタ

```
```yaml:yaml: リストのURLまたは絶対パスを入力してください
https://raw.githubusercontent.com/tofukko/filter/master/Adblock_Plus_list.txt
```

- [x] AdGuard DNS filter
- [ ] AdAway Default Blocklist
- [x] AdGuard Japanese filter
- [x] 280blocker
- [x] 豆腐フィルタ


- 確認
  - [Toolz](https://d3ward.github.io/toolz/)
    - [Adblock Test](https://d3ward.github.io/toolz/adblock.html)
  - AdGuard
    - [dGuardのDNSサーバーの位置地図](https://adguard-dns.io/welcome.html#servers-map)
    - [AdGuardサービスの作動確認ページ](https://adguard.com/test.html)
  - Cloudflar
    - [Connection Information](https://1.1.1.1/help)
    - [Browsing Experience Security Check](https://www.cloudflare.com/ssl/encrypted-sni/#results)
  - [DNS leak test](https://dnsleaktest.com/)
  - [IP/DNS Detect](https://ipleak.net/)
![1.1.1.1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3412833/5e3a0b24-7acf-fb3e-8d1b-6f5bd1d7e400.png)
  - Mac App Store
    - [AdGuard Home Remote](https://apps.apple.com/jp/app/adguard-home-remote/id1543143740)
- カスタムフィルタ
  - フィルタ
    - カスタム・フィルタリングルール
※yutubeの参考手順
```yaml:yaml: 1つの行に1つのルールを入力してください。 広告ブロックルールやhostsファイル構文を使用できます。
# ブロック
||amazon.co.jp
# 解除
@@||youtube.com
```

### [ウェブパスワードをリセットする](https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration#reset-web-password)

[htpasswdを使えるようにする](https://qiita.com/site_u/items/3236b10a480d4ca9495e#htpasswd%E3%82%92%E4%BD%BF%E3%81%88%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B)

### [アンインストール](https://openwrt.org/docs/guide-user/services/dns/adguard-home#uninstalling)
```sh:SSH
service adguardhome stop
service adguardhome disable
# Check version & Remove
OPENWRT_RELEAS=$(grep 'DISTRIB_RELEASE' /etc/openwrt_release | cut -d"'" -f2 | cut -c 1-2)
if [[ "${OPENWRT_RELEAS}" = "24" || "${OPENWRT_RELEAS}" = "23" || "${OPENWRT_RELEAS}" = "22" || "${OPENWRT_RELEAS}" = "21" ]]; then
  opkg remove adguardhome
elif [[ "${OPENWRT_RELEAS}" = "SN" ]]; then
  apk del adguardhome
  exit
fi
uci -q delete dhcp.@dnsmasq[0].noresolv
uci -q delete dhcp.@dnsmasq[0].cachesize
uci set dhcp.@dnsmasq[0].rebind_protection='1'
uci -q delete dhcp.@dnsmasq[0].server
uci -q delete dhcp.@dnsmasq[0].port
uci -q delete dhcp.lan.dhcp_option
uci -q delete dhcp.lan.dns
uci add_list dhcp.lan.dhcp_option="6,1.1.1.1,1.0.0.1"
uci add_list dhcp.lan.dhcp_option="6,8.8.8.8,8.8.4.4"
uci add_list dhcp.lan.dns="2606:4700:4700::1111"
uci add_list dhcp.lan.dns="2606:4700:4700::1001"
uci add_list dhcp.lan.dns="2001:4860:4860::8888"
uci add_list dhcp.lan.dns="2001:4860:4860::8844"
uci set network.wan.peerdns="0"
uci set network.wan6.peerdns="0"
uci -q delete network.wan.dns
uci -q delete network.wan6.dns
uci -q delete firewall.adguardhome_dns_53
uci commit
# reboot
```
:::

::: note warn
### 既知の問題
インストール出来ない場合、以下を利用してみる
* Beta builds
    * [Raspberry Pi (32-bit ARMv6)](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm.tar.gz)
    * [MacOS](https://static.adguard.com/adguardhome/beta/AdGuardHome_MacOS.zip)
    * [Windows 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_Windows_amd64.zip)
    * [Windows 32-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_Windows_386.zip)
    * [Linux 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_amd64.tar.gz)
    * [Linux 32-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_386.tar.gz)
    * [FreeBSD 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_freebsd_amd64.tar.gz)
    * [Linux 64-bit ARM](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm64.tar.gz)
    * [Linux 32-bit ARMv5](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_armv5.tar.gz)
    * [MIPS](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_mips.tar.gz)
    * [MIPSLE](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_mipsle.tar.gz)
* [Docker Hub](https://hub.docker.com/r/adguard/adguardhome)
* [Snap Store](https://snapcraft.io/adguard-home)

:::

</details>

# [AdBlock](https://openwrt.org/docs/guide-user/services/ad-blocking)

<details><summary>設定</summary>

::: note
### ワンコピペ自動スクリプト
フィルター
- [豆腐フィルタ](https://github.com/tofukko/filter)
- [なんJ AdGuard部](https://wikiwiki.jp/nanj-adguard/)

スクリプト
- [adblock-config.sh](https://github.com/site-u2023/config-software/blob/main/adblock-config.sh)
  - [adblock.sh](https://github.com/site-u2023/config-software/blob/main/adblock.sh)
  - [adblock-fast.sh](https://github.com/site-u2023/config-software/blob/main/adblock-fast.sh)

アドイン
  - [Adblock_Plus_list.txt](https://github.com/tofukko/filter/blob/master/Adblock_Plus_list.txt)

**スクリプト実行**
```sh:SSH: /etc/config-software/adblock.sh
mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/adblock-config.sh https://raw.githubusercontent.com/site-u2023/config-software/main/adblock-config.sh; sh /etc/config-software/adblock-config.sh
```
※強制終了：Ctrl+c
:::

::: note
### AdBlock自動構成の設定内容
設定
```sh:SSH: 
opkg update
opkg install adblock
opkg install luci-i18n-adblock-ja
opkg install tcpdump-mini
uci set adblock.global.adb_backupdir="/etc/adblock"
cp /etc/adblock/adblock.sources.gz /etc/adblock/adblock.sources.tofu.gz
gunzip /etc/adblock/adblock.sources.tofu.gz
sed -i -e '$d' /etc/adblock/adblock.sources.tofu
sed -i -e '$d' /etc/adblock/adblock.sources.tofu
cat <<"EOF" >> /etc/adblock/adblock.sources.tofu
                },
                "tofu": {
                                "url": "https://raw.githubusercontent.com/tofukko/filter/master/Adblock_Plus_list.txt",
                                "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
                                "size": "XL",
                                "focus": "tofu",
                                "descurl": "https://github.com/tofukko/filter"
               }
}
EOF
gzip /etc/adblock/adblock.sources.tofu
uci set adblock.global.adb_srcarc="/etc/adblock/adblock.sources.tofu.gz"
uci set adblock.global.adb_enabled="1"
uci set adblock.global.adb_backup="1"
uci set adblock.global.adb_backupdir="/etc/adblock"
uci set adblock.global.adb_backup_mode="1"
uci add_list adblock.global.adb_sources='tofu'
uci commit adblock
/etc/init.d/adblock enable
/etc/init.d/adblock start
```

確認
- [Panopticlick](https://coveryourtracks.eff.org/)
- [Toolz](https://d3ward.github.io/toolz/)
  - [Adblock Test](https://d3ward.github.io/toolz/adblock.html)
:::
::: note
### AdBlock-fast自動構成の設定内容
- [OpenWrt デバイスに OPKG/IPK リポジトリを追加する (GitHub)](https://docs.openwrt.melmac.net/#on-your-router)
```sh:SSH: 
opkg update
opkg install wget-ssl
echo -e -n 'untrusted comment: OpenWrt usign key of Stan Grishin\nRWR//HUXxMwMVnx7fESOKO7x8XoW4/dRidJPjt91hAAU2L59mYvHy0Fa\n' > /etc/opkg/keys/7ffc7517c4cc0c56
sed -i '/stangri_repo/d' /etc/opkg/customfeeds.conf
echo 'src/gz stangri_repo https://repo.openwrt.melmac.net' >> /etc/opkg/customfeeds.conf
```

- 設定
```sh:SSH: 
#! /bin/sh
opkg update
opkg install adblock-fast
opkg install luci-app-adblock-fast
opkg install luci-i18n-adblock-fast-ja
opkg install ip6tables-mod-nat
opkg install kmod-ipt-nat6
opkg --force-overwrite install gawk grep sed coreutils-sort
uci set adblock-fast.config.enabled=1
uci set adblock-fast.config.procd_trigger_wan6='1'
uci set adblock-fast.file_url=file_url
uci set adblock-fast.file_url.url='https://raw.githubusercontent.com/tofukko/filter/master/Adblock_Plus_list.txt'
uci set adblock-fast.file_url.action='block'
uci set adblock-fast.file_url.enabled='1'
uci commit adblock-fast
service adblock-fast enable
service adblock-fast start
```

確認
- [Panopticlick](https://coveryourtracks.eff.org/)
- [Toolz](https://d3ward.github.io/toolz/)
  - [Adblock Test](https://d3ward.github.io/toolz/adblock.html)
:::


</details>

# [DNS over HTTPS (DoH)](https://openwrt.org/docs/guide-user/services/dns/doh_dnsmasq_https-dns-proxy)

<details><summary>設定</summary>

::: note
### HTTPS-DNS-PROXY
### ワンコピペ自動スクリプト
- [doh.sh](https://github.com/site-u2023/config-software/blob/main/doh.sh)

**スクリプト実行**
```sh:SSH: /etc/config-software/doh.sh
mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/doh.sh https://raw.githubusercontent.com/site-u2023/config-software/main/dot.sh; sh /etc/config-software/doh.sh
```
※強制終了：Ctrl+c
:::

::: note
### 自動構成の設定内容
設定
```sh:SSH: 
opkg update
opkg install https-dns-proxy
opkg install luci-app-https-dns-proxy
opkg install luci-i18n-https-dns-proxy-ja
/etc/init.d/rpcd restart
#
while uci -q delete https-dns-proxy.@https-dns-proxy[0]; do :; done
uci set https-dns-proxy.dns="https-dns-proxy"
uci set https-dns-proxy.dns.bootstrap_dns="1.1.1.1,1.0.0.1"
uci set https-dns-proxy.dns.resolver_url="https://cloudflare-dns.com/dns-query"
uci set https-dns-proxy.dns.listen_addr="127.0.0.1"
uci set https-dns-proxy.dns.listen_port="5053"
uci commit https-dns-proxy
/etc/init.d/https-dns-proxy restart
```

確認
```sh:SSH: 
nslookup one.one.one.one localhost
```

- [Connection Information](https://1.1.1.1/help)
- [Browsing Experience Security Check](https://www.cloudflare.com/ssl/encrypted-sni/#results)

:::

</details>

# [DNS over TLS (DoT)](https://openwrt.org/docs/guide-user/services/dns/dot_dnsmasq_stubby)

<details><summary>設定</summary>

::: note
### STUBBY
### ワンコピペ自動スクリプト
- [dot.sh](https://github.com/site-u2023/config-software/blob/main/dot.sh)

**スクリプト実行**
```sh:SSH: /etc/config-software/dot.sh
mkdir -p /etc/config-software; wget --no-check-certificate -O /etc/config-software/dot.sh https://raw.githubusercontent.com/site-u2023/config-software/main/dot.sh; sh /etc/config-software/dot.sh
```
※強制終了：Ctrl+c
:::

::: note
### 自動構成の設定内容
設定
```sh:SSH: 
opkg update
opkg install stubby
/etc/init.d/dnsmasq stop
uci set dhcp.@dnsmasq[0].noresolv="1"
uci set dhcp.@dnsmasq[0].localuse="1"
uci -q delete dhcp.@dnsmasq[0].server
uci -q get stubby.global.listen_address \
| sed -e "s/\s/\n/g;s/@/#/g" \
| while read -r STUBBY_SERV
do uci add_list dhcp.@dnsmasq[0].server="${STUBBY_SERV}"
done
uci set network.wan.peerdns='0'
uci set network.wan.dns='127.0.0.1'
uci set network.wan6.peerdns='0'
uci set network.wan6.dns='0::1'
uci commit
/etc/init.d/dnsmasq start
/etc/init.d/network reload
# ブート失敗対策
sed -i "/exit 0/d" /etc/rc.local
echo "/etc/init.d/stubby restart" >> /etc/rc.local 
echo "exit 0" >> /etc/rc.local 
```
確認
```sh:SSH: 
nslookup one.one.one.one localhost
```
- [Connection Information](https://1.1.1.1/help)
- [Browsing Experience Security Check](https://www.cloudflare.com/ssl/encrypted-sni/#results)
:::


</details>

# [ペアレンタルコントロール](https://openwrt.org/docs/guide-user/firewall/fw3_configurations/fw3_parent_controls)

<details><summary>設定</summary>

::: note
### [インターネットアクセスの時間制限](https://openwrt.org/docs/guide-user/firewall/fw3_configurations/fw3_parent_controls#time_restriction_of_internet_access)
マックアドレス＠ファイアーウォール制御

参考
```sh:SSH: 
uci add firewall rule
uci set firewall.@rule[-1].name="Filter-Parental-Controls"
uci set firewall.@rule[-1].src="lan"
uci set firewall.@rule[-1].src_mac="00:11:22:33:44:55"
uci set firewall.@rule[-1].dest="wan"
uci set firewall.@rule[-1].start_time="21:30:00"
uci set firewall.@rule[-1].stop_time="07:00:00"
uci set firewall.@rule[-1].weekdays="Mon Tue Wed Thu Fri"
uci set firewall.@rule[-1].target="REJECT"
uci commit firewall
/etc/init.d/firewall restart
```
:::

::: note
### [タイムコントロール](https://github.com/4IceG/luci-app-timecontrol)
[パーソナル OpenWrt OPKG サーバー](https://qiita.com/site_u/items/da11f97d2cad53780870#%E3%83%91%E3%83%BC%E3%82%BD%E3%83%8A%E3%83%AB-openwrt-opkg-%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC)
マックアドレス制御
```sh:SSH: 
sed -i 's/option check_signature/# option check_signature/g' /etc/opkg.conf
echo "src/gz custom_generic https://raw.githubusercontent.com/lrdrdn/my-opkg-repo/main/generic" >> /etc/opkg/customfeeds.conf
echo "src/gz custom_arch https://raw.githubusercontent.com/lrdrdn/my-opkg-repo/main/$(grep "OPENWRT_ARCH" /etc/os-release | awk -F '"' '{print $2}')" >> /etc/opkg/customfeeds.conf
opkg update
opkg install luci-app-timecontrol
/etc/init.d/rpcd reload
```
:::

:::note
### [無線スケジュール](https://github.com/newkit/luci-app-wifischedule#wifischedule)
WiFi制御
```sh:SSH: 
opkg update
opkg install wifischedule
opkg install luci-app-wifischedule
opkg install luci-i18n-wifischedule-ja
```
:::

::: note
### [CRON](https://openwrt.org/docs/guide-user/base-system/cron)
WiFi(SSID別)制御
```sh:SSH: 
/etc/init.d/cron enable
# WiFi 5G OFF 00:00
echo "00 00 * * * uci set wireless.default_radio0.disabled=1; uci commit; wifi" >> /etc/crontabs/root
# WiFi 5G ON 08:00
echo "00 08 * * * uci set wireless.default_radio0.disabled=0; uci commit; wifi" >> /etc/crontabs/root
/etc/init.d/cron restart
```
:::

</details>

# あとがき
- AdGuard
自動化スクリプトに暗号化パスワードも入れ込めるんだけど、いかんせんアパッチ入れないとならない
とり諦め・・・ << 解決
容量自動判定はインストールサイズを根拠にしているが、インストール出来るから運用できるのとは違うかと思われ
まあログは取らなきゃいいだけだけど

# 参考資料（感謝:relaxed:）

### [280ブロッカー](https://280blocker.net/)

### [豆腐フィルタ](https://github.com/tofukko/filter#%E8%B1%86%E8%85%90%E3%83%95%E3%82%A3%E3%83%AB%E3%82%BF)

### [OpenWrt で豆腐フィルタを使って広告をブロックする](https://cube309b.hatenablog.com/entry/2023/05/06/005036)
### [OpenWrt 22.03のadblockに豆腐フィルタを適用する](https://zenn.dev/yotan/articles/8f21775eb0c483)