Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

DNS観察 #12

Open
tatsuru opened this issue Nov 25, 2023 · 9 comments
Open

DNS観察 #12

tatsuru opened this issue Nov 25, 2023 · 9 comments

Comments

@tatsuru
Copy link
Owner

tatsuru commented Nov 25, 2023

No description provided.

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

起動設定

isucon@ip-192-168-0-11:~$ cat /etc/systemd/system/pdns.service.d/isudns.conf 
[Unit]
After=network-online.target mysql.service mysqld.service postgresql.service slapd.service mariadb.service time-sync.target

[Service]
ProtectHome=read-only
ExecStartPost=/opt/init_zone_once.sh
isucon@ip-192-168-0-11:~$ cat /opt/init_zone_once.sh
#!/usr/bin/env bash
set -eux
cd $(dirname $0)
# PowerDNS の起動後に呼ばれ、ゾーンがない場合に初期化を行います

if test -f /home/isucon/env.sh; then
  source /home/isucon/env.sh
fi

ISUCON_SUBDOMAIN_ADDRESS=${ISUCON13_POWERDNS_SUBDOMAIN_ADDRESS:-127.0.0.1}

if !(pdnsutil list-all-zones | grep  u.isucon.dev); then
    pdnsutil create-zone u.isucon.dev
    pdnsutil add-record u.isucon.dev "." A 30 $ISUCON_SUBDOMAIN_ADDRESS
    pdnsutil add-record u.isucon.dev "pipe" A 30 $ISUCON_SUBDOMAIN_ADDRESS
    pdnsutil add-record u.isucon.dev "test001" A 30 $ISUCON_SUBDOMAIN_ADDRESS
fi

exit

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

pdnsのログを見てみると、ランダムっぽい攻撃が見える

Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants '39ympu1atw6es4cevnn7wtc0.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'pipe.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'vut6rgz4o8sxz0.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'pipe.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'bvsmvsnficrhcgoa8fx0.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants '1nbxxk4wthrlv7788gi00.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'ryohei000.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:17 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'pipe.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:20 ip-192-168-0-11 pdns_server[849]: Remote 35.77.6.88 wants 'pipe.u.isucon.dev|A', do = 0, bufsize = 512
Nov 25 04:35:43 ip-192-168-0-11 pdns_server[849]: gmysql Connection successful. Connected to database 'isudns' on '127.0.0.1'.

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

とりあえずDBサーバーを分けるところからかなー

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

zone ファイルを生成して load する方が良さそうな気がした。次にやる

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

launch=bind にするとファイルから読んでくれそうhttps://doc.powerdns.com/authoritative/backends/bind.html

isucon@ip-192-168-0-11:~$ cat /etc/powerdns/pdns.conf 
api=yes
api-key=isudns
webserver=yes
include-dir=/etc/powerdns/pdns.d
launch=gmysql
gmysql-port=3306
gmysql-user=isudns
gmysql-dbname=isudns
gmysql-password=isudns
local-port=53
security-poll-suffix=
setgid=pdns
setuid=pdns
cache-ttl=0
negquery-cache-ttl=0
query-cache-ttl=0
zone-cache-refresh-interval=0
zone-metadata-cache-ttl=0

log-dns-queries=yes
loglevel=7
log-dns-details=yes

@tatsuru
Copy link
Owner Author

tatsuru commented Nov 25, 2023

cache-ttl=0 ちょっとくらいキャッシュしていい気がする

@Gurrium Gurrium mentioned this issue Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant