Analiza sieci w Linuksie z netstat
Przejdź do nawigacji
Przejdź do wyszukiwania
netstat pokazuje w Linuksie połączenia sieciowe, tablice tras, statystyki interfejsów, połączenia masquerade i członkostwa multicast. Artykuł ten pokazuje przykłady zastosowania netstat. Obok netstat również iptstate dostępne połączenia sieciowe (ze wskazaniem czasu rzeczywistego).
Przykłady
Połączenia sieciowe
netstat -tapen
nadaje się do wyświetlania obecnie dostępnych połączeń sieciowych. Poszczególne parametry mają następujące znaczenie:
- -t (wyświetla jedynie połączenia TCP, -u tylko połączenia UDP)
- -a (wyświetla wszystkie połączenia)
- -p (pokazuje również PID i nazwę programu do którego należy połączenie)
- -e (wyświetla statystykę sieci Ethernet)
- -n (adresy i numery portów są wyrażane numerycznie i nie zostaną zmienione na nazwy)
[root@tpw ~]# netstat -tapen Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp 0 0 0.0.0.0:5060 0.0.0.0:* LISTEN 500 66008 3260/twinkle tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 5355 1289/rpcbind tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 6668 1589/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 0 5505 1322/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 0 12548 2297/sendmail: acce tcp 0 0 0.0.0.0:33466 0.0.0.0:* LISTEN 0 6486 1532/rpc.statd tcp 0 0 192.168.1.52:59861 192.168.1.254:22 ESTABLISHED 500 100032 3703/ssh tcp 0 0 192.168.1.52:36330 217.188.215.74:443 ESTABLISHED 500 104396 2608/firefox tcp 0 0 192.168.1.52:33252 74.125.79.97:443 ESTABLISHED 500 101832 2608/firefox tcp 0 0 :::111 :::* LISTEN 0 5360 1289/rpcbind tcp 0 0 :::22 :::* LISTEN 0 6670 1589/sshd tcp 0 0 ::1:631 :::* LISTEN 0 5504 1322/cupsd [root@tpw ~]#
Tablica tras
netstat -r
[root@tpw ~]# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 default 192.168.1.254 0.0.0.0 UG 0 0 0 eth0 [root@tpw ~]#
Statystyki interfejsu
netstat -i
[root@tpw ~]# netstat -i Kernel Interface table Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1500 0 26524 0 0 0 22118 0 0 0 BMRU lo 16436 0 34 0 0 0 34 0 0 0 LRU [root@tpw ~]#
netstat -s
[root@tpw ~]# netstat -s Ip: 28144 total packets received 1 with invalid addresses 0 forwarded 0 incoming packets discarded 28069 incoming packets delivered 23144 requests sent out 10 dropped because of missing route Icmp: 12 ICMP messages received 0 input ICMP message failed. ICMP input histogram: destination unreachable: 12 13 ICMP messages sent 0 ICMP messages failed ICMP output histogram: destination unreachable: 13 IcmpMsg: InType3: 12 OutType3: 13 Tcp: 146 active connections openings 0 passive connection openings 4 failed connection attempts 29 connection resets received 2 connections established 16637 segments received 12078 segments send out 67 segments retransmited 0 bad segments received. 59 resets sent Udp: 11421 packets received 0 packets to unknown port received. 0 packet receive errors 10998 packets sent UdpLite: TcpExt: 7 TCP sockets finished time wait in fast timer 543 delayed acks sent Quick ack mode was activated 12 times 6 packets directly queued to recvmsg prequeue. 8 packets directly received from prequeue 13040 packets header predicted 799 acknowledgments not containing data received 1470 predicted acknowledgments 5 times recovered from packet loss due to SACK data 4 congestion windows recovered after partial ack 2 TCP data loss events 3 timeouts after SACK recovery 7 fast retransmits 33 other TCP timeouts 12 DSACKs sent for old packets 2 DSACKs received 10 connections reset due to unexpected data 23 connections reset due to early user close 3 connections aborted due to timeout TCPDSACKIgnoredNoUndo: 1 TCPSackShifted: 71 TCPSackMerged: 35 TCPSackShiftFallback: 10 IpExt: InMcastPkts: 19 OutMcastPkts: 14 InBcastPkts: 54 OutBcastPkts: 51 InOctets: 20989496 OutOctets: 5396900 InMcastOctets: 5540 OutMcastOctets: 3421 InBcastOctets: 6629 OutBcastOctets: 5898 [root@tpw ~]#
Dalsze informacje
- iptstate wyświetla dostępne połączenia sieciowe (ze wskazaniem czasu rzeczywistego).
Powiązane artykuły
Podstawowe informacje o OpenVPN
Software RAID w Linuksie
Wake on LAN pod Linuksem