Changing Bind Addresses and Ports for Samba and FTP

From alfrescowiki

Jump to: navigation, search

This is a report of my own experiments to obviate BindExceptions. Having installed Alfresco on my Linux box, I was not really surprised to receive several java.net.BindException: Address already in use exceptions, as both Alfresco and my smbd/nmbd and ftp server were trying to bind to the same ports with the 'wildcard' IP address (0.0.0.0).

To allow co-existence, I decided to firstly, switch off the Alfresco netBIOSSMB service in favour of the Linux nmbd. The method is described on other forum posts, all that is required is to edit WEB-INF/classes/alfresco/file-servers.xml (within alfresco.war) and force tcpipSMB: Locate the following lines:

<tcpipSMB platforms="linux,solaris,macosx"/>
<netBIOSSMB platforms="linux,solaris,macosx"/>

and remove linux from the netBIOSSMB entry:

<tcpipSMB platforms="linux,solaris,macosx"/>
<netBIOSSMB platforms="solaris,macosx"/>

for the CIFS/smbd conflict, I decided to create an extra IP address just for Alfresco, and change the 'wildcard' IP bind address to a specific single address. My original network interface was configured thus:

# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:50:8D:F3:B4:71
inet addr:192.168.129.2 Bcast:192.168.129.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[snip]

I added an extra IP address thus:

# ifconfig eth0:0 192.168.129.63
result:
# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:50:8D:F3:B4:71
inet addr:192.168.129.63 Bcast:192.168.129.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[snip]

To force the smb daemon to listen on the correct address rather than wildcarding, I edited /etc/samba/smb.conf, and in the '[global]' section added:

Allow several Samba servers on different subnet without conflicts
socket address = 192.168.129.2
interfaces = 192.168.129.0/255.255.255.0
bind interfaces only = yes

consistent with my original eth0 ifconfig.

The similar task for the Alfresco CIFS server is accomplished by more editing of WEB-INF/classes/alfresco/file-servers.xml It is just a case of adding 'bindto' attributes in the correct spots and narrowing the broadcast address (necessary?) For the CIFS Server, I changed the broadcast address to that of my LAN and added a bindto attribute below:

<!-- Set to the broadcast mask for the subnet -->
<broadcast>192.168.129.255</broadcast>
<bindto>192.168.129.63</bindto>

and added a simlar line for the Alfresco FTP Server:

<config evaluator="string-compare" condition="FTP Server">
<!-- <debug flags="File,Search,Error,Directory,Info,DataPort"/> -->
<bindto>192.168.129.63</bindto>
</config>

The last task was to add a line to the /etc/hosts file in this and interested client machines, mapping the CIFS server name to its IP address:

192.168.129.63 brunel_a

Having then shutdown and restarted smb/nmb/alfresco, I was free of bind exceptions and my netstat output looked like this:

# netstat -lnp | egrep 'java|mb' | tr -s ' '
prot s r localAddress remoteAddress state PID/Program
tcp 0 0 192.168.129.2:139 0.0.0.0:* LISTEN 19409/smbd
tcp 0 0 192.168.129.63:21 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.2:7001 0.0.0.0:* LISTEN 23187/java
tcp 0 0 127.0.0.1:7001 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.63:445 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.2:445 0.0.0.0:* LISTEN 19409/smbd
udp 0 0 192.168.129.2:137 0.0.0.0:* 19414/nmbd
udp 0 0 192.168.129.2:137 0.0.0.0:* 19414/nmbd
udp 0 0 192.168.129.2:138 0.0.0.0:* 19414/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 19414/nmbd

7001 is my appserver's HTTP port. The nearest equivalent command on MS Windows (or Unix) would be netstat -an.

Share browsing is now a bit iffy, I'm not sure why, but mounting/mapping of the network drives as \\brunel_a\Alfresco etc seems to work OK.

HTH

Regards

Eric Lee


Hi! We used Eric's article to bind different ethernet interfaces to Alfresco CIFS and native Linux samba and it didn't work! My friend (Tatjana K.) and I (Boris B.) did everything like Eric said(bring up additonal eth inteface,bind Alfresco CIFS to one interface, bind Linux SMB to another interface) but that didn't work. Linux distribution we use is openSuse11.1 and Alfresco Community release 3.2. Problem was that if you start Linux SMB first it realy bind to specific interface we assing it to in /etc/samba/smb.conf but when we start Alfresco, it don't bind it to specific interface and Alfresco CIFS don't work.

linux:/ # netstat -lnp |egrep 'java|mb' | tr -s ' '
tcp 0 0 10.0.14.216:139 0.0.0.0:* LISTEN 2936/smbd
tcp 0 0 10.0.14.216:445 0.0.0.0:* LISTEN 2936/smbd
tcp 0 0 :::50753 :::* LISTEN 8655/java
tcp 0 0 :::50500 :::* LISTEN 8655/java
tcp 0 0 127.0.0.1:8005 :::* LISTEN 8655/java
tcp 0 0 :::50501 :::* LISTEN 8655/java
tcp 0 0 :::50502 :::* LISTEN 8655/java
tcp 0 0 :::50503 :::* LISTEN 8655/java
tcp 0 0 :::50504 :::* LISTEN 8655/java
tcp 0 0 :::50505 :::* LISTEN 8655/java
tcp 0 0 :::50506 :::* LISTEN 8655/java
tcp 0 0 :::50507 :::* LISTEN 8655/java
tcp 0 0 :::33932 :::* LISTEN 8655/java
tcp 0 0 :::21 :::* LISTEN 8655/java
udp 0 0 :::48786 :::* 8655/java

