TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.5k stars 221 forks source link

Add a way to query IP address through a specific interface #238

Open nagisa opened 6 months ago

nagisa commented 6 months ago

Describe the bug

I have two uplinks in my system: wan0 and wan1. wan1 is wired, but is behind a CGNAT. wan0 is a backup link to a sattelite, but I get a dynamic IP address to use with this link that's not behind a CGNAT. The routes are set up such that by default packets are routed through (the CGNATed) wan1.

I would like godns to query the IP address through wan0 link specifically, so that it obtains the IP address through which the machine is actually reachable.

The frequency of this issue

Steps to Reproduce

Obtain two interfaces with a public internet access. Set up the routes such that they read like this:

$ ip route
default dev wan1 proto static scope link metric 1000 
default dev wan0 proto static scope link metric 1001 
...

Your GoDNS configuration

{
  "ip_url": "https://api.ipify.org/",
  "ip_type": "IPv4",
  "debug_info": true,
  "interval": 3600
}

Expected behavior

It should be possible to ask godns to make a request through wan0 specifically (this can be done by binding the TCP socket I believe) so that the machine making the request is actually reachable over the obtained IP address.

Screenshots

N/A

Environment (please complete the following information):

Additional context
Add any other context about the problem here.

TimothyYe commented 6 months ago

Thanks for your feedback, I think it's possible. Let me figure out the solution.