-
Notifications
You must be signed in to change notification settings - Fork 44
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
Get IP from a specific ethernet interface #713
Comments
The Go standard library does not provide an easy way to specify the interface for the current detection algorithm. 🙃 |
@favonia Hello. I am interested in specifying a custom interface. I have little experience with go, but shouldn't something like this https://gist.github.com/schwarzeni/f25031a3123f895ff3785970921e962c work? I tried it and it looks like it works (I have not tried it on Windows). What I ended up doing is run I came across a python version here https://stackoverflow.com/a/24196955. One can use flask to serve. There is also a node version here https://stackoverflow.com/a/8440736 which can be served with something like express. It is a bit dirty but this should work even with custom commands to get an IP that is not directly related to an interface. |
This is way too complicated... you deserve a much better solution!!! The code you showed will choose the first IP of the specified interface in the expected IP family, while the current |
@tchar Hi, I think more about this and feel the design is a bit unclear to me. So I'd like to just ask you directly: if you specify an interface and it magically has many seemingly valid IP addresses, what do you want the updater to do? |
Hey @favonia indeed it seems like you would have to compromise, although I'm curious how often does something like this is the case. One possible solution is to allow the user to select family (ipv4 vs ipv6) and index (0, 1, ...). Now the family is clear, but the question is: Is it possible for the code to run two consecutive times and give a different order for the IPs? If the answer is no, or unlikely, you could do it like in the following scenario. Say machine has three IPs on interface eth1: Specifying something like local:ipv4:eth1/0 would give 10.0.0.2, and |
@tchar The ipv4/6 would not be needed because provider is set separately for |
@favonia Yes, I am using this, but for ipv4, not ipv6. If you would put the correct number to |
Well I'm only using the public information you provided in the issue. @tchar |
@tchar Alright, I did some more homework, and have some good and bad news.
May I have your confirmation that your address will be some global unicast (public) IPv4 address? (That is, would the most conservative implementation that rejects all "weird" addresses work for you?) Also, may I learn more about your network setup, especially why the current automatic selection fails? If you are not sure whether a particular address is global unicast, you can change the |
@favonia I am not sure what is considered to be a weird address. Unless you mean local and reserved addresses. In my case I am using a VPN tunnel for VLAN. The IPv4 is a valid one, but any service can be accessed only from those in the VPN VLAN network. I hope this makes more sense. |
@tchar Thanks. I have three questions:
|
local
provider
Here is an example of imaginary interfaces to help you understand a bit how the system works.
Let me know if you need any other information. |
@tchar Thank you! Is the (first) IP assigned to |
Yes, there is only one IPv4 under that interface. |
@tchar BTW, the Go code you mentioned earlier (which is based on the code on stackoverflow) is not correct. It's assuming that the Go standard library always returns something of type |
@tchar You may try out
|
@favonia I tested it out, and it works. I only had to put it in host mode instead of bridge. Regarding the syntax, it makes sense, so there is no problem. If I were you, I would prefix the interface with something like You could even have a simple mode ( Alternatively, you could use a keyword that is different from local (like This is up to you; either works and makes sense. |
@tchar Wow, that's a great suggestion! I propose using
This leverages the existing Once we establish
I wonder what you think about these changes? I am making the changes now, but it is easy to adjust the syntax before the release. |
local
provider
@tchar I released 1.15.0 with the syntax |
@favonia That's great. I will pin the version to 1.15.0 so I don't get any surprises for now. Thanks |
@tchar Thanks. It sounds like you don't have any preference between |
@favonia As a user, I find these formats identical in usability. As a dev, it's your project; you should decide which design is best for the project's life. You know it inside out. Both formats are better than local: because they are more verbose. Other than that. I am happy. If I were you, I would probably think about what other use cases the settings can have and see what the "key" would look like.
I feel like 1 (which is your current implementation feels better) |
Closing this as there's nothing to do for now. |
Inspired by TimothyYe/godns#238: maybe there are still cases where manual specification of the interface makes sense.
The text was updated successfully, but these errors were encountered: