Computer And Technologies

Computer And Technologies: Some Network Linux Commands...

Monday, 10 August 2009

Some Network Linux Commands...

How will you get only TCP protocol status in a network?

Ans:- # netstat -t
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 eOdissa-desktop.l:59156 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:59175 www-sf2p-a.facebook:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:57170 px-in-f83.google.co:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:45271 pv-in-f100.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41356 a96-17-8-64.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:52631 a96-17-8-48.deploy.:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:41932 ord-qs2-n24.panther:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54438 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:54442 px-in-f154.google.c:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56950 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56949 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56948 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:56947 a96-17-69-27.deploy:www ESTABLISHED
tcp 0 0 eOdissa-desktop.l:53859 221x247x49x219.ap:34580 ESTABLISHED

How will you get only UDP protocol status in a network ?
Ans:- # netstat -u
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -u
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State

How will you find only listening socket information?
Ans:- #netstat -l
O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.152.128 * 255.255.255.128 U 0 0 0 tap0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 192.168.152.129 255.255.0.0 UG 0 0 0 tap0
172.16.0.0 192.168.152.129 255.240.0.0 UG 0 0 0 tap0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

How will you get the class of any IP ?
Ans:- ipcals ( install apt-get install ipcalc in debian linux)

O/P:-
root@eOdissa-desktop:/home/amaresh/Documents/Testing# ipcalc 192.168.1.143
Address: 192.168.1.143 11000000.10101000.00000001. 10001111
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
Hosts/Net: 254 Class C, Private Internet

root@eOdissa-desktop:/home/amaresh/Documents/Testing#ipcalc 192.168.0.1 255.255.128.0 255.255.192.0
Address: 192.168.0.1 11000000.10101000.0 0000000.00000001
Netmask: 255.255.128.0 = 17 11111111.11111111.1 0000000.00000000
Wildcard: 0.0.127.255 00000000.00000000.0 1111111.11111111
=>
Network: 192.168.0.0/17 11000000.10101000.0 0000000.00000000
HostMin: 192.168.0.1 11000000.10101000.0 0000000.00000001
HostMax: 192.168.127.254 11000000.10101000.0 1111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.0 1111111.11111111
Hosts/Net: 32766 Class C, Private Internet

Subnets after transition from /17 to /18

Netmask: 255.255.192.0 = 18 11111111.11111111.11 000000.00000000
Wildcard: 0.0.63.255 00000000.00000000.00 111111.11111111

1.
Network: 192.168.0.0/18 11000000.10101000.00 000000.00000000
HostMin: 192.168.0.1 11000000.10101000.00 000000.00000001
HostMax: 192.168.63.254 11000000.10101000.00 111111.11111110
Broadcast: 192.168.63.255 11000000.10101000.00 111111.11111111
Hosts/Net: 16382 Class C, Private Internet

2.
Network: 192.168.64.0/18 11000000.10101000.01 000000.00000000
HostMin: 192.168.64.1 11000000.10101000.01 000000.00000001
HostMax: 192.168.127.254 11000000.10101000.01 111111.11111110
Broadcast: 192.168.127.255 11000000.10101000.01 111111.11111111
Hosts/Net: 16382 Class C, Private Internet


Subnets: 2
Hosts: 32764

How will you monitor your LAN IP?
Ans:- iptraf (use apt-get install iptraf in debian linux)

How will you get your bandwidth usages of your interface by host ?
Ans:- iftop

2 comments:

  1. Hi Amaresh,

    Great going... itz really cool.

    Thanks,
    Maniraj Patri

    ReplyDelete