[jcifs] newbie problems and connection problem on unix box

Mark Shifman mark.shifman at yale.edu
Tue Jul 19 17:04:20 GMT 2005


Michael B Allen wrote:

>On Tue, 19 Jul 2005 09:33:39 -0400
>Mark Shifman <mark.shifman at yale.edu> wrote:
>
>  
>
>>>Linux ehh? Odd. Something's definately wrong there. Actually I think
>>>there might be something about this in the FAQ.
>>> 
>>>
>>>      
>>>
>>Yes! Here it is.
>>
>>    * *Your hostname is resolving to 127.0.0.1.* It is not uncommon on
>>      Linux for an /etc/hosts file to map the hostname to 127.0.0.1 such
>>      as:
>>
>>127.0.0.1      nano   localhost.localdomain    localhost
>>    
>>
>>      Taking the host name (e.g. nano) out of the localhost line should
>>      solved the problem.
>>
>>This is a bit tedious though if you are testing on one linux box and 
>>then running on another box. Also if you like using the short name for 
>>your computer
>>Since getLocalHost returns a short name for my computer, this might be a 
>>reasonable solution
>>jcifs.Config.setProperty( "jcifs.smb.client.laddr", 
>>InetAddress.getLocalHost().getHostName()+"rest.of.domain");
>>    
>>
>
>First, the FAQ doesn't really explain why this problem happends. Personally I have a hostname in my /etc/hosts so there is obviously another factor involved. I suspect if the name is resolvable by DNS you might get different results. Why DNS should have anything to do with binding 127.0.0.1 I don't know but there's not much I can do about it.
>
>  
>
I think I figured out the problem.
my HOSTNAME was set to mylinuxbox in the /etc/sysconfig/network file

my first line of /etc/hosts was
127.0.0.1               mylinuxbox localhost.localdomain localhost

so when it tried to resolve mylinuxbox it got 127.0.0.1

I have changed my hostname to mylinuxbox.med.yale.edu
and got rid of mylinuxbox in the first line of the /etc/host file.

After rebooting things work correctly without setting the property for 
client.laddr.

One could probably add another line in the /etc/host with your ip 
address and I also expect things would work.
xxx.xxx.xx.xx   mylinuxbox

You may want to add a description in the faq  to run
host `hostname`
from a console to see if the HOSTNAME  is resolvable.

If it comes up with 127.0.0.1 or "host not found" then you can add a 
line to /etc/hosts
or add the smb.cliend.laddr property with the ip or the full name of the 
host.


Thanks for your help.

mas



>Anyway, I'll apply the below fix. That should pretty much eliminate the problem regardless.
>
>Mike
>
>  
>
>>>>>if (localAddr == InetAddress.getLocalHost()) {
>>>>>    socket = new Socket( address.getHostAddress(), port );
>>>>>} else {
>>>>>    socket = new Socket( address.getHostAddress(), port, localAddr, localPort );
>>>>>}
>>>>>          
>>>>>
>
>  
>


-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shifman at yale.edu



More information about the jcifs mailing list