Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@phrawzty
Copy link
Contributor

@phrawzty phrawzty commented Dec 1, 2025

Hello! I figured I'd take a crack at #193 since I had the same observation.

Currently, doggo reads DNS configuration from /etc/resolv.conf on macOS, but this file doesn't reflect the actual DNS settings managed by the SystemConfiguration framework. Modern macOS systems use scutil --dns to expose the real configuration, which can include multiple resolvers for different domains - particularly important when connected to corporate VPNs or using MDM profiles.

I've added a new config_darwin.go that parses the output of scutil --dns instead. This gives doggo access to all the DNS servers configured on the system, including domain-specific resolvers that are common in enterprise environments. The implementation gracefully falls back to reading /etc/resolv.conf if scutil isn't available or fails for any reason.

While working on this, I realized it would be helpful to have a way to specifically query internal/corporate DNS servers. So I've also added a new --strategy=internal option that automatically filters for RFC 1918 private IP addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x) and RFC 4193 IPv6 ULA addresses (fd00::/8). This makes it much easier to investigate name resolution issues when you're connected to a VPN or have corporate DNS profiles installed.

The macOS-specific code lives in config_darwin.go and follows the same pattern as the existing Windows implementation. I updated the Unix config build tag to exclude darwin, so Linux and BSD systems continue using the existing /etc/resolv.conf approach. The internal strategy logic integrates cleanly with the existing strategy system and respects the IPv4/IPv6 filtering flags.

One thing worth noting: the implementation aggregates nameservers from all non-mDNS resolvers, not just resolver #1. This means the --strategy=internal option can discover corporate DNS servers even when they're configured as domain-specific resolvers (e.g. resolver #8 for *.corp.example.com).

This is a purely additive change. The existing strategies (all, random, first) work exactly as before, and explicit nameserver specifications with -n continue to work. The default behavior on macOS now uses scutil instead of /etc/resolv.conf, but returns the same nameservers in practice (resolver #1). Other platforms are completely unaffected.

I've tested this with various network configurations on macOS: standard public DNS, connected to a corporate VPN with internal DNS servers, and with domain-specific resolver profiles. The internal strategy correctly identifies and uses private IP nameservers, and successfully resolves internal corporate domains. The fallback to /etc/resolv.conf works as expected when scutil isn't available.

@mr-karan
Copy link
Owner

mr-karan commented Dec 2, 2025

Looks good! I'll do some more testing on my end and will have this merged. Thanks for the PR :)

Copy link
Owner

@mr-karan mr-karan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Minor changes.

- Remove unused fields from scutilResolver struct
- Remove unused stderr buffer
- Remove redundant filtering in internal strategy
- Return error when --strategy=internal finds no private IP nameservers
@phrawzty
Copy link
Contributor Author

I believe I have addressed the feedback. Thanks for the review! Looking forward to merging this. :)

@mr-karan mr-karan merged commit d1091e3 into mr-karan:main Dec 20, 2025
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Dec 23, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mr-karan/doggo](https://github.com/mr-karan/doggo) | patch | `v1.1.2` → `v1.1.3` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>mr-karan/doggo (mr-karan/doggo)</summary>

### [`v1.1.3`](https://github.com/mr-karan/doggo/releases/tag/v1.1.3)

[Compare Source](mr-karan/doggo@v1.1.2...v1.1.3)

#### Changelog

##### New Features

- [`23fdfe1`](mr-karan/doggo@23fdfe1): feat(web): add SEO meta tags and FAQ page ([@&#8203;mr-karan](https://github.com/mr-karan))
- [`39bae49`](mr-karan/doggo@39bae49): feat: add macOS SystemConfiguration DNS support and internal strategy ([#&#8203;193](mr-karan/doggo#193)) ([@&#8203;phrawzty](https://github.com/phrawzty))

##### Bug fixes

- [`15d6c34`](mr-karan/doggo@15d6c34): fix: restore table text wrapping and respect -4/-6 flags for query types ([@&#8203;mr-karan](https://github.com/mr-karan))

##### Others

- [`46a1de3`](mr-karan/doggo@46a1de3): chore: upgrade go dependencies ([@&#8203;mr-karan](https://github.com/mr-karan))
- [`47136e4`](mr-karan/doggo@47136e4): docs(README): add mise alternative method installation ([@&#8203;jylenhof](https://github.com/jylenhof))
- [`d1091e3`](mr-karan/doggo@d1091e3): refactor: address MR [#&#8203;227](mr-karan/doggo#227) review feedback ([@&#8203;phrawzty](https://github.com/phrawzty))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi42NC4xIiwidXBkYXRlZEluVmVyIjoiNDIuNjQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants