- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: netstat output and range of free ports
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 06:47 AM
тАО08-30-2009 06:47 AM
Here's a small programm that i intend to use to find a list of free port:
# more testport
#!/bin/sh
#set -x
no=$1
echo $1
fin=`expr ${no} + 1000`
echo $fin
while test $no -le $fin
do
#echo $no
netstat -an | grep $no
test=`echo $?`
#if [$test =! 1];then
#echo "PORT NUMBER $n PORT NOTFREE"
#fi
no=`expr $no + 1`
done
So , for a range of free ports (required by application) i should not get any o/p.For ports being used it will show o/p:
Active UNIX domain sockets
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
e000000536710080 dgram 0 0 e0000004ac3bdc80 0 0 0 /var/spool/sockets/pwgr/client27200
e0000004e7060080 dgram 0 0 e0000004c420f880 0 0 0 ../wo
1)need help to understand the above netstat o/p better.How can i know what is the port number in above o/p.pardon my meager knowledge.
2)Out of 65000 + ports , i am not able to find a continous range of 1000 ports free , any better program.
lsof is ok but it takes time to scan 1000 ports(after putting that in loop)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 07:16 AM
тАО08-30-2009 07:16 AM
SolutionIt's probably easier to use 'lsof' rather than 'netstat' to snapshot the ports currently in use at any time.
That said, what you see is indeed at that moment and might change in another sample interval.
As for 'netstat' you can see inuse ports in the following snippet:
tcp 0 52 10.xxx.xxx.xxx.22 10.xxx.xxx.xxx.1086 ESTABLISHED
Here, port #22 on the server and port #1086 on the client have formed a connection.
I don't quite understand why you think you need "a continous range of 1000 ports free". Your application (as the server side) should likely need only one.
As background:
http://www.iana.org/assignments/port-numbers
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
All of the above aside, you could also vastly improve the run time of scripts like you posted by _avoiding_ the use of 'expr' to simply increment a counter. You are spawning a separate process very time you do and this is quite expensive!
Instead of:
# no=`expr $no + 1`
do:
# ((no+=+1))
The later lets the shell do the arithmetic and therefore eliminates process creation merely to do so.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 07:40 AM
тАО08-30-2009 07:40 AM
Re: netstat output and range of free ports
Quality Assurance check.
From outside the system.
nmap hostname (best run from a Linux host)
nmap is a port scanner and you may wish to get permission prior to running it.
Show what ports externally are open, though this will only show ports with active listeners, which can be hidden with firewalls.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 09:32 AM
тАО08-30-2009 09:32 AM
Re: netstat output and range of free ports
I want to understand this line in the output of netsta -an :
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
e000000536710080 dgram 0 0 e0000004ac3bdc80 0 0 0 /var/spool/sockets/pwgr/client27200........how can i find the port number, from this line, is it refering to any port , if yes whad is that port .
Regards ,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 09:40 AM
тАО08-30-2009 09:40 AM
Re: netstat output and range of free ports
> I want to understand this line in the output of netsta -an :
Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr
See here:
http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/sockets.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 10:05 AM
тАО08-30-2009 10:05 AM
Re: netstat output and range of free ports
In the o/p above the domain socket address is "e000000536710080" which may be used as an IPC for a service in application(frm the URL that you helped me with ).To my understanding socket = ip + port number.can you please let me know how to break up "e000000536710080" in ip + port number fasion( not sure if my understanding is OK).
Regards ,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 10:36 AM
тАО08-30-2009 10:36 AM
Re: netstat output and range of free ports
These look like kernel virtual addresses. Unless you have a memory dump or use adb(1), you can only treat them as IDs/keys.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 06:13 PM
тАО08-30-2009 06:13 PM
Re: netstat output and range of free ports
UNIX domain sockets are not IP sockets, so
they do not involve IP ports, so they also
do not involve IP port numbers.
> [...] a range of free ports (required by
> application) [...]
Why do you think that this (nameless)
application requires "a range of free ports"?
> [...] i am not able to find a continous
> range of 1000 ports free
Really? And even if that were true, then why
would you care?
> [...] lsof is ok but it takes time to scan
> 1000 ports(after putting that in loop)
Perhaps running lsof (or netstat) 1000 times
is not the best way to solve this problem.
(But I doubt that you really need to solve
it.)
Is there some actual problem which you are
trying to solve? If so, perhaps you should
ask about that problem, rather than asking
about how to implement some sub-ideal method
to solve the wrong problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 09:54 PM
тАО08-30-2009 09:54 PM
Re: netstat output and range of free ports
with the above testport script(from 2000-65000).Also an Excerpt from application installtion
manual ...:"Enter the starting port number from which the tool will start configuring rest of the Finacle Application Services. Make sure that around 1000 port number from the above port are free and that no other application is listening on to this port.".
# ./testport 42000
42000
43000
e000000591297680 dgram 0 0 e0000004fc242700 0 0 0 /var/spool/sockets/pwgr/client5069
e00000046aa00680 dgram 0 0 e0000004ac342800 0 0 0 /var/spool/sockets/pwgr/client1939
e000000428eee380 stream 0 0 e000000428787580 0 0 0 /etc/useracct/utmpd_read
e000000429672980 dgram 0 0 e000000428799100 0 0 0 /dev/log.un
e000000471075680 dgram 0 0 e000000428799e80 0 0 0 /var/spool/sockets/pwgr/client16736
e00000055f1a7080 dgram 0 0 e000000428817b80 0 0 0 /var/spool/sockets/pwgr/client27140
e00000053b61d680 dgram 0 0 e000000429164680 0 0 0 /var/spool/sockets/pwgr/client6303
e000000506a4d380 dgram 0 0 e00000042941e800 0 0 0 /var/spool/sockets/pwgr/client17883
e000000429460080 stream 0 0 0 e00000042b8c7180 0 0
e000000429460380 stream 0 0 0 e00000042b8c7100 0 0
e000000429460680 dgram 0 0 e00000042b86b700 0 0 0 /var/spool/sockets/pwgr/client2198
e000000429460c80 dgram 0 0 e000000468b86880 0 0 0 /var/spool/sockets/pwgr/client2412
e000000429672380 stream 0 0 e00000042b718500 0 0 0 /var/evm/sockets/evmd
e000000429672680 dgram 0 0 e00000042b7b2980 0 0 0 /var/spool/sockets/pwgr/client1530
e000000429672980 dgram 0 0 e000000428799100 0 0 0 /dev/log.un
e000000468de3080 stream 0 0 0 e000000429675300 0 0
e000000468c65400 stream 0 0 0 e000000429675380 0 0
e000000468c65a00 stream 0 0 0 e000000429675280 0 0 /tmp/.s.PGSQL.10864
e000000468c65d00 stream 0 0 0 e000000429675200 0 0 /var/evm/sockets/evmd
since UNIX domain sockets are not IP sockets , so does the output above implies that port from 42000-43000 are free.
since in the output there are no IP socket .Also how will i free this range of scoket , kill the PID ?I cannot see any PIDs
# ps -ef | grep -i "/var/evm/sockets/evmd"
root 5533 8896 0 09:46:32 pts/3 0:00 grep -i /var/evm/sockets/evmd
# ps -ef | grep -i "/var/spool/sockets/pwgr/client2412"
root 5537 8896 0 09:48:43 pts/3 0:00 grep -i /var/spool/sockets/pwgr/client2412
# ps -ef | grep -i "/var/spool/sockets/pwgr/client1530"
root 5539 8896 1 09:48:58 pts/3 0:00 grep -i /var/spool/sockets/pwgr/client1530
Thanks and Regards ,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2009 10:19 PM
тАО08-30-2009 10:19 PM
Re: netstat output and range of free ports
#!/bin/ksh
# Port Scanner with PERL
#
echo From Port
read prt1
echo To Port
read prt2
echo IP
read ip
# Init Log File step
>/tmp/port_check.$ip > /dev/null
while [ $prt1 -lt $prt2 ]
do
echo $ip:$prt1 >> /tmp/port_check.$ip
/aydin/chk_rem_port $ip $prt1 >> /tmp/port_check.$ip
wait
prt1=$(($prt1+1))
done