Linked Questions

Popular Questions

Connect to windows shared using IP address in SMB

Asked by At

I need to connect to Windows shared drive in Python, and for that I'm using the pysmb library.

The code I have used is as follows:

from smb.SMBConnection import SMBConnection

username = "[email protected]"
password = "password"
client_machine_name = "any_name"
hostname = "server_20xx"
ip_address = ""

# Create the connection object
conn = SMBConnection(username, password, client_machine_name, 
       host_name, use_ntlm_v2=True)

# Connect to the server
conn.connect(host_name, 139)

Since the UNC can be either \\ip_address\share_name or \\hostname\share_name, why doesn't the smb client accept ip_address for establishing a connection?

When I use

conn = SMBConnection(username, password, client_machine_name, 
       ip_address, use_ntlm_v2=True)
conn.connect(ip_address, 139)

The error returned is

raise NotConnectedError

Related Questions