In this case Linux SMB works and Alfresco CIFS don't.

If you start Alfresco first and Linux SMB second,then you have this situation

linux:/ # netstat -lnp |egrep 'java|mb' | tr -s ' '
tcp 0 0 :::50753 :::* LISTEN 8655/java
tcp 0 0 :::50500 :::* LISTEN 8655/java
tcp 0 0 127.0.0.1:8005 :::* LISTEN 8655/java
tcp 0 0 :::50501 :::* LISTEN 8655/java
tcp 0 0 :::50502 :::* LISTEN 8655/java
tcp 0 0 :::50503 :::* LISTEN 8655/java
tcp 0 0 :::50504 :::* LISTEN 8655/java
tcp 0 0 :::50505 :::* LISTEN 8655/java
tcp 0 0 :::50506 :::* LISTEN 8655/java
tcp 0 0 :::50507 :::* LISTEN 8655/java
tcp 0 0 :::33932 :::* LISTEN 8655/java
tcp 0 0 :::21 :::* LISTEN 8655/java
tcp 0 0 :::445 :::* LISTEN 8655/java
udp 0 0 :::137 :::* 8655/java
udp 0 0 :::48786 :::* 8655/java

In this case Alfresco CIFS works an Linux SMB don't.


It turns out that you don't have to change file-servers.properties in location /opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco.

Tip:in file file-servers.properties you can modified variables used in file-servers.xml. It's much more user friendly to change variables in file-servers.properties then in file-servers.xml.

linux:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco # ls |grep file-serve file-servers.properties file-servers.xml

In location /opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/fileServers/default there is two files

linux:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/fileServers/default # ls file-servers-context.xml file-servers.properties

and content of

/opt/Alfresco/tomcat/webapps/alfresco//WEB-INF/classes/alfresco/file-servers.properties

matches content of

/opt/Alfresco/tomcat/webapps/alfresco//WEB-INF/classes/alfresco/subsystems/fileServers/default/file-servers.properties

and content of

/opt/Alfresco/tomcat/webapps/alfresco//WEB-INF/classes/alfresco/file-servers.xml

matches content of

/opt/Alfresco/tomcat/webapps/alfresco//WEB-INF/classes/alfresco/subsystems/fileServers/default/file-servers-context.xml

In file /opt/Alfresco/tomcat/webapps/alfresco//WEB-INF/classes/alfresco/subsystems/fileServers/default/file-servers.properties we changed

cifs.binto=

to

cifs.binto=10.0.14.227

and after restarting Alfresco and Linux SMB we have this output

linux:/ # netstat -lnp |egrep 'java|mb' | tr -s ' '
tcp 0 0 10.0.14.216:139 0.0.0.0:* LISTEN 2936/smbd
tcp 0 0 10.0.14.216:445 0.0.0.0:* LISTEN 2936/smbd
tcp 0 0 :::50753 :::* LISTEN 8655/java
tcp 0 0 :::50500 :::* LISTEN 8655/java
tcp 0 0 127.0.0.1:8005 :::* LISTEN 8655/java
tcp 0 0 :::50501 :::* LISTEN 8655/java
tcp 0 0 :::50502 :::* LISTEN 8655/java
tcp 0 0 :::50503 :::* LISTEN 8655/java
tcp 0 0 :::50504 :::* LISTEN 8655/java
tcp 0 0 :::50505 :::* LISTEN 8655/java
tcp 0 0 :::50506 :::* LISTEN 8655/java
tcp 0 0 :::50507 :::* LISTEN 8655/java
tcp 0 0 10.0.14.227:139 :::* LISTEN 8655/java
tcp 0 0 :::33932 :::* LISTEN 8655/java
tcp 0 0 10.0.14.227:8080 :::* LISTEN 8655/java
tcp 0 0 :::21 :::* LISTEN 8655/java
tcp 0 0 10.0.14.227:445 :::* LISTEN 8655/java
udp 0 0 10.0.14.227:137 :::* 8655/java
udp 0 0 :::48786 :::* 8655/java

and as you can see Alfresco bind 10.0.14.227:445 and 10.0.14.227:137 and Linux SMB bind 10.0.14.216:139 and 10.0.14.216:445. From Windows explorer we now can acces both \\10.0.14.227\alfresco and \\10.0.14.216\samba locatiion on our Linux server.

No other changes are made but modifiying cifs.binto. Now everything works perfectly!!!

We hope that this will help you!!!

Once again I want to thanks Tatjana K. for solving this very important problem!!!


Regards

Boris Bardak

Personal tools
Download and go
© 2014 Alfresco Software, Inc. All Rights Reserved. Legal | Privacy | Accessibility