Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm in pure command line here, SunOS 5.8, was wondering if there was a command to kick connections of a specific port #. We could reboot and have it done or reboot the PCs connecting, but thought there was a way to kick connections of a port #.
You could use lsof to determine what process is using the port and try killing that process.
However if its a FIN_WAIT status of some sort there may be no process and it may not go away until a reboot.
I did find a script using ndd that would get rid of FIN_WAIT_2 on HP-UX. Not sure if you can use it on SunOS 5.8. Only Sun I have here 5.6 and it doesn't show the tcp_discon as available.
The script if you want to play with it AT YOUR OWN RISK:
Code:
#
# Taken from Jim Dunn's script.
#
# Doug Burton - 1/23/2004
# http://home.tampabay.rr.com/batcave/
#
# jlightne 02-Jul-2004 - Found on HP ITRC-Modified for bluebird port 1502 issue
#############################################################
# jlightne Modified center line to look only for port 1502 on bluebird's IP:
stuff=$(/usr/bin/printf "%.2x%.2x%.2x%.2x%.4x%.2x%.2x%.2x%.2x%.4x\n" \
$(/usr/bin/netstat -an | /usr/bin/grep 64.102.0.149.1502 | \
/usr/bin/awk '{print $4,$5}' | /usr/bin/sed 's/\./ /g'))
# jlightne This line was center line above as I found it - This would kill ALL
# FIN_WAIT_2 items which might be risky:
# $(/usr/bin/netstat -an -f inet | /usr/bin/grep FIN_WAIT_2 | \
for x in $stuff
do
echo $x
/usr/bin/ndd -set /dev/tcp tcp_discon_by_addr $x
done
I'm confused. If clients are connected on the port how would you free it?
If clients are connected via separate ports then changing port number wouldn't affect them but might affect new connections that expected you to be listening on the original port.
If you run "ndd /dev/tcp \? |grep tcp_discon" do you see anything?
On HP-UX I see:
tcp_discon (write only)
tcp_discon_by_addr (write only)
which is what allows above script to work. By the way in the above I hardcoded port 1502 - you'd want to modify it for the one you wanted if you decided to try it.
The script is AT YOUR OWN RISK but the command in this post doesn't write anything - just checks to see what capabilities you have for /dev/tcp.
Question was how to stop the connections rather than determine what they are. However I heartilly recommend lsof for all Unix/Linux OSes. It has many uses including the one you mention.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.