Netstat and networking

Programming, for all ages and all languages.
Post Reply
rich_m

Netstat and networking

Post by rich_m »

Netstat and networking
I am trying to learn IP addressing, networking etc. and would be grateful if anyone could explain this output of the netstat command to me. the command i used was

Code: Select all

netstat -r
The ouput is shown below
Active Routes:

Network Address Netmask Gateway Address Interface Metric
0.0.0.0 0.0.0.0 130.145.187.80 130.145.187.80 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
130.145.187.0 255.255.255.0 130.145.187.80 130.145.187.80 1
130.145.187.80 255.255.255.255 127.0.0.1 127.0.0.1 1
130.145.187.255 255.255.255.255 130.145.187.80 130.145.187.80 1
224.0.0.0 224.0.0.0 130.145.187.80 130.145.187.80 1
255.255.255.255 255.255.255.255 130.145.187.80 130.145.187.80 1
What does this information tell you?
the rest is here this
Route Table

Active Connections

Proto Local Address Foreign Address State
TCP m:1461 web5.webmailer.de:80 ESTABLISHED
TCP m:1462 web5.webmailer.de:80 ESTABLISHED
TCP m:1463 web5.webmailer.de:80 ESTABLISHED
TCP m:1507 web5.webmailer.de:80 ESTABLISHED
TCP m:1516 hotmail.se:80 FIN_WAIT_1
Could you suggest any good sites for understanding these kind of things?
durand
Member
Member
Posts: 193
Joined: Wed Dec 21, 2005 12:00 am
Location: South Africa
Contact:

Re:Netstat and networking

Post by durand »

The first output is the routing table. The routing table defines how IP packets should be moved around. So, if I want to send a packed to IP xxx.xxx.xxx.xxx, then the OS will check the routing table to find out which device it should send the packet over. (modem, network card, adsl, etc)

The netmask is a bit value against which the destination IP is AND'd and the result is compared with the Network Address.

For example: I want to send a packet to a machine with IP 130.145.187.5.

Second line: (130.145.187.5 && 255.0.0.0 ) != 127.0.0.0
Third line: (130.145.187.5 && 255.255.255.0 ) == 130.145.187.0

So, that packet would be routed through the device with IP 130.145.187.80

The first line with 0.0.0.0 and 0.0.0.0 is usually called the default route. Any packets which don't have matches in the routing table will be sent to the default device.

You can also see that IP 130.145.187.80 has a specific route on line four. 130.145.187.80 & 255.255.255.255 == 130.145.187.80. Any packets sent to 130.145.187.80 will be sent to 127.0.0.1 (which is always the local machine as standard. )

If you wanted to set up a home network with two segments - maybe master house and guest cottage - and you wanted to connect both segments with one machine, you could do this:

information:

house: ip range = 192.168.0.0 - 192.168.0.255
with netmask 255.255.255.0
plugged into eth0 (network card 1)
eth0 has address 192.168.0.1

guest: ip range = 10.0.0.0 - 10.0.0.255
with netmask 255.255.255.0
plugged into eth1 (network card 2)
eth1 has address 10.0.0.1


Just set up your routing table as:

Network Address Netmask Gateway

192.168.0.0 255.255.255.0 192.168.0.1
10.0.0.0 255.255.255.0 10.0.0.1

Yup. So this machine will know how to get to the house and the guest quarters. It won't know how to get anywhere else though.

I don't have links for you and I don't explain very well. I'm just bored.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Netstat and networking

Post by Neo »

Just thought i would post this here instead of creating a new thread. but what are the equivalent commands for the Windows "net" (netstat, net send, net view) family of commands etc.
Also what is the equivalen of the 'ipconfig' command on UNIX (HP,Solaris etc) systems?
Only Human
chris

Re:Netstat and networking

Post by chris »

ipconfig on *nix is ifconfig.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Netstat and networking

Post by Neo »

nope that does not work here on Solaris.
I got netstat though. :)
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Netstat and networking

Post by Candy »

Neo wrote: nope that does not work here on Solaris.
I got netstat though. :)
Are you root? if not, then you have to specify the full path, ie, /usr/sbin/ifconfig
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Netstat and networking

Post by Neo »

yeah that works (should have thought of it) Thanks a lot anyway :)
Only Human
Post Reply