Using smbclient or nmblookup to access samba shares or servers

From Notes_Wiki

Home > CentOS > CentOS 6.x > Samba server configuration > Using smbclient or nmblookup to access samba shares or servers


Using smbclient command line samba client

  • To obtain list of shares shared by particular server use:
    smbclient -U <username> -L <IP_address>
    For example to see list of files shared by machine with IP 10.3.3.145 use 'smbclient -U saurabh -L 10.3.3.145'
  • To Access files shared on windows machine using command:
    smbclient -U <administrator_username> //<IP>/<sharename>
    For example to access drive share named 'C$' on machine with IP 10.3.3.145 using administrator username as saurabh' use 'smbclient -U saurabh //10.3.3.145/C$ '. Note that windows usernames are case-insensitive, so any case is fine for typing username.
  • Once you are connected you will get prompt like 'smb>'. On this prompt you can use "help" command to see what commands are available.
  • To download directories first go to parent directory using cd commands. Then use 'ls' command to see proper full name of directory you want to download. Then use commands:
    prompt
    recurse
    mget "<Directory to download>"
    to download complete directory along with sub-folders and files without any prompting. Then use 'recurse' as soon as download is finished. This is because recurse applies to all commands and not just to mget. Hence if you forget to switch of recurse and try to do 'ls' then you would end up seeing all sub-directories and files inside them to when trying to run 'ls' on any parent directory.
  • We can use command
    smbclient -L localhost -U%
    to check that local samba server is running and that it is allowing users to connect without supplying any username or password.



Using nmblookup

  • To find IP address of computer given its computer name we can use nmblookup. Normally large windows networks have WINS (Windows Name Server) to resolve name to IP addresses and vice-versa. But within same LAN we can resolve name to IP addresses without using WINS server. To find IP address of computer in same LAN, using its computer name use:
    nmblookup '<computer name>'
  • To also find group to which this computer belongs and its MAC address use:
    nmblookup -S '<computer name>'
  • In the "nmblookup -S" output look for lines that contain code '<00>'. For example
    CR0100017 <00> - B <ACTIVE>
    LAB320 <00> - <GROUP> B <ACTIVE>
    In this case the computer name is 'CR0100017' and it belongs to workgroup named 'lab320'.
  • To find IPs of all computers in a workgroup we can use:
    nmblookup '<workgroup name>'
    For example to find all computers in workgroup named lab320 we can use nmblookup 'lab320'
  • If we want computer names along with IP addresses then we can use:
    nmblookup -S 'lab320'


Home > CentOS > CentOS 6.x > Samba server configuration > Using smbclient or nmblookup to access samba shares or servers