在 Solaris 上,如何获取与每个 TCP 连接关联的远程 IP 或主机名?
答案1
以下是一种方法:
netstat -a | grep ESTABLISHED |
sed -e 's/\.\([^.]*\) / \1/g' -e 's/ */ /g' |
nawk '
BEGIN {format="%-10s\t%-10s\t%-10s\t%-10s\n";
printf(format,"local_host","local_protocol","remote_host","remote_protocol")}
{printf(format,$1,$2,$3,$4)}'