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

Definition whether remote IPv6-address is in the same network #208

Open
bob-byte opened this issue Jun 13, 2022 · 0 comments
Open

Definition whether remote IPv6-address is in the same network #208

bob-byte opened this issue Jun 13, 2022 · 0 comments

Comments

@bob-byte
Copy link

bob-byte commented Jun 13, 2022

Is there any way to define whether remote IPv6-address is in the same network? I have connected NetworkInterface object, but I didn't find any way to define this.
I have tried to get first link local IPv6 of interface:

IPAddress ipv6LinkLocalAddress = networkInterface.GetIPProperties().UnicastAddresses.FirstOrDefault( c => c.Address.IsIPv6LinkLocal )?.Address;

IPNetwork ipNetwork = ipv6LinkLocalAddress != null ? IPNetwork.Parse( ipv6LinkLocalAddress, SubnetMask.ClassC ) : null;
isSameNetwork = ( ipNetwork != null ) && ipNetwork.Contains( remoteAddress );

But this returns true, when networks is different

@bob-byte bob-byte changed the title Definition whether remote IP-address is in the same network Definition whether remote IPv6-address is in the same network Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants