文档说明:只记录关键地方;
试验环境: linux debian 11
基础软件: etcd+CoreDNS
目标:自建DNS
etcd(存储解析记录) + CoreDNS
| version: "3" |
| services: |
| coredns: |
| image: coredns/coredns:1.9.3 |
| restart: always |
| container_name: coredns |
| ports: |
| - "127.0.0.253:53:53/tcp" |
| - "127.0.0.253:53:53/udp" |
| volumes: |
| - ./Corefile:/Corefile |
| external_links: |
| - etcd |
| command: |
| - "-conf" |
| - "/Corefile" |
| etcd: |
| image: quay.io/coreos/etcd:v3.5.0 |
| ports: |
| - "2379:2379" |
| restart: always |
| container_name: etcd |
| environment: |
| - "ETCD_MAX_WALS=3" |
| volumes: |
| - ./etcd-data:/etcd-data |
| command: |
| - /bin/sh |
| - -c |
| - | |
| /usr/local/bin/etcd \ |
| --name s1 \ |
| --data-dir /etcd-data \ |
| --listen-client-urls http://0.0.0.0:2379 \ |
| --advertise-client-urls http://0.0.0.0:2379 |
| |
| |
| |
Corefile 配置文件
| .:53 { |
| |
| cache 600 |
| debug |
| errors |
| log |
| reload 5s |
| health { |
| lameduck 5s |
| } |
| |
| |
| |
| hosts { |
| |
| |
| |
| |
| 192.168.3.20 bbs |
| 192.168.3.21 china |
| 192.168.3.22 hai_service |
| |
| |
| ttl 60 |
| |
| reload 5s |
| |
| fallthrough |
| } |
| etcd { |
| |
| path /ddns |
| |
| |
| |
| |
| |
| endpoint http://etcd:2379 |
| } |
| |
| } |
| |
启动、关闭、查看日志
| |
| docker-compose -f docker-compose.yaml up -d |
| |
| docker-compose -f docker-compose.yaml down --remove-orphans |
| |
| docker-compose -f docker-compose.yaml logs -f |
etcdctl 设置域名解析
| #!/bin/bash |
| |
| set -exu |
| __CURRENT__=$(pwd) |
| __DIR__=$( |
| cd "$(dirname "$0")" |
| pwd |
| ) |
| cd ${__DIR__} |
| |
| |
| export ETCDCTL_API=3 |
| export ETCDCTL_COMMAND_TIMEOUT=5s |
| |
| endpoints=127.0.0.1:2379 |
| |
| |
| args='endpoint status' |
| |
| args='member list' |
| |
| |
| |
| |
| |
| |
| |
| args='del /ddns/com/jingjingxyk/ddns/service/srv' |
| |
| args='put /ddns/com/jingjingxyk/ddns/service/srv {"host":"192.168.100.20","ttl":60,"priority":10,"port":65535}' |
| |
| |
| |
| args='put /ddns/demo {"host":"fd00::1","ttl":60}' |
| |
| args='put /ddns/demo {"host":"192.168.3.20","ttl":30}' |
| |
| |
| |
| |
| ${__DIR__}/etcd-v3.5.5-linux-amd64/etcdctl --endpoints $endpoints $args |
| |
| |
| dig bbs @127.0.0.253 -p 53 +short |
| dig hai_service @127.0.0.253 -p 53 +short |
| dig demo @127.0.0.253 -p 53 +short |
| |
| dig srv.service.ddns.jingjingxyk.com @127.0.0.253 -p 53 srv +short |
| |
| |
| |
| |
参考文档
- CoreDNS介绍
- CoreDNS ETCD
- etcd security
- etcd release
- etcdctl API
- etcd Libraries and tools
- etcd configuration
- DoH (DNS over HTTPS)
- 基于 TLS 的 DNS(DoT)
- DNS over HTTPS Publicly available servers
- 告别DNS劫持,一文读懂DoH
- 容器5种网络模式 与 K8S pod网络关系
- 自建拉取registry.k8s.io、k8s.gcr.io、gcr.io、quay.io、ghcr.io 容器镜像的服务
- 多播DNS ( mDNS )协议将主机名解析为不包含本地名称服务器的小型网络中的IP地址
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术