lsof -P -i -n | cut -f 1 -d " " | uniq
lsof – list open files
-P list port numbers instead of service names
-i list all network files
-n IP addresses instead of host names
cut – cut output
-f specifies fields, separated in the input by the field delimiter character (-d)
-d delimiter
uniq – filters out repeated lines