/bin/netstat imprime información sobre el sistema de red en el host donde se ejecuta. Esto último implica que tenemos que tener cuenta en la máquina que escaneamos si deseamos usar esta utilidad.
Con netstat, dependiendo de los argumentos usados podemos:
# Mostrando las conexiones TCP establecidas
usuario$ ssh usuario@gogh.ace.ual.es usuario$ netstat | grep ESTABLISHED tcp 0 0 192.168.213.133:3841 gogh.ace.ual.es:ssh ESTABLISHED # Mostrando los servicios escuchando a través de puertos TCP usuario$ netstat --listening | grep tcp tcp 0 0 *:sunrpc *:* LISTEN tcp 0 0 *:1488 *:* LISTEN tcp 0 0 *:auth *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 *:nessus *:* LISTEN tcp 0 0 localhost:smtp *:* LISTEN tcp6 0 0 *:www *:* LISTEN tcp6 0 0 *:ssh *:* LISTEN # Mostrando los servicios escuchando a través de puertos UDP usuario$ netstat --listening | grep udp udp 0 0 *:1024 *:* udp 0 0 *:1026 *:* udp 0 0 *:826 *:* udp 0 0 *:bootpc *:* udp 0 0 *:mdns *:* udp 0 0 *:sunrpc *:* udp 0 0 *:ipp *:* udp6 0 0 *:1025 *:* |
# Mostrando la tabla de routing
usuario$ netstat --route Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.213.0 * 255.255.255.0 U 0 0 0 eth0 default 192.168.213.2 0.0.0.0 UG 0 0 0 eth0 |
# Mostrando la información sobre los interfaces de red
usuario$ netstat --interface 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 191678 0 0 0 87617 0 0 0 BMRU lo 16436 0 44677 0 0 0 44677 0 0 0 LRU |
# Mostrando las estadísticas de la red por protocolo
usuario$ netstat --statistics Ip: 236706 total packets received 13 with invalid addresses 0 forwarded 0 incoming packets discarded 236693 incoming packets delivered 132642 requests sent out 3 outgoing packets dropped Icmp: 140 ICMP messages received 1 input ICMP message failed. ICMP input histogram: destination unreachable: 125 echo requests: 3 echo replies: 12 61 ICMP messages sent 0 ICMP messages failed ICMP output histogram: destination unreachable: 58 echo replies: 3 Tcp: 37328 active connections openings 182 passive connection openings 30011 failed connection attempts 50 connection resets received 4 connections established 236131 segments received 131732 segments send out 371 segments retransmited 0 bad segments received. 15052 resets sent Udp: 328 packets received 58 packets to unknown port received. 0 packet receive errors 455 packets sent TcpExt: 207 TCP sockets finished time wait in fast timer 128 time wait sockets recycled by time stamp 268 delayed acks sent 5 delayed acks further delayed because of locked socket Quick ack mode was activated 18 times 5665 packets directly queued to recvmsg prequeue. 33578 of bytes directly received from prequeue 168068 packet headers predicted 41 packets header predicted and directly queued to user 906 acknowledgments not containing data received 7266 predicted acknowledgments 6 congestion windows recovered after partial ack 0 TCP data loss events 334 other TCP timeouts 4 times receiver scheduled too late for direct processing 22 connections reset due to unexpected data 18 connections reset due to early user close 2 connections aborted due to timeout |
# Mostrando las conexiones masquerade. Para que este comando
# muestre información relevante el kernel ha debido ser configurado # con la funcionalidad ip_masquerade. usuario$ netstat --masquerade netstat: no support for ‘ip_masquerade’ on this system. |
# Mostrando los grupos multicast a los que estamos suscritos
usuario$ netstat --groups IPv6/IPv4 Group Memberships Interface RefCnt Group --------------- ------ --------------------- lo 1 ALL-SYSTEMS.MCAST.NET eth0 1 224.0.0.251 eth0 1 ALL-SYSTEMS.MCAST.NET lo 1 ip6-allnodes eth0 1 ff02::1:ff14:bcf6 eth0 1 ip6-allnodes |