TCP/IP Primer, Part III - IP Addresses and KiXtart

KiXtart has the ability to return the IP addresses of a computer with the IPADDRESSx macro. The subnet mask of a specific adapter can be retrieved from either ENUMIPINFO(), the registry, through WMI, or using command-line utilities like IPCONFIG.
Recommended Freeware Subnet Calculator
Advanced IP Address Calculator for FamaTech, downloadable at

UDFs involving IP addresses
The following UDFs handle IP address functions:

BinaryIP is a UDF that converts the octet version of an IP address (e.g. into it's equivalent binary format (e.g. 11000000101010000000000100000011). This IP address can be a network ID, host ID, or subnet mask, as long as it is four octets.

Subnet and IsInSubnet both check whether a given IP address is part of a subnet as defined by it's network ID and subnet mask.

IsInIPRange is a slightly expanded version of Subnet and IsInSubnet since it accepts an array of subnets (NetworkID/SubnetMask). It will check whether a given IP address is part of any of the provided subnets. Example code would look like this:

$retcode = isiniprange($ipaddress,$iparray)

In the example above the IP address is being evaluated whether it is part of either the network or network Please note that IsInIPRange accepts both the CIDR format /24 as well as the more traditional octet format as subnet masks.

IPMask and CalcLogicalSubnet perform a binary AND of two binary IP addresses, it could for example be used to calculate the network ID based on Host ID and Subnet mask since (HostID AND SubnetMask) = NetworkID.

GetIPinfo will retrieve a computers IP address, subnet mask, and default gateway.

Potential usesThe main use of the above mentioned UDFs would be to check whether an IP address is part of a subnet or a particular range of IP addresses as defined by it's network ID and subnet mask or other appropriate combinations.
For example, only certain computers are to connect to a specific drive share based on their IP address. One could then create an array of permitted IP addresses or address ranges and do the following:

if isiniprange($ipaddress,$iparray)
use X: '\\server\share'

This would allow IP addresses in the ranges,, and to connect drive letter X: to share \\server\share.

TCP/IP Primer, Part III - IP Addresses and KiXtart

Edited by sealeopard (2004-03-11 03:46 PM)
There are two types of vessels, submarines and targets.