NetStat

Introduction

Netstat is a tool that help to determine the active TCP connections on the machine on which the command is enabled and thus list all TCP and UDP ports on your computer.

Commands

Show routing table :
#netstat -rn 
 -r: Linux kernel routing tables.
-n: Display numerical addresses instead of hostnames.

Kernel IP routing table 

Destination
192.168.1.0
0.0.0.0
Gateway
0.0.0.0
192.168.1.1
Genmask
255.255.255.0
0.0.0.0
Flags
U
UG
MSS
0
0
Window
0
0
irtt
0
0
Iface
eth1
eth1

Show quick interface statistics:
#netstat -i
-i: Interface Kernel Interface table

Iface
ath0
eth0
eth1
lo
MTU
1500
1500
1500
16436
Met
0
0
0
0
RX-OK
0
0
1156
225
RX-ERR
250
0
0
0
RX-DRP
0
0
0
0
RX-OVR
0
0
0
0
TX-OK
0
0
568
225
TX-ERR
0
0
0
0
TX-DRP
0
0
0
0
TX-OVR
0
0
0
0
FLG
BMRU
BMU
BMRU
LRU

Parameters of the netstat command.

Used without any arguments, the netstat command displays all connections opened by the machine. The netstat command has a number of optional parameters, the syntax is as follows:

 netstat [-a] [-e] [-n] [-o] [-s] [-p PROTO] [-r] [interval]


Used with the-a argument, the netstat command displays all connections and listening ports on the machine.
Used with the-e argument, the netstat command displays Ethernet statistics.

Used with the-n argument, the netstat command displays the addresses and port numbers in numeric format without name resolution.

Used with the-o argument, the netstat command details the number associated with the connection process.

Used with the-p argument followed by the name of the protocol (TCP, UDP or IP), the netstat command displays the information requested on the specified protocol.

Used with the-r argument, the netstat command displays the routing table.

Used with the-s argument, the netstat command displays detailed statistics by protocol.

Finally, an optional interval determines the refresh information in seconds. The default setting is 1 second.

0 commentaires: