
You cannot kill a TCP connection using netstat utility. netstat is use for
- Display network connections
- Routing tables
- Interface statistics
- Masquerade connections
- Multicast memberships
- And much more
However Linux support two other commands or utility that can be used to kill a TCP connection.
tcpkill command
Use tcpkill command to kill specified in-progress TCP connections. It is useful for libnids-based applications which require a full TCP 3-whs for TCB creation.
Syntax:
1 |
tcpkill -i eth0 { expression } |
Examples:
(a) Kill all outgoing ftp (port 21) connection:
1 |
tcpkill -i eth0 port 21 |
(b) Kill all all packets arriving at or departing from host 192.168.1.2 (host12.nixcraft.com)
1 |
tcpkill host 192.168.1.2 |
OR
1 |
tcpkill host host12.nixcraft.com |
(c) To kill all IP packets between 192.168.1.2 and any host except 192.168.1.111, type the following:
1 |
tcpkill ip host 192.168.1.2 and not 192.168.1.111 |