#check if Ipv6 is present in the subnet

1 messages · Page 1 of 1 (latest)

fast nova
#

I want to check if the Ipv6 address is present in the subnet.

It will be good if there is a way to check it using some official library otherwise I will have to write the implementation.

I have to do it in Java

olive galeBOT
#

<@&987246399047479336> please have a look, thanks.

heady beacon
#

Hi there

#

I think In java there is a built-in API called InetAddress.getByName()

#

That can help you in this

fast nova
#

I want to validate if the Ipv6 address is present in the prefix

deep marsh
#

string.contains(":");pepekek

#

But realistically, check java.net.Inet6Address

#

When using InetAddress.getByName if it's IPV6 it'll return a Inet6Address if it's IPV6

#

i.e.

boolean isIpv6(String addr) {
  return InetAddress.getByName(addr) instanceof Inet6Address;
}```
#

Or something similar

fast nova
#

I want to determine if the IP address "21ab:1212:43:d45::" is present in "21ab:1212:43::\48"

deep marsh
#

if(str.contains(str2) ?

fast nova
#

no

deep marsh
#

why