Pages

Thursday, July 19, 2012

Which port is used by a process in AIX?

Today I installed samba and tried to starting it but it refuses to start:

# /etc/inetd/samba start
Starting SMB services
# ps -ef | grep smb
    root 811496 860488   0 14:15:39  pts/0  0:00 grep smb

A look at the log file gave me a hint that port 139 is already in use:

# more /var/log/samba/smb.log
...
[2012/07/19 14:02:00, 0] lib/util.c:smb_panic2(1398)
  PANIC: internal error
[2012/07/19 14:10:37, 0] smbd/server.c:main(791)
  standard input is not a socket, assuming -D option
[2012/07/19 14:10:37, 0] lib/util_sock.c:open_socket_in(691)
  bind failed on port 139 socket_addr = 0.0.0.0.
  Error = The socket name is already in use.
[2012/07/19 14:10:37, 0] lib/fault.c:fault_report(36)
...

Next I looked at all used ports:

# netstat -Aan | grep "139"
f100060003201398 tcp4     0     0     *.139     *.*     LISTEN

The used options for the netstat command are the following:
A: Shows the address associated with the socket
a: Show all sockets
n: Shows network addresses as numbers
With the address I can look which process ID is using port 139:

# rmsock f100060003201398 tcpcb
The socket 0x3201008 is being held by proccess 159934 (inetd).

Normally rmsock is used to remove sockets when they are not in use anymore. When the socket is still in use it will display the process ID. The above output shows that port 139 is used by inetd. To free port 139 I reconfigured inetd.conf first:

# vi /etc/inetd.conf
...
#netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd
#netbios-ns dgram upd wait root /usr/sbin/nmbd nmbd
#swat      stream  tcp     nowait.400      root /usr/sbin/swat swat
...

I commented out the three lines that were associated with smbd, nmbd and swat. Then I reloaded inetd:

# refresh -s inetd
0513-095 The request for subsystem refresh was completed successfully.

Finally I tried to start samba again:

# /etc/inetd/samba start
Starting SMB services

And her I go:

# ps -ef | grep smb
    root 811496 860488   0 14:15:39  pts/0  0:00 grep smb
    root 909696      1   0 14:15:34      -  0:00 /usr/local/samba/sbin/smbd -D -s /etc/samba/smb.conf

Links:
http://www-01.ibm.com/support/docview.wss?uid=swg21264632
http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.cmds%2Fdoc%2Faixcmds4%2Fnetstat.htm
http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.cmds%2Fdoc%2Faixcmds4%2Frmsock.htm

No comments:

Post a Comment