512mbのVPSの限界に挑戦し、広告を破壊する。

当ブログはアフィリエイト広告を利用し商品を紹介しています。

サブスク代高いなあと思ったので、VPSでいろいろ代用したメモ。ついでに512mbでこんなにできるのかとびっくりしたのでメモ。

現状うちの子で動いてるもの

1.tailscale(vpn)
2.pihole、unbound(ネットサーフィンの広告破壊)
3.invidious(youtubeの広告を破壊、youtube premiumの代用)
4.tinytinyRSS(情報収集)
5.このwordpress
6.dolphin(おひとり様向けmisskey)

1.下ごしらえ

1.VPSを借りる。今回はとにかくケチりたかったのと、VPNとしても使いたかったので通信量に制限のないConohaの1コア512mbのものを使用。どうせ使うかと36か月を契約。

【1.3円/時間】GMOインターネットのSSD「ConoHa VPS」

2.Google、Githubあたりのアカウントを作っておく。

3.暇な時間を作る。だいたいコピペで済むようにするので1時間はかからないと思う。

2.tailscaleの導入

OS:Debian12.0
他デフォルト

sshもしくはコンソールからコマンドを打つ。コピペ出来るからsshの方が早い

sudo apt update
sudo apt upgrade
curl -fsSL https://tailscale.com/install.sh | sh #tailscaleインストールコマンド

↑おまじないとtailscaleの導入

tailscaleの導入はググれば出るが、最後にリンクが出る。これをGoogleかGithubで認証する。

3.piholeの導入

これがメイン。これもスクリプトがある

curl -sSL https://install.pi-hole.net | bash #piholeをインスト―ル

我がvpsではunboundも導入している。効果は謎だが早くなったような気がする。
細かな調整は後日述べる。

sudo apt install -y unbound

/etc/unbound/unbound.conf.d/pi-hole.conf を書き換える。
ここからさらに微調整をしたが、とりあえずこれで良い。

server:
    # If no logfile is specified, syslog is used
    # logfile: "/var/log/unbound/unbound.log"
    verbosity: 0

    interface: 127.0.0.1
    port: 5335
    do-ip4: yes
    do-udp: yes
    do-tcp: yes

    # May be set to yes if you have IPv6 connectivity
    do-ip6: no

    # You want to leave this to no unless you have *native* IPv6. With 6to4 and
    # Terredo tunnels your web browser should favor IPv4 for the same reasons
    prefer-ip6: no

    # Use this only when you downloaded the list of primary root servers!
    # If you use the default dns-root-data package, unbound will find it automatically
    #root-hints: "/var/lib/unbound/root.hints"

    # Trust glue only if it is within the server's authority
    harden-glue: yes

    # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS
    harden-dnssec-stripped: yes

    # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes
    # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
    use-caps-for-id: no

    # Reduce EDNS reassembly buffer size.
    # IP fragmentation is unreliable on the Internet today, and can cause
    # transmission failures when large DNS messages are sent via UDP. Even
    # when fragmentation does work, it may not be secure; it is theoretically
    # possible to spoof parts of a fragmented DNS message, without easy
    # detection at the receiving end. Recently, there was an excellent study
    # >>> Defragmenting DNS - Determining the optimal maximum UDP response size for DNS <<<
    # by Axel Koolhaas, and Tjeerd Slokker (https://indico.dns-oarc.net/event/36/contributions/776/)
    # in collaboration with NLnet Labs explored DNS using real world data from the
    # the RIPE Atlas probes and the researchers suggested different values for
    # IPv4 and IPv6 and in different scenarios. They advise that servers should
    # be configured to limit DNS messages sent over UDP to a size that will not
    # trigger fragmentation on typical network links. DNS servers can switch
    # from UDP to TCP when a DNS response is too big to fit in this limited
    # buffer size. This value has also been suggested in DNS Flag Day 2020.
    edns-buffer-size: 1232

    # Perform prefetching of close to expired message cache entries
    # This only applies to domains that have been frequently queried
    prefetch: yes

    # One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1.
    num-threads: 1

    # Ensure kernel buffer is large enough to not lose messages in traffic spikes
    so-rcvbuf: 1m

    # Ensure privacy of local IP ranges
    private-address: 192.168.0.0/16
    private-address: 169.254.0.0/16
    private-address: 172.16.0.0/12
    private-address: 10.0.0.0/8
    private-address: fd00::/8
    private-address: fe80::/10

そろそろ長いので次回に続く…

ps:途中までで飽きて辞めた人もポートは忘れずに閉めておくように

次→

研究室の一角 - にほんブログ村

Licensed under CC BY-NC-SA 4.0
最終更新 Aug 11, 2023 13:26 UTC
comments powered by Disqus
Hugo で構築されています。
テーマ StackJimmy によって設計されています。