Date created: Tuesday, June 10, 2014 2:16:48 PM. Last modified: Friday, February 9, 2024 2:55:16 PM

Networking Commands

DNS:

DNS on Ubuntu

# Show statistics
sudo systemd-resolve --statistics

# Clear stats
sudo systemd-resolve --flush-caches

$ sudo systemd-resolve --statistics
DNSSEC supported by current servers: no

Transactions
Current Transactions: 0
Total Transactions: 1157

Cache
Current Cache Size: 32
Cache Hits: 417
Cache Misses: 156

DNSSEC Verdicts
Secure: 0
Insecure: 0
Bogus: 0
Indeterminate: 0

$ sudo systemd-resolve --flush-caches

$ sudo systemd-resolve --statistics
DNSSEC supported by current servers: no

Transactions
Current Transactions: 0
Total Transactions: 1157

Cache
Current Cache Size: 0
Cache Hits: 417
Cache Misses: 156

DNSSEC Verdicts
Secure: 0
Insecure: 0
Bogus: 0
Indeterminate: 0

 

Network Statistics:

Show number of connections per IP

netstat -ntu | tail -n +3| awk '{ print $5}' | cut -d : -f 1 | sort | uniq -c| sort -n -r
or
netstat -ntu | awk '{ print $5}' | cut -d : -f 1 | sort | uniq -c| sort -n -r

 

Show all connected IPs

netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq

 

Show number of connections by state

netstat -nat | tail -n +3 | awk '{print $6}' | sort | uniq -c | sort -n
or
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n

Show number of connections

netstat -an | grep ESTABLISHED | wc -l
or
sudo ss -s

 

Show ports and programs associated with the open ports

netstat -A inet -p
netstat -lnpute
sudo ss -utap
sudo ss -utlp

sudo lsof -i -n -P

Filter ports and programs

ss -anp 'dport = :443'
ss -npet 'sport = :22'

Previous page: netplan
Next page: PPPoE Setup