IPMATCH(1)

NAME
ipmatch - a tool for checking if IP address belongs to a subnet

DESCRIPTION
This program checks if given IP address belongs to a particular subnet, or if it is the nework, broadcast or host address. It's default behavior is to output nothing and to set proper return value.

RETURN VALUES
0 - IP was checked as being in range
1 - syntax or usage error
2 - IP was checked as being out of range

SYNOPSIS
ipmatch [-r|-n|-h|-b] ip network/netmask

OPTIONS
  -r, --range          Check if IP address is in given range (default)
  -n, --network        Check if IP address is network address
  -h, --host           Check if IP address is a host address
  -b, --broadcast      Check if IP address is broadcast address

  -t, --text           Print text output (IN/OUT) - default: no output
      --help, --usage  Print this help

  network and netmask can be specified in one of these formats:
    a.b.c.d/prefix   (mask is not specified)
    a.b.c.d prefix
    a.b.c.d/e.f.g.h  (a.b.c.d is IP address, e.f.g.h is netmask)
    a.b.c.d e.f.g.h
    a.b.c.d          (netmask will be determined automatically)

OUTPUT
The program gives no output by default. Only in case -t is given as a paremeter, a simple string IN or OUT is being written.

In case of syntax or usage error, all output is written to stdout.

EXAMPLES
$ ipmatch -t 192.168.1.1 192.168.1.0/24
IN

$ ipmatch -t -n 192.168.1.1 192.168.1.0 255.255.255.0
OUT

$ ipmatch -t -b 192.168.1.15 192.168.1.0/28
IN

$ ipmatch -h 192.168.1.0 192.168.1.0/30 || echo "Not a host address"
Not a host address

$ ipmatch -n 192.168.0.0 192.168.0.0 && echo "A network address"
A network address

$ ipmatch -b 10.255.255.255 10.0.0.0; echo $?
0

$ ipmatch -b 10.255.255.255 10.0.0.0/24; echo $?
2

AUTHOR
Written by C. McCohy <mccohy@kyberdigi.cz>
See http://www.kyberdigi.cz/projects/ipinfo/ for more information.