惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
Attack and Defense Labs
Attack and Defense Labs
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
N
News and Events Feed by Topic
O
OpenAI News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
AI
AI
L
LINUX DO - 最新话题
S
Securelist
Cisco Talos Blog
Cisco Talos Blog
V
Vulnerabilities – Threatpost
Webroot Blog
Webroot Blog
T
Threatpost
A
Arctic Wolf
罗磊的独立博客
T
Tor Project blog
The Hacker News
The Hacker News
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
Latest news
Latest news
Y
Y Combinator Blog
S
Schneier on Security
T
Troy Hunt's Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
量子位
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
L
Lohrmann on Cybersecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Help Net Security
Help Net Security
腾讯CDC
The Last Watchdog
The Last Watchdog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
Cloudbric
Cloudbric
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
GbyAI
GbyAI
B
Blog
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
S
Secure Thoughts
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell

database on CoreDNS: DNS and Service Discovery

暂无文章

mysql
2021-06-07 · via database on CoreDNS: DNS and Service Discovery

Description

This plugin uses MySQL as a backend to store DNS records. These will then can served by CoreDNS. The backend uses a simple, single table data structure that can be shared by other systems to add and remove records from the DNS server. As there is no state stored in the plugin, the service can be scaled out by spinning multiple instances of CoreDNS backed by the same database.

Syntax

mysql {
    dsn DSN
    [table_prefix TABLE_PREFIX]
    [max_lifetime MAX_LIFETIME]
    [max_open_connections MAX_OPEN_CONNECTIONS]
    [max_idle_connections MAX_IDLE_CONNECTIONS]
    [ttl DEFAULT_TTL]
    [zone_update_interval ZONE_UPDATE_INTERVAL]
}
  • dsn DSN for MySQL as per https://github.com/go-sql-driver/mysql examples. You can use $ENV_NAME format in the DSN, and it will be replaced with the environment variable value.
  • table_prefix Prefix for the MySQL tables. Defaults to coredns_.
  • max_lifetime Duration (in Golang format) for a SQL connection. Default is 1 minute.
  • max_open_connections Maximum number of open connections to the database server. Default is 10.
  • max_idle_connections Maximum number of idle connections in the database connection pool. Default is 10.
  • ttl Default TTL for records without a specified TTL in seconds. Default is 360 (seconds)
  • zone_update_interval Maximum time interval between loading all the zones from the database. Default is 10 minutes.

Supported Record Types

A, AAAA, CNAME, SOA, TXT, NS, MX, CAA and SRV. This backend doesn’t support AXFR requests. It also doesn’t support wildcard records yet.

Setup (as an external plugin)

Add this as an external plugin in plugin.cfg file:

mysql:github.com/cloud66-oss/coredns_mysql

then run

Add any required modules to CoreDNS code as prompted.

Database Setup

This plugin doesn’t create or migrate database schema for its use yet. To create the database and tables, use the following table structure (note the table name prefix):

CREATE TABLE `coredns_records` (
    `id` INT NOT NULL AUTO_INCREMENT,
	`zone` VARCHAR(255) NOT NULL,
	`name` VARCHAR(255) NOT NULL,
	`ttl` INT DEFAULT NULL,
	`content` TEXT,
	`record_type` VARCHAR(255) NOT NULL,
	PRIMARY KEY (`id`)
) ENGINE = INNODB AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;

Record setup

Each record served by this plugin, should belong to the zone it is allowed to server by CoreDNS. Here are some examples:

-- Insert batch #1
INSERT INTO coredns_records (zone, name, ttl, content, record_type) VALUES
('example.org.', 'foo', 30, '{"ip": "1.1.1.1"}', 'A'),
('example.org.', 'foo', '60', '{"ip": "1.1.1.0"}', 'A'),
('example.org.', 'foo', 30, '{"text": "hello"}', 'TXT'),
('example.org.', 'foo', 30, '{"host" : "foo.example.org.","priority" : 10}', 'MX');

These can be queries using dig like this:

$ dig A MX foo.example.org 

Also See

See the manual.