Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to determine IP address of Interface on FreeBSD #202

Closed
diizzyy opened this issue Mar 24, 2023 · 11 comments
Closed

Fails to determine IP address of Interface on FreeBSD #202

diizzyy opened this issue Mar 24, 2023 · 11 comments

Comments

@diizzyy
Copy link
Contributor

diizzyy commented Mar 24, 2023

Not sure if it's configuration issue or not (seems like a bug) but trying to use an interface makes godns fail.

ERRO[0000] Cannot get IP:Get "": unsupported protocol scheme ""
ERRO[0000] get ip online failed. Fallback to get ip from interface if possible.
ERRO[0000] get ip from interface failed. There is no more ways to try.
ERRO[0000] Error during execution:can't get a vaild address from hn0: fail to get current IP

Relevant configuration (json):

...
  ],
  "ip_urls": [""],
  "ip_type": "IPv4",
  "ip_interface": "hn0",
  "interval": 300,
  "debug_info": true,
  "run_once": true
}

Using this code works however (standalone)

https://gist.github.com/schwarzeni/f25031a3123f895ff3785970921e962c

@diizzyy
Copy link
Contributor Author

diizzyy commented May 7, 2023

Still busy or is this something you can look into? @TimothyYe
It appears to be a simple parsing bug

@biship
Copy link

biship commented Sep 7, 2023

Same problem on windows. "ip_interface": "wgpia0",

time="2023-09-07T16:09:24-04:00" level=info msg="Creating DNS handler with provider: DuckDNS"
time="2023-09-07T16:09:24-04:00" level=info msg="GoDNS started, starting the DNS manager..."
time="2023-09-07T16:09:24-04:00" level=error msg="Cannot get IP:Get "": unsupported protocol scheme """
time="2023-09-07T16:09:24-04:00" level=error msg="get ip online failed. Fallback to get ip from interface if possible."
time="2023-09-07T16:09:24-04:00" level=error msg="get ip from interface failed. There is no more ways to try."
time="2023-09-07T16:09:24-04:00" level=error msg="can't get a vaild address from wgpia0"
time="2023-09-07T16:09:24-04:00" level=debug msg="DNS update loop finished, will run again in 300 seconds"

@diizzyy
Copy link
Contributor Author

diizzyy commented Oct 18, 2023

@TimothyYe
Can you possibly have a look at this?

@TimothyYe
Copy link
Owner

@diizzyy Thanks, I'll look into this issue.

@TimothyYe
Copy link
Owner

ERRO[0000] Cannot get IP:Get "": unsupported protocol scheme ""

@diizzyy I've checked the code, this error means GoDNS still tries to get the IP address from the internet.

I think to fix this issue, update your config as:

{
  "ip_type": "IPv4",
  "ip_interface": "hn0",
  "interval": 300,
  "debug_info": true,
  "run_once": true
}

Just remove ip_urls from it.
By the way, I've released a new version to fix this problem and filter the empty URLs in the ip_urls option.

@diizzyy
Copy link
Contributor Author

diizzyy commented Oct 21, 2023

@TimothyYe
Hi, still doesn't work unfortunately

  "ip_type": "IPv4",
  "ip_interface": "hn0",
  "interval": 300,
  "debug_info": true,
  "run_once": true

INFO[0000] GoDNS started, starting the DNS manager...
ERRO[0000] get ip from interface failed. There is no more ways to try.
ERRO[0000] Error during execution:fail to get current IP

Also the syntax is from the manual,
https://github.com/TimothyYe/godns#network-interface-ip-address

@TimothyYe
Copy link
Owner

Could you please help to run the ifconfig command, and paste the output for your network interface hn0 here?
I guess the only difference between GoDNS and the code snippet you mentioned is that GoDNS checks if the IP is private:

https://github.com/TimothyYe/godns/blob/master/pkg/lib/ip_helper.go#L122

@TimothyYe
Copy link
Owner

I use my Oracle cloud to test GoDNS on the FreeBSD system, and the same error shows when the network interface is assigned with a private IP address:

image

For the current implementation, GoDNS will ignore the private IP address while fetching it from the network interface.

@diizzyy
Copy link
Contributor Author

diizzyy commented Oct 22, 2023

Ahh, you're correct! I should've checked the code more carefully but it would be nice if godns where verbose about it especially in debug mode. There seems to be a loop however somewhere in the logic to detect IP?

INFO[0000] Creating DNS handler with provider: Infomaniak
INFO[0000] GoDNS started, starting the DNS manager...
DEBU[0000] get ip success from network intereface by: igb0, IP: NOT PRIVATE
DEBU[0000] get ip success from network intereface by: igb0, IP: NOT PRIVATE
INFO[0002] Update IP success: good NOT PRIVATE
DEBU[0002] Cached IP address: NOT PRIVATE

@TimothyYe
Copy link
Owner

It's not a loop, it only happens when the GoDNS is launched for the first time, the current_ip in the IPHelper is empty, so it tries to fetch the current IP address immediately. In this case, it produces one extra output log:
https://github.com/TimothyYe/godns/blob/master/pkg/lib/ip_helper.go#L71

Another log is produced by the inner goroutine inside the IPHelper:
https://github.com/TimothyYe/godns/blob/master/pkg/lib/ip_helper.go#L60

So you may see two output logs here.

@diizzyy
Copy link
Contributor Author

diizzyy commented Oct 22, 2023

Thanks for clarifying, I guess we can close this now.

@diizzyy diizzyy closed this as completed Oct 22, 2023
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

No branches or pull requests

3 participants