EN
Linux - list all connected tcp clients
2 points
In this article, we're going to have a look at how to print connected tcp
/tcp6
clients and their ip adresses with netstat
command under Bash in Linux.
Type in terminal:
xxxxxxxxxx
1
netstat -tn
Where:
-t
means tcp connections only,-n
show numerical addresses.
Becasue:
netstat -tn
is equivalent tonetstat -t -n
Console print:
xxxxxxxxxx
1
Active Internet connections (w/o servers)
2
Proto Recv-Q Send-Q Local Address Foreign Address State
3
tcp6 0 0 83.145.210.81:80 172.69.134.86:45022 ESTABLISHED
4
tcp6 0 0 83.145.210.81:80 172.69.134.224:50256 TIME_WAIT
5
tcp6 0 0 83.145.210.81:80 172.69.134.230:13386 TIME_WAIT
6
tcp6 0 0 83.145.210.81:80 162.158.167.193:27216 TIME_WAIT
7
tcp6 0 0 83.145.210.81:80 162.158.154.66:17908 ESTABLISHED
8
tcp6 0 0 83.145.210.81:80 141.101.104.246:45062 ESTABLISHED
9
tcp6 0 0 83.145.210.81:80 162.158.88.25:25148 ESTABLISHED
10
tcp6 0 0 83.145.210.81:80 172.68.244.11:48602 ESTABLISHED
11
tcp6 0 463 83.145.210.81:80 162.158.167.7:63428 ESTABLISHED
12
tcp6 0 0 83.145.210.81:80 172.69.134.122:56144 TIME_WAIT
13
tcp6 0 0 83.145.210.81:80 162.158.165.233:17370 TIME_WAIT
14
tcp6 0 0 83.145.210.81:80 172.69.134.224:39788 TIME_WAIT
15
tcp6 0 0 83.145.210.81:80 162.158.166.218:64254 TIME_WAIT
Where:
Foreign Address
- shows ip addresses for connected clients
Note: as we can see in console print, there are connected only
tcp6
clients.
If we would like remove errors we can redirect stderr
(standard error output) to null dev
(place where unnecessary things "vanish") with following command:
xxxxxxxxxx
1
netstat -tn 2>/dev/null
Where:
2>
redirects error output to other place.
If we would like to make print scrollable following command will be useful:
xxxxxxxxxx
1
netstat -tn 2>/dev/null | less
Where:
|
redirects ouput from one program to another one,less
displays results in scrollable form.