1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AdGuard HomeをOpenWrtにインストールするまで

Posted at

筆者について

name → Koki Teramoto
age → 18
language → ja_JP, en_US

本編

題名の通りです。AdGuard HomeをOpenWrtにインストールしていきます。今回は公式Wikiを参考にしました。

インストール

コマンドで一発ですね!ここがOpenWrtのいいところ。

opkg update
opkg install adguardhome

インストールが終わったらそのままサービスだけ起動しときます。

service adguardhome enable
service adguardhome start

設定

もう本当に公式Wikiのままでした。とりあえず変数だけ設定しておきましょう。

NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1]; exit }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk '$4 ~ /^fd|^fc/ { split($4, ip_addr, "/"); print ip_addr[1]; exit }')
echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"

次にOpenWrtに内蔵されているDNSをのポートを変更し、不必要な設定を削除します。

# 1. Move dnsmasq to port 54.
# 2. Set local domain to "lan".
# 3. Add local '/lan/' to make sure all queries *.lan are resolved in dnsmasq;
# 4. Add expandhosts '1' to make sure non-expanded hosts are expanded to ".lan";
# 5. Disable dnsmasq cache size as it will only provide PTR/rDNS info, making sure queries are always up to date (even if a device internal IP change after a DHCP lease renew).
# 6. Disable reading /tmp/resolv.conf.d/resolv.conf.auto file (which are your ISP nameservers by default), you don't want to leak any queries to your ISP.
# 7. Delete all forwarding servers from dnsmasq config.
uci set dhcp.@dnsmasq[0].port="54"
uci set dhcp.@dnsmasq[0].domain="lan"
uci set dhcp.@dnsmasq[0].local="/lan/"
uci set dhcp.@dnsmasq[0].expandhosts="1"
uci set dhcp.@dnsmasq[0].cachesize="0"
uci set dhcp.@dnsmasq[0].noresolv="1"
uci -q del dhcp.@dnsmasq[0].server
uci -q del dhcp.lan.dhcp_option
uci -q del dhcp.lan.dns

DNS設定を指定しておく。

uci add_list dhcp.lan.dhcp_option='3,'"${NET_ADDR}"
uci add_list dhcp.lan.dhcp_option='6,'"${NET_ADDR}"

# ここはオプション。正味どっちでもいい。
uci add_list dhcp.lan.dhcp_option='15,'"lan"
uci add_list dhcp.lan.dns="$NET_ADDR6"

uci commit dhcp

最後にリスタートします。

service dnsmasq restart
service odhcpd restart
exit 0

という下記にならないのであればしょうみそのままポート変更さえしておけばあとは放置でもいいと思います。

GUI設定

それでは、http://192.168.1.1:3000/にアクセスしましょう。するとWebで色々設定できると思います。Webのポートは8080に設定しています。また、DNSのポートは53に設定しておいてください。すると設定画面は以下の通りになります。

image.png

DNS設定

フォワード先のDNSを設定する必要があります。僕は以下のサーバーを指定しました。

  • 1.1.1.1
  • 1.0.0.1
  • https://cloudflare-dns.com/dns-query
  • https://dns10.quad9.net:443/dns-query
  • 8.8.8.8
  • 8.8.4.4

またParallel requestsにしています。

最後に

今回はAdGuard Homeを設定してみました。これ本当に速度も速いし広告もブロックしてくれるし設定も簡単だし悪いことありません。少しの手間で終わりますので、皆さんぜひやってみてください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?