{"id":13563475,"url":"https://github.com/jc21/dnsrouter","last_synced_at":"2025-09-01T09:35:17.743Z","repository":{"id":64304364,"uuid":"379620906","full_name":"jc21/dnsrouter","owner":"jc21","description":"Simple DNS daemon to redirect requests based on domain names","archived":false,"fork":false,"pushed_at":"2025-05-30T03:32:56.000Z","size":73,"stargazers_count":53,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T15:47:13.435Z","etag":null,"topics":["daemon","dns","golang","router","split-dns"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jc21.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-23T13:57:23.000Z","updated_at":"2025-06-17T05:02:31.000Z","dependencies_parsed_at":"2024-11-12T06:22:22.185Z","dependency_job_id":"57ead84e-d503-40d5-b478-fddf3ef60a73","html_url":"https://github.com/jc21/dnsrouter","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/jc21/dnsrouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fdnsrouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fdnsrouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fdnsrouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fdnsrouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jc21","download_url":"https://codeload.github.com/jc21/dnsrouter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jc21%2Fdnsrouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273100402,"owners_count":25045697,"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-09-01T02:00:09.058Z","response_time":120,"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":["daemon","dns","golang","router","split-dns"],"created_at":"2024-08-01T13:01:19.679Z","updated_at":"2025-09-01T09:35:17.717Z","avatar_url":"https://github.com/jc21.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# dnsrouter\n\nA simplistic dns daemon that you can use as your local DNS server\nand have it route DNS requests to upstream servers based on the\nrequested domain.\n\nI've created this so that I can effectively set up split DNS\n(sometimes called split horizon DNS) such that my setup will\nproperly forward DNS requests through a VPN connection only when\nthe domain being queried is told to do so.\n\nWhy? Split DNS is apparently supported by common DNS server software but\nmy experience is that it's not implemented in the way I expect. For\nexample `dnsmasq` will send DNS requests to all servers regardless\nof the rules and when an upstream DNS server is dropping connections\nit will hang the whole server.\n\nThis service can also answer with internal DNS entries, avoiding the\nneed for host file modifications.\n\n## Installation\n\nOnly the following methods are available for installation. For all other systems, see Building below.\n\n### MacOS Homebrew\n\nHomebrew won't accept this package until it has higher reputation (stars, forks) so until then\nyou'll have to use the development Formula and rebuild it to install it:\n\n```bash\nexport HOMEBREW_NO_INSTALL_FROM_API=1\nbrew update\nbrew tap --force homebrew/core\ncd $(brew --repo homebrew/core)\ngit remote add jc21 https://github.com/jc21/homebrew-core.git\ngit fetch --all\ngit checkout jc21/dnsrouter\nbrew install --build-from-source dnsrouter\n# and if you need to rebuild:\nbrew reinstall --build-from-source dnsrouter\n\n# Edit config which is located at:\n# /opt/homebrew/etc/dnsrouter/config.json\n\nsudo brew services start dnsrouter\n\n# Switch back to homebrew-core master\ngit checkout master\n```\n\n### RHEL based distros\n\nRPM's are built [here](https://github.com/jc21-rpm/dnsrouter) and hosted [here](https://yum.jc21.com).\n\n```bash\nsudo yum localinstall https://yum.jc21.com/jc21.rpm\nsudo yum install dnsrouter\n\n# Edit config which is located at:\n# /etc/dnsrouter/config.json\n\nsudo systemctl enable dnsrouter --now\n```\n\n## Configuration\n\nThe command is able to write it's default configuration and exit:\n\n```bash\n./dnsrouter -w\n# optionally specify the file to write\n./dnsrouter -w -c /path/to/config.json\n```\n\nThen it's up to you to edit this file to your liking. The default location is `/etc/dnsrouter/config.json`\n\nRefer to the `config.json.example` file for upstream routing examples.\n\n### Examples\n\nGiven the following configuration:\n\n```json\n{\n  \"servers\": [\n    {\n      \"host\": \"127.0.0.1\",\n      \"port\": 53,\n      \"default_upstream\": \"1.1.1.1\",\n      \"internal\": [\n        {\n          \"regex\": \"mail.example.com\",\n          \"A\": \"192.168.0.10\",\n          \"AAAA\": \"2001:db8::1234:5678\",\n          \"TXT\": \"omgyesitworked\",\n          \"MX\": \"10 mailserver1.example.com.\\n20 mailserver2.example.com.\"\n        }\n      ],\n      \"upstreams\": [\n        {\n          \"regex\": \"local\",\n          \"nxdomain\": true\n        },\n        {\n          \"regex\": \".*\\\\.example.com\",\n          \"upstream\": \"8.8.8.8\"\n        },\n        {\n          \"regex\": \".*\\\\.localdomain\",\n          \"upstream\": \"10.0.0.1\"\n        },\n        {\n          \"regex\": \".*\\\\.(office\\\\.lan|myoffice\\\\.com)\",\n          \"upstream\": \"10.0.0.1\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n*Requesting DNS for `test.example.com`*\n\n1. DNS client connects to `dnsrouter` and asks for `test.example.com`\n2. `dnsrouter` matches with the 2nd _upstream_ rule\n3. `dnsrouter` forwards the DNS question to upstream DNS server `8.8.8.8`\n4. `dnsrouter` returns the answer to the DNS client\n\n*Requesting DNS for `google.com`*\n\n1. DNS client connects to `dnsrouter` and asks for `google.com`\n2. `dnsrouter` does not match with any defined rules\n3. `dnsrouter` forwards the DNS question to default upstream DNS server `1.1.1.1`\n4. `dnsrouter` returns the answer to the DNS client\n\n*Requesting DNS for `local`*\n\n1. DNS client connects to `dnsrouter` and asks for `local`\n2. `dnsrouter` matches with the 1st _upstream_ rule\n3. `dnsrouter` returns an error to the client with NXDOMAIN\n\n*Requesting DNS for `myoffice.com`*\n\n1. DNS client connects to `dnsrouter` and asks for `myoffice.com`\n2. `dnsrouter` does not match with any defined rules\n3. `dnsrouter` forwards the DNS question to default upstream DNS server `1.1.1.1`\n4. `dnsrouter` returns the answer to the DNS client\n\n_Note: This is a trick example. The domain matching regex will match `*.myoffice.com` but not `myoffice.com`_\n\n*Requesting DNS for `mail.example.com`*\n\n1. DNS client connects to `dnsrouter` and asks for `mail.example.com`\n2. `dnsrouter` matches with the 1st _internal_ rule\n3. `dnsrouter` returns the answer value to the DNS client with the A/AAAA/MX/TXT record as requested\n\n## Building\n\n```bash\ngit clone https://github.com/jc21/dnsrouter.git\ncd dnsrouter\n./scripts/build.sh\n```\n\nBinary will output to `bin/dnsrouter`\n\n## Running\n\n```bash\n./dnsrouter\n# optionally specify the file to read\n./dnsrouter -c /path/to/config.json\n```\n\nBe aware that running on port `53` will require root permissions on Linux systems.\n\nAfter the service is running you just have to use it. Modify your network interface's DNS\nservers (or /etc/resolv.conf) to use the IP running `dnsrouter` ie `127.0.0.1` if it's\nthe same machine.\n\nYou may choose to run in verbose mode by specifying `-v` this will output each incoming\nDNS request and the determined forwarding DNS server.\n\n### Multiple Servers\n\nThe configuration allows you to run multiple DNS servers on different interfaces and ports\nand have different rules for them.\n\n### Additional Notes\n\n1. Cache, if enabled, won't respect the TTL of the record, but is controlled internally\n2. Regex's are prefixed with `^` and appended with `$` so there is no need to add them\n3. Performance on a desktop used heavily appears to be great. Has not been tested for an entire office.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjc21%2Fdnsrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjc21%2Fdnsrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjc21%2Fdnsrouter/lists"}