NAME
cnetstat - a netstat like utility that supports color and searching
SYNOPSIS
cnetstat [-t] [-u] [--drp] [-S <sort>] [-s <states>] [-c <CIDRs>] [-p <ports>] [-P <protocols>] [<-a>] [-l] [-i] [--nc] [<--ptr> <ptrs>] [--rptrs <regexs>] [--Si] [--si] [--ci] [--pi] [--Pi] [--ptri] [--rptri]
FLAGS
-a
Show all connections, including those in the LISTEN state.
-c <CIDRs>
A comma seperated list of CIDRs to search for.
--ci
Invert the CIDR search.
--drp
Don't resolve port numbers to names.
-i
Invert the sort.
-l
Show connections in the LISTEN state. This is the equivalent of '-a -s listen'. If combined with -s, it will display LISTENing sockets and whatever is specified via -s.
--nc
Don't colorize the output. If The NO_COLOR environment variable is set, then it will it will also not be colorized and this flag will be inverted.
-p <ports>
A comma seperated list of ports to search for.
--pi
Invert the port search.
--ptr <ptrs>
A comma seperated list of PTRs to search for.
--ptri
Invert the PTR search.
-P <protocols>
A comma seperated list of protocols to saerch for.
--Pi
Invert the protocol search.
--rptr <regexs>
A comma seperated list of regular expressions to use for matching PTRs.
--rptri
Invert the regex PTR search.
-s <states>
A comma seperated list of states to search for.
--si
Invert the state ssearch.
-S <sort>
The sort method to use. This is one of the supported methods by Parse::Netstat::Sort.
host_f Host, Foreign (default)
host_l Host, Local
port_f Port, Foriegn
port_l Port, Local
state State
protocol Protocol
q_r Queue, Receive
q_s Queue, Send
none No sorting is done.
The ones below are dual sort and take noticably longer than the ones above.
host_ff Host, Foreign First
host_lf Host, Local First
port_ff Port, Foreign First
port_lf Port, Local First
q_rf Queue, Receive First
q_sf Queue, Send First
-t
Don't fetch TCP info.
-u
Don't fetch UDP info.
ENVIRONMENT VARIABLES
CNETSTAT_invert
This is either 0 or 1. If defined it will be used for XORing the -i flag.
export CNETSTAT_invert=1
# run cnetstat inverted
cnetstat
# run it non-inverted, the opposite of what the -i flag normally is
cnetstat -i
CNETSTAT_sort
Sets the default sort method. -S overrides this.
NO_COLOR
If this is set, The output will not be colorized. If this is set, the --nc flag is also inverted.
RES_NAMESERVERS
A space-separated list of nameservers to query used by Net::DNS::Resolver.
There are a few more possible ones, but this is the most useful one and that documentation really belongs to that module.
EXAMPLES
cnestat -s established,time_wait
Return a list of connection that are in the established or time_wait state.
cnestat -c ::/0
Return a list of all IPv6 addresses.
cnestat -c ::1/128,127.0.0.1/32
Return all connections to localhost.
cnestat -c 192.168.15.2/32 -l
Display all connections listening explicitly on 192.168.15.2.
cnetstat -S host_f -i
Sort the connections by the foreign host and invert the results.
cnetstat -c 10.0.0.0/24 --ci
Show connections that are either not locally or remotely part of the 10.0.0.0/24 subnet.
cnetstat --ptr foo.bar
Find connections to/from IPs that have a PTR record of foo.bar.
cnetstat --rptr foo
Find connections to/from IPs that a PTR record that matches the regexp /foo/.
cnetstat --ptr foo.bar --ptri
Find connections to/from IPs that do not have a PTR record of foo.bar.