Linux Net

netstat

netstat -a

┌─[]─[~]
└──? $netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0     36 nedrain:ssh             36.62.46.62:45402       ESTABLISHED
tcp        0      0 nedrain:38802           100.100.30.26:http      ESTABLISHED
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*
udp        0      0 nedrain:ntp             0.0.0.0:*
udp        0      0 localhost:ntp           0.0.0.0:*
udp        0      0 0.0.0.0:ntp             0.0.0.0:*
udp        0      0 0.0.0.0:48935           0.0.0.0:*
udp6       0      0 [::]:ntp                [::]:*
udp6       0      0 [::]:fmp                [::]:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    9764     /run/systemd/shutdownd
unix  2      [ ACC ]     STREAM     LISTENING     47257    /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix  2      [ ACC ]     STREAM     LISTENING     9581     /run/systemd/private
unix  2      [ ACC ]     SEQPACKET  LISTENING     9615     /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     11151    /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    6873     /run/systemd/notify
unix  2      [ ]         DGRAM                    6875     /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     6887     /run/systemd/journal/stdout

netstat -an You can find more

┌─[]─[~]
└──? $netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 172.19.4.50:55528       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:34850       122.228.250.253:443     TIME_WAIT
tcp        0      0 172.19.4.50:55524       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:47276       122.228.250.177:443     TIME_WAIT
tcp        0      0 172.19.4.50:55514       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:55504       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:47280       122.228.250.177:443     TIME_WAIT
tcp        0     36 172.19.4.50:22          36.62.46.62:42658       ESTABLISHED
tcp        0      0 172.19.4.50:22          36.62.46.62:45402       ESTABLISHED
tcp        0      0 172.19.4.50:34842       122.228.250.253:443     TIME_WAIT
tcp        0      0 172.19.4.50:55520       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:55506       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:38802       100.100.30.26:80        ESTABLISHED
tcp        0      0 172.19.4.50:55508       122.228.250.176:443     TIME_WAIT
tcp        0      0 172.19.4.50:47290       122.228.250.177:443     TIME_WAIT
tcp        0      0 172.19.4.50:55522       122.228.250.176:443     TIME_WAIT
udp        0      0 0.0.0.0:68              0.0.0.0:*
udp        0      0 172.19.4.50:123         0.0.0.0:*
udp        0      0 127.0.0.1:123           0.0.0.0:*
udp        0      0 0.0.0.0:123             0.0.0.0:*
udp        0      0 0.0.0.0:48935           0.0.0.0:*
udp6       0      0 :::123                  :::*
udp6       0      0 :::4745                 :::*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    9764     /run/systemd/shutdownd
unix  2      [ ACC ]     STREAM     LISTENING     47257    /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix  2      [ ACC ]     STREAM     LISTENING     9581     /run/systemd/private
unix  2      [ ACC ]     SEQPACKET  LISTENING     9615     /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     11151    /var/run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    6873     /run/systemd/notify
unix  2      [ ]         DGRAM                    6875     /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     6887     /run/systemd/journal/stdout
unix  5      [ ]         DGRAM                    6890     /run/systemd/journal/socket
unix  11     [ ]         DGRAM                    6892     /dev/log
unix  3      [ ]         STREAM     CONNECTED     14999
unix  2      [ ]         DGRAM                    12242
unix  3      [ ]         STREAM     CONNECTED     10749
unix  2      [ ]         DGRAM                    51268
unix  2      [ ]         DGRAM                    12998
unix  3      [ ]         STREAM     CONNECTED     10750
unix  2      [ ]         DGRAM                    10740
unix  3      [ ]         STREAM     CONNECTED     13357
unix  3      [ ]         STREAM     CONNECTED     11202
unix  3      [ ]         STREAM     CONNECTED     13358    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11675    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     47255
unix  3      [ ]         STREAM     CONNECTED     13544    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     11214
unix  3      [ ]         STREAM     CONNECTED     10518    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     11674
unix  3      [ ]         STREAM     CONNECTED     10394
unix  3      [ ]         STREAM     CONNECTED     11215
unix  3      [ ]         STREAM     CONNECTED     12629
unix  3      [ ]         STREAM     CONNECTED     11203    /run/systemd/journal/stdout
unix  3      [ ]         DGRAM                    10629
unix  3      [ ]         STREAM     CONNECTED     12630    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    10401
unix  3      [ ]         DGRAM                    10628
unix  3      [ ]         STREAM     CONNECTED     11764
unix  2      [ ]         DGRAM                    51826
unix  3      [ ]         STREAM     CONNECTED     15000    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    14235
unix  3      [ ]         STREAM     CONNECTED     13540
unix  2      [ ]         DGRAM                    11631
unix  3      [ ]         STREAM     CONNECTED     11535
unix  3      [ ]         STREAM     CONNECTED     11536    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     11765    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    11927
unix  2      [ ]         DGRAM                    13601
unix  2      [ ]         DGRAM                    11893
unix  3      [ ]         STREAM     CONNECTED     11958    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     47254
unix  3      [ ]         STREAM     CONNECTED     11957
unix  3      [ ]         STREAM     CONNECTED     47253
unix  3      [ ]         STREAM     CONNECTED     11216    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     11162
unix  3      [ ]         STREAM     CONNECTED     47256
unix  2      [ ]         DGRAM                    11973

and may do something like this : netstat -an | grep ESTABLISHED | wc -l

netstat -tuln

┌─[]─[~]
└──? $netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
udp        0      0 0.0.0.0:68              0.0.0.0:*
udp        0      0 172.19.4.50:123         0.0.0.0:*
udp        0      0 127.0.0.1:123           0.0.0.0:*
udp        0      0 0.0.0.0:123             0.0.0.0:*
udp        0      0 0.0.0.0:48935           0.0.0.0:*
udp6       0      0 :::123                  :::*
udp6       0      0 :::4745                 :::*

相关推荐