{"id":18586005,"url":"https://github.com/cloud66-oss/coredns_mysql","last_synced_at":"2025-08-02T04:32:47.158Z","repository":{"id":38245888,"uuid":"373415077","full_name":"cloud66-oss/coredns_mysql","owner":"cloud66-oss","description":"MySQL backend for CoreDNS","archived":false,"fork":false,"pushed_at":"2023-11-16T19:37:49.000Z","size":24,"stargazers_count":42,"open_issues_count":5,"forks_count":26,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-08T16:02:47.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloud66-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-03T07:12:41.000Z","updated_at":"2025-05-10T02:41:04.000Z","dependencies_parsed_at":"2023-11-16T21:14:52.926Z","dependency_job_id":null,"html_url":"https://github.com/cloud66-oss/coredns_mysql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cloud66-oss/coredns_mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fcoredns_mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fcoredns_mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fcoredns_mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fcoredns_mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloud66-oss","download_url":"https://codeload.github.com/cloud66-oss/coredns_mysql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud66-oss%2Fcoredns_mysql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334611,"owners_count":24233793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T00:36:19.853Z","updated_at":"2025-08-02T04:32:47.128Z","avatar_url":"https://github.com/cloud66-oss.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL\n\nMySQL backend for CoreDNS\n\n## Name\nmysql - MySQL backend for CoreDNS\n\n## Description\n\nThis 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.\n\n## Syntax\n```\nmysql {\n    dsn DSN\n    [table_prefix TABLE_PREFIX]\n    [max_lifetime MAX_LIFETIME]\n    [max_open_connections MAX_OPEN_CONNECTIONS]\n    [max_idle_connections MAX_IDLE_CONNECTIONS]\n    [ttl DEFAULT_TTL]\n    [zone_update_interval ZONE_UPDATE_INTERVAL]\n}\n```\n\n- `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.\n- `table_prefix` Prefix for the MySQL tables. Defaults to `coredns_`.\n- `max_lifetime` Duration (in Golang format) for a SQL connection. Default is 1 minute.\n- `max_open_connections` Maximum number of open connections to the database server. Default is 10.\n- `max_idle_connections` Maximum number of idle connections in the database connection pool. Default is 10.\n- `ttl` Default TTL for records without a specified TTL in seconds. Default is 360 (seconds)\n- `zone_update_interval` Maximum time interval between loading all the zones from the database. Default is 10 minutes.\n\n## Supported Record Types\n\nA, AAAA, CNAME, SOA, TXT, NS, MX, CAA and SRV.  Wildcard records are supported as well.  This backend doesn't support AXFR requests.\n\n## Setup (as an external plugin)\n\nAdd this as an external plugin in `plugin.cfg` file: \n\n```\nmysql:github.com/cloud66-oss/coredns_mysql\n```\n\nthen run\n \n```shell script\n$ go generate\n$ go build\n```\n\nAdd any required modules to CoreDNS code as prompted.\n\n## Database Setup\nThis 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):\n\n```sql\nCREATE TABLE `coredns_records` (\n    `id` INT NOT NULL AUTO_INCREMENT,\n\t`zone` VARCHAR(255) NOT NULL,\n\t`name` VARCHAR(255) NOT NULL,\n\t`ttl` INT DEFAULT NULL,\n\t`content` TEXT,\n\t`record_type` VARCHAR(255) NOT NULL,\n\tPRIMARY KEY (`id`)\n) ENGINE = INNODB AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;\n```\n\n## Record setup\nEach record served by this plugin, should belong to the zone it is allowed to server by CoreDNS. Here are some examples:\n\n```sql\n-- Insert batch #1\nINSERT INTO coredns_records (zone, name, ttl, content, record_type) VALUES\n('example.org.', 'foo', 30, '{\"ip\": \"1.1.1.1\"}', 'A'),\n('example.org.', 'foo', '60', '{\"ip\": \"1.1.1.0\"}', 'A'),\n('example.org.', 'foo', 30, '{\"text\": \"hello\"}', 'TXT'),\n('example.org.', 'foo', 30, '{\"host\" : \"foo.example.org.\",\"priority\" : 10}', 'MX');\n```\n\nThese can be queries using `dig` like this:\n\n```shell script\n$ dig A MX foo.example.org \n```\n\n### Acknowledgements and Credits\nThis plugin, is inspired by https://github.com/wenerme/coredns-pdsql and https://github.com/arvancloud/redis\n\n### Development \nTo develop this plugin further, make sure you can compile CoreDNS locally and get this repo (`go get github.com/cloud66-oss/coredns_mysql`). You can switch the CoreDNS mod file to look for the plugin code locally while you're developing it:\n\nPut `replace github.com/cloud66-oss/coredns_mysql =\u003e LOCAL_PATH_TO_THE_SOURCE_CODE` at the end of the `go.mod` file in CoreDNS code. \n\nPull requests and bug reports are welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud66-oss%2Fcoredns_mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud66-oss%2Fcoredns_mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud66-oss%2Fcoredns_mysql/lists"}