{"id":23388226,"url":"https://github.com/exc4/macos-dns-persist","last_synced_at":"2026-05-19T10:04:24.757Z","repository":{"id":268264249,"uuid":"903743126","full_name":"exc4/macos-dns-persist","owner":"exc4","description":"This repository offers a solution to persist DNS settings across all network connections on macOS using a launch service.","archived":false,"fork":false,"pushed_at":"2024-12-18T08:55:34.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-27T03:45:26.051Z","etag":null,"topics":["cloudflared","dns","dnsmasq","macos","stubby"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exc4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-12-15T13:01:12.000Z","updated_at":"2024-12-16T05:16:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"bfdcac94-80f4-4a4a-804d-872ed05cfe22","html_url":"https://github.com/exc4/macos-dns-persist","commit_stats":null,"previous_names":["exc4/macos-dns-persist"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/exc4/macos-dns-persist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exc4%2Fmacos-dns-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exc4%2Fmacos-dns-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exc4%2Fmacos-dns-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exc4%2Fmacos-dns-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exc4","download_url":"https://codeload.github.com/exc4/macos-dns-persist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exc4%2Fmacos-dns-persist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273892841,"owners_count":25186561,"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-06T02:00:13.247Z","response_time":2576,"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":["cloudflared","dns","dnsmasq","macos","stubby"],"created_at":"2024-12-22T02:18:07.226Z","updated_at":"2026-05-19T10:04:24.239Z","avatar_url":"https://github.com/exc4.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# macOS Persist DNS Resolvers\n\nThis repository offers a solution to persist DNS settings across all network connections on macOS using a launch service.\n\nmacOS uses different DNS settings for various network connections, making it challenging to maintain consistent DNS settings when frequently connecting to new networks. However, you may prefer to use specific DNS resolvers across all connections, particularly when employing DNS caching tools like Dnsmasq or utilizing DNS protection services such as Stubby, Cloudflared and other tools.\n\nThis repository helps you set the same DNS resolvers for all network connections and persist these settings by using a launch service. The service executes the settings periodically and upon network changes to ensure the DNS settings remain consistent.\n\n## Files\n\n-  `io.github.exc4.dnspersist.plist`: Launch service configuration file.\n-  `dnspersist.sh`: Shell command script.\n\n## How to Use\n\nTo install the service, run the following commands:\n\n```bash\ngit clone https://github.com/exc4/macos-dns-persist.git\ncd macos-dns-persist\n\n# Set the DNS configuration for persistence.\n# You can specify multiple DNS servers separated by spaces.\necho \"127.0.0.1 ::1\" | sudo tee /etc/dnspersist.conf\n\nsudo ./dnspersist.sh --install\n```\n\nAfter installation, the script applies the DNS settings immediately and continues to persist the setting periodically and whenever the network changes. \n## How to Uninstall\n\n```bash\ndnspersist --uninstall\n```\n\n## How to Configure DNS Persistence\n\nTo set the DNS servers, edit the `/etc/dnspersist.conf` file. \n```bash\n# use local DNS server, ensure there is one running on the system\n# you can choose dnsmasq, stubby, cloudflared and etc.\necho \"127.0.0.1 ::1\" | sudo tee /etc/dnspersist.conf      \n\n# use public DNS servers\necho \"8.8.8.8 8.8.4.4\" | sudo tee /etc/dnspersist.conf  \n\n# use default DNS servers obtained from DHCP\necho \"DEFAULT\" | sudo tee /etc/dnspersist.conf           \n```\nAfter editing the file, run the following command to apply the changes:\n\n```bash\nsudo dnspersist\n```\n\nThe default time interval for the periodic execution is 30 minutes. You can adjust this interval by editing the `/Library/LaunchDaemons/io.github.exc4.dnspersist.plist` file, and changing the `StartInterval` value.\n\nAfter editing the file, run the following command to apply the changes:\n\n```bash\nsudo launchctl unload /Library/LaunchDaemons/io.github.exc4.dnspersist.plist\nsudo launchctl load /Library/LaunchDaemons/io.github.exc4.dnspersist.plist\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Copyright\n\nThis script is inspired by the original script from stubby: [stubby-setdns-macos.sh](https://github.com/getdnsapi/stubby/blob/develop/macos/stubby-setdns-macos.sh).\n\nOriginal Copyright (c) 2017, Sinodun Internet Technologies Ltd, NLnet Labs. All rights reserved.\n\nThe script has been modified to function as a service to persist DNS settings on macOS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexc4%2Fmacos-dns-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexc4%2Fmacos-dns-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexc4%2Fmacos-dns-persist/lists"}