I am using CentOS and I need to connect to a file server running on windows. My friend told me that I need to install SAMBA to be able to do that. and so I installed samba and when I try to check if the installation is successful, this command

smbclient //[hostname]/[sharename] -U [username]

gave me this

timeout connecting to XXX.XXX.XXX.XXX:XXX Error Connecting to XXX.XXX.XXX.XXX (No route to host) Connection to XXX.XXX.XXX.XXX failed (Error NT_STATUS_HOST_UNREACHABLE)

How do I fix this?

Here's the step by step instruction how I installed SAMBA. Kindly check if I'm missing something.

  1. Check if SAMBA is already installed using the command below : $ rpm -q samba

  2. If SAMBA is not yet installed. Type the command shown below to have a root access $ su –

  3. Then you will be asked to type in your password.

  4. Download and install the Linux SAMBA package using the command : yum install samba

  5. Configure the Linux Firewall so that it will allow the SAMBA traffic by following the steps below. a. Click the System >> Administration > Security Level and Firewall b. Type the root password> in the textbox provided c. In “Firewall Options” tab, Check the SAMBA > Combo box. d. Apply and press ok.

  6. Configure the SAMBA config file. In the terminal, you should have a root access, (do as told in number 2) and type in the command below.

    gedit /etc/samba/smb.conf

this will open the smb.conf and it is ready for any modification.

Spot the part of the config file which contains workgroup. Edit that part, change the value to “workgroup”

   workgroup = workgroup

And add this section [NetApps]

path = /data/network-applications 
  writeable = yes
  browseable = yes
valid users = administrator Save all the changes.
  1. Create a SAMBA user a. You must gain root privileges by doing the command in number 2. b. Add administrator as a user smbpasswd -a > administrator
    c. Then it will ask you to type the password for that > account. d. To know if you have any error with the configuration, use > this command Testparm

  2. Start SAMBA and NetBios Service a. To start the SAMBA and NetBios Service /etc/init.d/smb {start|stop|restart|reload|status|condrestart}

  3. Accessing Windows Shares From CentOS a. Gain root privileges by doing number 2. b. Download and install samba-client $ Yum install > samba-client

  • Please let me know your farewell is Enable/Disable if Enable then configure your farewell via command line "iptables" or " system-config-farewell" use any method..
    – user165888
    Mar 22, 2013 at 5:40
  • 2
    Actually you should check L3 connectivity via commands like ping|traceroute and L4 connectivity with telnet and tcpdump.
    – Navern
    May 24, 2015 at 19:56

1 Answer 1


I'm writing this from the samba server's perspective.

If you don't have access to a gui or prefer to do things in the command line you can replace step 5 with:

First, work out which ports samba is listening on. This can be done with this command:

netstat -tulpn | egrep "samba|smbd|nmbd|winbind"

You'll see something like this:

tcp 0 0* LISTEN 43270/smbd
tcp 0 0* LISTEN 43270/smbd
tcp 0 0* LISTEN 43273/samba
tcp 0 0* LISTEN 43273/samba
tcp 0 0* LISTEN 43270/smbd
tcp 0 0* LISTEN 43270/smbd

The above example shows, that the services are listening on localhost ( and the interface with IP - each on the listed ports (139, 88, 445, and so on). Further information about samba port usage can be found here: https://wiki.samba.org/index.php/Samba_port_usage

Make a note of port and associated tcp/udp, then add lines that open these ports and protocols in /etc/sysconfig/iptables (it's probably a good plan to back up iptables before editing).

If we take the top line of output from the example above, we'd want to open TCP port 139 in iptables. This can be done by adding the following line of text to /etc/sysconfig/iptables:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

Say if you wanted to open UDP port 137 you could do it by adding the following line of text to /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m udp -p ucp --dport 137 -j ACCEPT

You'd need to keep adding lines for any other ports that you need to have open.

Then save your changes, and restart IPtables (service iptables restart).

Hope that helps.

You must log in to answer this question.