Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with NETSTAT [Begineer]
#1
Hello good people,
I thought I would talk a bit about netstat. Its quite a helpful tool to manage incoming and out going connections. Connections made can be easily viewed with netstat command.
Here I will discuss the various modes of this command.


Requirements:
Command shell

Checking connections:
This is pretty basic stuff:
netstat [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]
-a Displays all connections and listening ports.
-e Displays Ethernet statistics. This may be combined with the -s option.
-n Displays addresses and port numbers in numerical form.
-p proto Shows connections for the protocol specified by proto; proto may be TCP or UDP. If used with the -s option to display per-protocol statistics, proto may be TCP, UDP, or IP.
-r Displays the routing table.
-s Displays per-protocol statistics.
[Image: netstatw.jpg]

Now when we make a connection, under "foreign addresses" we can see the IP its sending a syn packet to and at which port.

Killing a TCP session:
LINUX
Killing a TCP session is pretty easy in LINUX,
tcpkill -i eth0 { expression }
Example:
(a) Kill all outgoing ftp (port 21) connection:
tcpkill -i eth0 port 21
(b) Kill all all packets arriving at or departing from host 192.168.1.2 (host12.nixcraft.com)
tcpkill host 192.168.1.2


WINDOWS
Well, people tend to use third party programs but this will give you guys an idea of how it works.
Getting process ID
Since every process has an ID, we can achieve the TCP session IP with netstat,
netstat -b | find ":100"
This will show the process id of all the TCP connections taking place with port 100 and its corresponding process ID.
[Image: unledpq.jpg]

Killing the ID
Well, you can do that with taskkill.
taskkill /PID {argument}

Reply


Messages In This Thread
Working with NETSTAT [Begineer] - by Slash - 09-09-2011, 03:08 AM
RE: Working with NETSTAT [Begineer] - by Slash - 09-11-2011, 02:38 AM
RE: Working with NETSTAT [Begineer] - by SaNĘ¹ - 09-12-2011, 10:28 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)