Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

How to kill a TCP connection using tcpkill?

Answer:

You can use the tcpkill program.

tcpkill came with the dsniff in Debian/Ubuntu, you need to install it manually.

# sudo apt-get install dsniff

Usages:

1. Kill all outgoing web (port 80) connection:

# tcpkill -i eth0 port 80

2. Kill all connection by IP

# tcpkill -i eth0 host www.google.com

How to change MAC address

Answer:

To change MAC address, you need to take the network interface

# sudo ifconfig eth1 down

Then change it by

# sudo ifconfig eth1 hw ether 00:01:02:03:04:05

Kill all processes listening on a particular port

Answer:

To kill all processes listening on a particular port, e.g. port 80

# kill -9 $( lsof -i:80 -t )

Replace 80 by the port you want.

Packet sniffing with tcpdump

Answer:

To perform packet sniffing, it is easy with tcpdump

# tcpdump -i eth0 -w dump.cap -s 0

After you terminated the tcpdump, you can use tool such as Wireshark to analyse the dump.cap.

Show the system ARP cache

Answer:

Show the current content of the current ARP table

#  arp

Address                 HWtype  HWaddress           Flags Mask            Iface
192.168.1.5             ether   00:00:0c:07:ac:0c   C                     eth0