blob: 993d97e0af80bbacabe547f69b0e30ce97e5aec7 (
plain)
1
2
3
4
5
6
7
8
9
|
#! /bin/bash
query=""
for port in `netstat -lntu | tail -n +3 | grep -v "127.0.0.1" | awk -e '{print $4}' | rev | cut -d ':' -f 1 | rev | sort -n | uniq`; do
[ $port -gt 32768 ] && continue;
[ -z "$query" ] && query="sport = :$port" || query="$query or sport = :$port"
done
eval /sbin/ss -nrtu state established "'( $query ) '" | tail -n +2 | grep -v localhost | awk -F'[:\t ]+' -e '$6 != $4 { print $6, $5 }'
|