Sunday, January 25, 2004

Installing a Single Port

Thanks to this thread I learned how to install a single port that doesn't appear in the ports tree. For example, GNU netcat just appeared at on 12 Jan. I wanted to install this one port to a FreeBSD 4.9 REL box that hasn't ever updated its port tree, as shown here:

moog# ls -al /usr/ports/INDEX*
-rw-r--r-- 1 root wheel 4003057 Oct 2 16:55 /usr/ports/INDEX
-rw-r--r-- 1 root wheel 4036779 Aug 15 21:56 /usr/ports/INDEX-5

I visited /ports/net/gnetcat and chose the download this directory in tarball option. This copied gnetcat.tar.gz to my system, and I moved it to /usr/local/ports/net. Next I extracted it and ran make and make install:

moog# tar -xzvf gnetcat.tar.gz
moog# cd gnetcat
moog# make && make install
>> netcat-0.7.1.tar.bz2 doesn't seem to exist in /usr/ports/distfiles/.
>> Attempting to fetch from
Receiving netcat-0.7.1.tar.bz2 (325687 bytes): 45%

When done I did a "rehash" and found gnetcat on my system:

moog# rehash
moog# which gnetcat
moog# gnetcat -h
GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere: gnetcat [options] hostname port [port] ...
listen for inbound: gnetcat -l -p port [options] [hostname] [port] ...
tunnel to somewhere: gnetcat -L hostname:port -p port [options]

Mandatory arguments to long options are mandatory for short options too.
-c, --close close connection on EOF from stdin
-e, --exec=PROGRAM program to exec after connect
-g, --gateway=LIST source-routing hop point[s], up to 8
-G, --pointer=NUM source-routing pointer: 4, 8, 12, ...
-h, --help display this help and exit
-i, --interval=SECS delay interval for lines sent, ports scanned
-l, --listen listen mode, for inbound connects
-L, --tunnel=ADDRESS:PORT forward local port to remote address
-n, --dont-resolve numeric-only IP addresses, no DNS
-o, --output=FILE output hexdump traffic to FILE (implies -x)
-p, --local-port=NUM local port number
-r, --randomize randomize local and remote ports
-s, --source=ADDRESS local source address (ip or hostname)
-t, --tcp TCP mode (default)
-T, --telnet answer using TELNET negotiation
-u, --udp UDP mode
-v, --verbose verbose (use twice to be more verbose)
-V, --version output version information and exit
-x, --hexdump hexdump incoming and outgoing traffic
-w, --wait=SECS timeout for connects and final net reads
-z, --zero zero-I/O mode (used for scanning)

Remote port number can also be specified as range. Example: '1-1024'

I plan to test gnetcat to see how it compares to the original nc.