OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

netstat

The netstat program is used to examine various network settings and statistics. Through the use of its many options, we can look at a variety of features in our network setup. Using the “-ie” option, we can examine the network interfaces in our system:


[me@linuxbox ~]$ netstat -ie

eth0 Link encap:Ethernet HWaddr 00:1d:09:9b:99:67

inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::21d:9ff:fe9b:9967/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:238488 errors:0 dropped:0 overruns:0 frame:0 TX packets:403217 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100

RX bytes:153098921 (146.0 MB) TX bytes:261035246 (248.9 MB)

Memory:fdfc0000-fdfe0000

[me@linuxbox ~]$ netstat -ie

eth0 Link encap:Ethernet HWaddr 00:1d:09:9b:99:67

inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::21d:9ff:fe9b:9967/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:238488 errors:0 dropped:0 overruns:0 frame:0 TX packets:403217 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100

RX bytes:153098921 (146.0 MB) TX bytes:261035246 (248.9 MB)

Memory:fdfc0000-fdfe0000


lo

Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

lo


inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:2208 errors:0 dropped:0 overruns:0 frame:0 TX packets:2208 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0

RX bytes:111490 (108.8 KB) TX bytes:111490 (108.8 KB)

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:2208 errors:0 dropped:0 overruns:0 frame:0 TX packets:2208 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0

RX bytes:111490 (108.8 KB) TX bytes:111490 (108.8 KB)


image

Using the “-r” option will display the kernel’s network routing table. This shows how the network is configured to send packets from network to network:


image

[me@linuxbox ~]$ 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.1

0.0.0.0

UG

0

0

0

eth0


In this simple example, we see a typical routing table for a client machine on a LAN (Lo- cal Area Network) behind a firewall/router. The first line of the listing shows the destina- tion 192.168.1.0. IP addresses that end in zero refer to networks rather than individ- ual hosts, so this destination means any host on the LAN. The next field, Gateway, is the name or IP address of the gateway (router) used to go from the current host to the des- tination network. An asterisk in this field indicates that no gateway is needed.

The last line contains the destination default. This means any traffic destined for a network that is not otherwise listed in the table. In our example, we see that the gateway is defined as a router with the address of 192.168.1.1, which presumably knows what to do with the destination traffic.

Like ip, the netstat program has many options and we have only looked at a couple. Check out the ip and netstat man pages for a complete list.


Top OS Cloud Computing at OnWorks: