LoginSignup
0
1

More than 1 year has passed since last update.

サクッとローカルDNSサーバー

Last updated at Posted at 2023-04-11

概要

自宅内で名前解決がしたい。
hostsはかったるいし、せっかくなのでDNSサーバーを立ててみる。

方針

ぶっちゃけよくわかりません。
今回はUnboundってのを使ってみようと思います。

あとできればdocker使っていきたい。

起動

mvance/unboundなるものを見つけました。

ここからdocker-compose.ymlを拝借。

docker-compose.yml
version: '3'
services:
  unbound:
    container_name: unbound
    image: "mvance/unbound:latest"
    expose:
      - "53"
    networks:
     - dns
    network_mode: bridge
    ports:
      - target: 53
        published: 53
        protocol: tcp
        mode: host
      - target: 53
        published: 53
        protocol: udp
        mode: host
    volumes:
      - type: bind
        read_only: true
        source: ./my_conf/forward-records.conf
        target: /opt/unbound/etc/unbound/forward-records.conf
      - type: bind
        read_only: true
        source: ./my_conf/a-records.conf
        target: /opt/unbound/etc/unbound/a-records.conf
    restart: unless-stopped

networks:
  dns:

volumes:
  mydata:
.
├── docker-compose.yml
└── my_conf
    ├── a-records.conf
    └── forward-records.conf

my_conf内のファイルはまだ空です。

docker-compose up -d

とりあえず起動はできました。

unboundの設定

起動はできたので名前解決のためにa-records.confを編集します。

a-records.conf
# A Record
  local-data: "[つけたい名前] A [ip]"

# PTR Record
  local-data-ptr: "[ip] [つけたい名前]"

んで再起動したら解決できるようになりました。

0
1
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
0
1