verifying if ip address is part of ipv6 network range
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 06:18 AM
Hi Everyone,
I have been trying to check if mentioned ip addres is part of ipv6 network. I could see there is hidden class for
*** Script: constructor
*** Script: isValid
*** Script: isV4
*** Script: isV6
*** Script: isSameVersionAs
*** Script: isLinkLocal
*** Script: isMulticast
*** Script: isRoutable
*** Script: isPublic
*** Script: isReserved
*** Script: isUnicast
*** Script: toExpanded
*** Script: isLocalhost
*** Script: getAddressClass
*** Script: getIP
*** Script: isLinkLocalAddress
*** Script: isMulticastAddress
*** Script: isPrivateAddress
*** Script: isPublicAddress
*** Script: isReservedAddress
*** Script: isUnicastAddress
*** Script: toString
does anybody have any idea how can we check ip is in range of network or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 06:32 AM
you can use isValid function
something like this
var ipAddress = "2001:db8:3333:4444:5555:6666:7777:8888"; // Example IPv6 address
var sncIP = new SNC.IPAddress(ipAddress);
if (sncIP.isValid()) {
gs.info("Valid IPv6 address: " + ipAddress);
} else {
gs.info("Invalid IPv6 address: " + ipAddress);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 06:34 AM
Ankur,
i need if IP is part of IP network or not.
I have already checked above mentioned methods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 06:39 AM
check this docs link
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 06:36 AM - edited 03-26-2025 06:38 AM
you can use this OOB Class as well and use isV6()
Something like this
var ipAddress = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"; // Example of valid IPv6 address
if (SNC.IPAddress.isV6(ipAddress)) {
gs.info("Valid IPv6 address: " + ipAddress);
} else {
gs.info("Invalid IPv6 address: " + ipAddress);
}
var ipAddress1 = "2001:0db8:85a3::8A2E:037j:7334"; // Example of invalid IPv6 address
if (SNC.IPAddress.isV6(ipAddress1)) {
gs.info("Valid IPv6 address: " + ipAddress1);
} else {
gs.info("Invalid IPv6 address: " + ipAddress1);
}
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader