Operating System - HP-UX
1822007 Members
4115 Online
109639 Solutions
New Discussion юеВ

Re: killing a specific TCP session

 
prakasse
Advisor

killing a specific TCP session

Hi,

Does HP-UX provide a system call (assuming root privilege) that can kill a specific TCP session? We would like to be able to interrupt any TCP connection to the host based on the IP address and TCP port numbers.

Thanks,
Senthil.
8 REPLIES 8
Jeeshan
Honored Contributor

Re: killing a specific TCP session

if that tcp connection belongs to any system processes you can kill it by its PID.
a warrior never quits
Michael Steele_2
Honored Contributor

Re: killing a specific TCP session

Hi Senthil:

Well, you can identify and kill a process associated to the ip address. Is this what you're looking for? For this use netstat.

netstat -an | grep port / ip

You can then use 'ps' command or the 'lsof' command to either examine the process or the open files being used by the process. Then its just 'kill -9 pid'.

Is this what you're looking for?
Support Fatherhood - Stop Family Law
Michael Steele_2
Honored Contributor

Re: killing a specific TCP session

Sorry, I wasn't thinking this through. You'll have to use 'lsof' for this. For example:

# netstat -an | grep 65154
tcp4 0 0 *.65154 *.* LISTEN
# lsof -i tcp:65154
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 430100 was 255u IPv4 0xf100020003cc3390 0t0 TCP *:65154 (LISTEN)

Download from here:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.80/
Support Fatherhood - Stop Family Law
rick jones
Honored Contributor

Re: killing a specific TCP session

Well, there is an ndd command one can use. I am far from certain that the calls it makes into the kernel are documented for external use though.

Is there a specific reason you want to be able to reach-out and terminate a given TCP connection with extreme predjudice?
there is no rest for the wicked yet the virtuous have no pillows
prakasse
Advisor

Re: killing a specific TCP session

we are aware that lsof and netstat will indicate that TCP Connections do exist but, to our knowledge neither provides a way to directly kill a specific TCP connection.

For example, Solaris provides an ioctl (TCP_IOC_ABORT_CONN) command to kill a given TCP connection, given the ip address and port number pairs.
This was allegedly ported from the BSD (OpenBSD, FreeBSD, NetBSD) implementation of tcpdrop. We were wondering if HP UX also has a feature like a system call to terminate a TCP connection.

Thnaks,
Senthil.

Will be soon assigning points to all those who replied.
Aneesh Mohan
Honored Contributor

Re: killing a specific TCP session

Hi Senthil ,

Please check my script below ,

Note:-substitude your ip address with "192.168.053.050"


#!/usr/bin/sh
> /portid
ndd -get /dev/tcp tcp_status |grep -i tcp_established |grep "192.168.053.050" | awk '{print $1}' > /portid
P=`cat /portid |wc -l`
echo $P
if [ $P -gt "0" ]
then
echo "Clearing the port/ports"
for i in `cat /portid`
do
ndd -set /dev/tcp tcp_discon 0x$i
done
else echo "Port is already cleared"
fi


Thanks ,

Aneesh
Ralph Grothe
Honored Contributor

Re: killing a specific TCP session

Hi Aneesh,

do the tcp_discon* tunables require a certain patch to become operational on B.11.11?

e.g.

# ndd -h unsupported|grep tcp_discon
tcp_discon - Terminate a TCP connection
tcp_discon_by_addr - Terminate a TCP connection

# ndd -h supported|grep -c tcp_discon
0

# ndd -h tcp_discon
Unknown tunable parameter: tcp_discon

# ndd -h tcp_discon_by_addr
Unknown tunable parameter: tcp_discon_by_addr

# uname -srv
HP-UX B.11.11 U

Madness, thy name is system administration
Aneesh Mohan
Honored Contributor

Re: killing a specific TCP session

Hi ,

>do the tcp_discon* tunables require a certain patch to become operational on B.11.11?

I couldn`t able to find any patches to make it supported ,but I can able to use tcp_discon on 11.11 :).

Even on 11.31 also tcp_discon shows unsupported

fyi:-

# uname -srv;ndd -h unsupported |grep tcp_discon
HP-UX B.11.31 U
tcp_discon - Terminate a TCP connection
tcp_discon_by_addr - Terminate a TCP connection
#

Thanks,

Aneesh