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

AzFileDiagnostics.ps1 fails when dns lookup returns multiple IP addresses #149

Open
a-teece opened this issue Jul 4, 2023 · 1 comment

Comments

@a-teece
Copy link

a-teece commented Jul 4, 2023

It seems that a standard/vanilla configuration of an Azure File Share returns 3 IP addresses. However the script fails with the following error because it tries to connect to a single host which is all 3 addresses (separated by a space), which obviously fails.

[OK]: Storage Account Name enatefiles.file.core.windows.net is resolved to xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz

======Validate port 445 reachability over Storage Account IP xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz

[ERROR]: Connection attempt fails with iteration(0 + 1) of 3 with the error --- No such host is known
[ERROR]: Connectoin Failure with error -2147467259

[ERROR]: Connection attempt fails with iteration(1 + 1) of 3 with the error --- No such host is known
[ERROR]: Connectoin Failure with error -2147467259

[ERROR]: Connection attempt fails with iteration(2 + 1) of 3 with the error --- No such host is known
[ERROR]: Connectoin Failure with error -2147467259

[ERROR]: Last connection exception is:
---No such host is known

[ERROR]: Port 445 is not reachable from this client, Exit the validation and please verify the network

@jcampbellburns
Copy link

jcampbellburns commented Sep 2, 2023

For anyone reviewing AzFileDiagnostics.ps1 as well as anyone else running into this issue, the issue occurs at lines 1808 thru 1811. On 1808, the script performs a lookup which is expected to return multiple addresses and filters out anything where .AddressFamily is not "InterNetwork". The script apparently assumes that this will return a single result and treats it as such without checking.

On 1810 and 1811, $result, which the coder expected to be an array of System.Net.IPAddress with a single element, contains an array of System.Net.IPAddress with more than one element. When calling System.Net.IPAddress[].IPAddressToString (which I cannot find anywhere in .Net documentation, btw), it apparently converts each element into a string and, if there's more than a single element, concatenates them into a single string separated by " ". This is then returned and other code then refers to the whole thing as a connection endpoint. The coder assumes that this would be an ip address but since it doesn't parse as one (due to being multiple addresses separated by a space), the connection endpoint is treated as a dns name and then the dns lookup fails.

The developer of this script works for Azure and should know that an Azure resource may have more than one address.

Workaround:
I was able to run the script by changing both calls to $result.IPAddressToString (on line 1810 and 1811) to $result[0].IPAddressToString to use the first address only. Note: This will disregard any additional addresses which are resolved rather than testing them.

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

2 participants