]> gitweb.michael.orlitzky.com - hath.git/blob - doc/man1/hath.1
c0d6bc004f8eb5f552049e75004ef6aa562cce8b
[hath.git] / doc / man1 / hath.1
1 .TH hath 1
2
3 .SH NAME
4 hath \- Manipulate network blocks in CIDR notation
5 .SH SYNOPSIS
6
7 \fBhath\fR [\fBregexed|reduced|duped|diffed\fR] [\fB\-h\fR] [\fB-i \fIFILE\fR] \fI<input>\fR
8 .SH INPUT
9 .P
10 The \fIinput\fR (default: stdin) should be a list of CIDR blocks,
11 separated by whitespace. Empty lines will be ignored, but otherwise,
12 malformed entries will cause an error to be displayed.
13 .SH DESCRIPTION
14 .P
15 Hath is a Haskell program for working with network blocks in CIDR
16 notation. When dealing with blocks of network addresses, there are a
17 few things that one usually wants to do with them:
18 .IP \(bu 2
19 Create a regular expression matching the CIDR block(s). This is
20 because grep will throw up if you feed it CIDR.
21 .IP \(bu
22 Combine small blocks into larger ones. For example, if you have two
23 consecutive /24s, they might combine into a larger /23.
24 .IP \(bu
25 View the result of block combination in a useful way.
26 .IP \(bu
27 List them.
28 .IP \(bu
29 Find their associated PTR records.
30 .P
31 Hath does just that. It takes as its input (via stdin, or a file with
32 the -i parameter) a list of CIDR blocks.
33 .SH MODES
34 .P
35 Hath has several modes:
36 .IP \(bu 2
37 \fBRegexed\fR
38 .P
39 This computes a (Perl-compatible) regular expression matching
40 the input CIDR blocks. It's the default mode of operation.
41 .P
42 .nf
43 .I $ hath <<< \(dq10.0.0.0/29 10.0.0.8/29\(dq
44 ((10)\.(0)\.(0)\.(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15))
45 .fi
46 .IP \(bu 2
47 \fBReduced\fR
48 .P
49 This combines small blocks into larger ones where possible, and
50 eliminates redundant blocks. The output should be equivalent to
51 the input, though.
52 .P
53 .nf
54 .I $ hath reduced <<< \(dq10.0.0.0/24 10.0.1.0/24\(dq
55 10.0.0.0/23
56 .fi
57 .IP \(bu 2
58 \fBDuped\fR
59 .P
60 Shows only the blocks that would be removed by reduce; that is, it
61 shows the ones that would get combined into larger blocks or are
62 simply redundant.
63 .P
64 .nf
65 .I $ hath duped <<< \(dq10.0.0.0/24 10.0.1.0/24\(dq
66 10.0.0.0/24
67 10.0.1.0/24
68 .fi
69 .IP \(bu 2
70 \fBDiffed\fR
71 .P
72 Shows what would change if you used reduce. Uses diff-like
73 notation.
74 .P
75 .nf
76 .I $ hath diffed <<< \(dq10.0.0.0/24 10.0.1.0/24\(dq
77 -10.0.0.0/24
78 -10.0.1.0/24
79 +10.0.0.0/23
80 .fi
81 .IP \(bu 2
82 \fBListed\fR
83 .P
84 List the IP addresses contained within the given CIDRs.
85 .P
86 .nf
87 .I $ hath listed <<< \(dq192.168.0.240/29\(dq
88 192.168.0.240
89 192.168.0.241
90 192.168.0.242
91 192.168.0.243
92 192.168.0.244
93 192.168.0.245
94 192.168.0.246
95 192.168.0.247
96 .fi
97 .IP \(bu 2
98 \fBReversed\fR
99 .P
100 Perform reverse DNS (PTR) lookups on the IP addresses contained within
101 the given CIDRs.
102 .P
103 .nf
104 .I $ hath reversed <<< \(dq198.41.0.4/30\(dq
105 198.41.0.4: a.root-servers.net.
106 198.41.0.5:
107 198.41.0.6: rs.internic.net.
108 198.41.0.7:
109 .fi
110 .P
111 The DNS lookups are usually the bottleneck for this mode, but we can
112 perform them in parallel. Simply pass the number of threads to the GHC
113 runtime on the command line; for example, the following will perform
114 25 lookups in parallel:
115 .P
116 .nf
117 .I $ hath reversed +RTS -N25 <<< \(dq198.41.0.4/24\(dq
118 198.41.0.4: a.root-servers.net.
119 198.41.0.5:
120 198.41.0.6: rs.internic.net.
121 \(pc\(pc\(pc
122 .fi
123 .P
124 Each of the modes also supports a present-tense flavor; the following
125 are equivalent to their counterparts: \fBregex\fR, \fBreduce\fR,
126 \fBdupe\fR, \fBdiff\fR, \fBlist\fR, \fBreverse\fR.
127
128 .SH OPTIONS
129
130 .IP \fB\-\-input\fR,\ \fB\-i\fR
131 Specify the input file containing a list of CIDRs, rather than using
132 stdin (the default).