Date created: 06/10/14 14:16:48. Last modified: 08/30/21 09:42:18

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
or
ss -utp

Filter ports and programs

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

Previous page: Linux Network Tuning
Next page: PPPoE Setup