-h Print usage message.
-t Include a timestamp column.
-c Count connects per src ip and dest ip/port.
-p PID Trace this process ID only (filtered in-kernel).
-P PORT Comma-separated list of destination ports to trace (filtered in-kernel).
-4 Trace IPv4 family only.
-6 Trace IPv6 family only.
-L Include a LPORT column.
-U Include a UID column.
-u UID Trace this UID only (filtered in-kernel).
--cgroupmap MAPPATH Trace cgroups in this BPF map only (filtered in-kernel).
--mntnsmap MAPPATH Trace mount namespaces in this BPF map only (filtered in-kernel).
-d Shows the most recent DNS query for the IP address in the connect call. This is likely related to the TCP connection details in the other columns, but is not guaranteed. This feature works by tracing the udp_recvmsg kernel function and tracking DNS responses received by the server. It only supports UDP DNS packets up to 512 bytes in length. The python code keeps a cache of 10k DNS responses in memory for up 24 hours. If the time difference in milliseconds between when the system received a DNS response and when a connect syscall was traced using an IP in that DNS response is greater than 100ms, this tool will report this delta after the query. These deltas should be relatively short for most applications. A long delay between the response and connect could be either anomalous activity or indicate a misattribution between the DNS name requested and the IP that the connect syscall is using. The -d option may not be used with the count feature (option -c)
Trace all active TCP connections: # tcpconnect
Trace all TCP connects, and include timestamps: # tcpconnect -t
Trace all TCP connects, and include most recent matching DNS query for each connected IP # tcpconnect -d
Trace PID 181 only: # tcpconnect -p 181
Trace ports 80 and 81 only: # tcpconnect -P 80,81
Trace IPv4 family only: # tcpconnect -4
Trace IPv6 family only: # tcpconnect -6
Trace all TCP connects, and include LPORT: # tcpconnect -L
Trace all TCP connects, and include UID: # tcpconnect -U
Trace UID 1000 only: # tcpconnect -u 1000
Count connects per src ip and dest ip/port: # tcpconnect -c
Trace a set of cgroups only (see special_filtering.md from bcc sources for more details): # tcpconnect --cgroupmap /sys/fs/bpf/test01
Trace a set of mount namespaces only (see special_filtering.md from bcc sources for more details): # tcpconnect --mntnsmap /sys/fs/bpf/mnt_ns_set
TIME(s) Time of the call, in seconds.
UID User ID
PID Process ID
COMM Process name
IP IP address family (4 or 6)
SADDR Source IP address.
LPORT Source port
DADDR Destination IP address.
DPORT Destination port
CONNECTS Accumulated active connections since start.
QUERY Shows the most recent DNS query for the IP address in the connect call. This is likely related to the TCP connection details in the other columns, but is not guaranteed.
Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool.