netbios interview questions
Top netbios frequently asked interview questions
If I read a file from a UNC network share does Windows cache parts of that file?
For example: If I read the whole file byte for byte, will each read call result in a request over the network, or does Windows read larger blocks internally, and serve subsequent request from memory?
Source: (StackOverflow)
I'm able to fetch connected devices IP and their MAC address and also would like to fetch the device's names and services(open ports).
Can somebody please help me with this?
Source: (StackOverflow)
I have been toying with a few ideas and would like to use Netbios to do some checks on the network. So after some research decided pysmb's nmb.Netbios was a good place to start.
I have constructed a simple queryName function that I was hoping would return an ip address. But it seems after checking some wireshark pcap dumps it isnt even broadcasting.
Ive found an example in the pysmb docs but that doesnt seem to broadcast either. Below is my test function, any pointers would be appreciated.
from nmb.NetBIOS import NetBIOS
def queryNam(name):
n = NetBIOS(broadcast=True, listen_port=0)
ip = n.queryName(name, timeout=30)
return ip
name = "Computer-Name"
ip = queryNam(name)
print ip
Source: (StackOverflow)
I have seen a few questions that are like mine, but none that actually apply. The problem I am facing is:
I need to get group membership of User with:
- Group in Domain B
- User in domain A.
- Service in domain B.
- Forrest to Forrest 2-way trust.
User attaches to service and service gets WindowsIdentity object with SID, name, etc.
In order to get group membership, I am using a UserPrincipal object. In order to get that, you need a PrincipalContext object. The constructor for the PrincipalContext object needs the FQDN of the domain (i.e. A.some.domain.com). The WindowsIdentity object has the NetBios domain name in the username (i.e. A\User), but I cannot see a way to get the DNS name.
Here is an example of code that has the DNS name HARD CODED, that works, but I need to take out the hard coded part.
-- WindowsIdentity wi (passed into the method) --
PrincipalContext context = new PrincipalContext(ContextType.Domain, "A.some.domain.com");
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.Sid, wi.User.ToString());
I have another solution that uses impersonation, using System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain().Name, but that is not acceptable because impersonation may not be available. I need a solution that will work with TokenImpersonationLevel.Identification
I have spent several days scouring MSDN and Google (including Stack Overflow) to no avail.
Source: (StackOverflow)
We have been trying - without success - to get transactional message queues working between local servers and our cloud servers up in Amazon EC2.
We're using NServiceBus, and have got the pub/sub examples and various other trivial apps working locally between here and EC2, but trying to spin up the components of our actual application is proving... vexatious.
As far as I can work out, to allow a local server (DYLAN-PC) to send a message transactionally via a queue on an Amazon EC2 instance, I will need to:
- Enable NETBIOS name resolution (e.g. via the /etc/lmhosts file) at both ends
- Allow RPC connections to be initiated from either end (so open port 135 for RPC plus various other ports)
- Configure MSTDC on both systems, enabling remote connections and inbound/outbound connections
Have I missed something? In particular, the requirement to allow NetBIOS in an age where everything (including Active Directory!) runs on DNS seems particularly archaic. Are we doing something stupid trying to use MSMQ between sites like this? This is the first big project where we've tried this kind of distributed architecture, and the deployment/configuration is starting to hurt so much I'm convinced we've taken a wrong turn somewhere... a little perspective or advice would be gratefully received!
Source: (StackOverflow)
I am reading here, that
On connect, the JVM (Java Virtual Machine) tries to resolve the
hostname to IP/port. Windows tries a netbios ns query on UDP (User
Datagram Protocol) port 137 with a timeout of 1.5 seconds, ignores any
ICMP (Internet Control Message Protocol) port unreachable packets and
repeats this two more times, adding up to a value of 4.5 seconds. I
suggest putting critical hostnames in your HOSTS file to make sure
they are resolved quickly. Another possibility is turning off NETBIOS
altogether and running pure TCP/IP on your LAN (Local Area Network).
is this currently an issue still? Because I am working on a heartbeat-sensor and I was curious.
Source: (StackOverflow)
From SuperUser Answer:
An application that uses the NetBIOS interface API for network communication can be run on any protocol stack that supports a NetBIOS interface.
Can we say that NetBIOS is similar to socket API?
Also what is the relation between SMB and NetBIOS? If NetBIOS is similar to socket API, is it possible to implement SMB in socket API?
Please correct me if I am wrong.
Source: (StackOverflow)
given the ip address of a computer on the same network of my Android device, i have to find its NetBIOS/FQDN name ... is there any "clean" solution to accomplish this with the Android SDK and generally speaking in java ?
Obviously InetAddress.get*HostName does not return the NetBIOS name :)
Source: (StackOverflow)
In short - How do I translate a NETBIOS domain to a FQDN ?
Details:
Assuming I'm in domain A and I have user credentials for domain B which has a trust relationship with domain A (I can authenticate the credentials).
How do I get domain B's FQDN when all I have are the credentials of some authenticated user from that domain, including the netbios domain name?
I'm coding in C# but a COM/WMI/Win32 solution would be welcomed as well.
Source: (StackOverflow)
Can u please give me full code to turn on networked computer by WOL option of Network Card and BIOS.
Please provide me all the details and please try to give me working code.
Source: (StackOverflow)
What network tool can I use under DOS/windows to find the ip address of a netbios host as easily as is done in Linux?
For example under Linux (ubuntu) I can find the ip address like so:
# nmblookup imac
querying imac on 192.168.1.255
192.168.1.75 imac<00>
Now, this is the IP of the macbook when connected wirelessly
But under windows I can't ping it:
C:\>ping imac
Pinging imac.gateway.2wire.net [192.168.1.68] with 32 bytes of data:
Request timed out.
And the closest tool I could find returns TWO IPs
(it returns the hardwired IP even though it got a different IP by connecting wirelessly
C:\>nslookup imac
Address: 192.168.1.254
Name: imac.gateway.2wire.net
Addresses: 192.168.1.68, 192.168.1.75
Isnt there a windows command to return only the active IP address for the host?
Source: (StackOverflow)
By hostname i meqn the name of the PC of the client. :)
I'm trying to identify each of the connected client of the server.
Like client -> server. Server says: client hostname has connected.
then all the process by that client will be tagged with the hostname.
And I don't really know how to.
My client code:
char hostname[1024];
gethostname(hostname, 1023);
send(sock, hostname, hostname, 0);
//now we are done sending the hostname of the client.
My server code (the loop):
void clients (int sock)
{
int n, p;
char buffer[256];
char request;
FILE *file;
file = fopen("process.log","a+");
//the stuff i added for the identification
char hostbuf[256];
bzero(hostbuf,256);
n = read(sock,hostbuf,255);
printf("%s has connected.\n",buffer);
//after the client has been identified then we tag all communications from that client as its hostname/identification.
do
{
bzero(buffer,256);
p = read(sock,buffer,255);
if (p < 0) error("ERROR reading from socket");
//the output i modified
printf("%s sent: %s\n",hostbuf,buffer);
n = write(sock,buffer,sizeof(buffer));
if (n < 0) error("ERROR writing to socket");
fprintf(file,"%s\n",buffer); /*writes*/
}while(p == 11);
fclose(file);
}
----------- edit -----------
Used both suggestions together
Added to code:
socklen_t len;
struct sockaddr_storage addr;
char ipstr[INET_ADDRSTRLEN];
int port;
len = sizeof addr;
getpeername(sock, (struct sockaddr*)&addr, &len);
// deal with both IPv4 and IPv6:
if (addr.ss_family == AF_INET) {
struct sockaddr_in *s = (struct sockaddr_in *)&addr;
port = ntohs(s->sin_port);
inet_ntop(AF_INET, &s->sin_addr, ipstr, sizeof ipstr);
} else { // AF_INET6
struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addr;
port = ntohs(s->sin6_port);
inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr);
}
char host[1024];
getnameinfo(&addr, sizeof addr, host, sizeof host, NULL, NULL, 0);
tried to display it:
printf("%s has connected from %s.", host,ipstr);
//returned 'myip.myisp.net has connected from *.*.*.*.'
//i want it to return my PC name.
//my pc name is SashaGre-PC :))
It works but it doesn't return my PC name but rather the 'ip.ispdomain.net'.
Source: (StackOverflow)
(originally asked on StackOverflow, but I think there are more appropriate experts here):
I'm trying to transfer a file from a remote samba share (on a windows server) in a python script (running on OSX 10.10). I am able to mount the share using Finder's Go->"Connect to Server..." dialog, but when I attempt to use the same credentials with the pysmb module in python (v 2.7.6), I get "Connection Refused.":
>>> from smb.SMBConnection import SMBConnection
>>> conn =SMBConnection('myuser', 'mypassword','me','remote-server-netbios-name')
>>> assert conn.connect('remoteserver.mycompany.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/smb/SMBConnection.py", line 103, in connect
self.sock.connect(( ip, port ))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused
Similarly, if I try to use the NetBIOS package to get the remote server's name (to confirm I'm getting that correct), it just times out:
>>> from nmb.NetBIOS import NetBIOS
>>>
>>> def getBIOSName(remote_smb_ip, timeout=30):
... try:
... bios = NetBIOS()
... srv_name = bios.queryIPForName(remote_smb_ip, timeout=timeout)
... except:
... print >> sys.stderr, "Looking up timeout, check remote_smb_ip again!!"
... finally:
... bios.close()
... return srv_name
...
>>> getBIOSName('remoteserver.mycompany.com')
The same code works fine to get files from a samba share on my ubuntu server at home. I suspect it may be some permissions or firewall issue on the server itself. Any ideas on what ports/permissions need to be opened to make this work?
EDIT:
With boardrider's suggestion below, I tried the connect function by specifying port 445. However, that generates a "Connection reset by peer" error:
>>> assert conn.connect('remoteserver.mycompany.com', 445)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/smb/SMBConnection.py", line 112, in connect
self._pollForNetBIOSPacket(timeout)
File "/Library/Python/2.7/site-packages/smb/SMBConnection.py", line 511, in _pollForNetBIOSPacket
d = self.sock.recv(read_len)
socket.error: [Errno 54] Connection reset by peer
Source: (StackOverflow)
I want to discover all devices (host name, MAC address and vendor name) connected to my Wifi network through an android phone. There are no common services running on the devices.
Tried the following methods:
- Pinging all IPs in the subnet takes too long (
inetAddress.isReachable()
).
- Sending an
nbstat
request to query the NETBIOs
names works in some devices. Some of them give PortNotOpenException
(port 137 not opened). Some other devices do not have NETBIOs
name service enabled.
Tried using jcifs for android. Was able to fetch host names using
nbtAddress.getByName(ip)
looped over all IP addresses in the subnet. This method gives all hostnames, irrespective of whether they are active or not.
What is the best method to find all ACTIVE devices on a network? Some apps like FING seem to do it.
Edit: I tried to analyze how the android FING app does it.
- Connected a small hotspot with 2 devices. Started discovery in FING and captured packets on wireshark.
A series of the following requests are sent(All broadcast):

- Started discovery in FING on a large wifi network (65 k devices)
Netbios name service query and response packets are captured. (Unicast and sometimes to broadcast address)
Meanwhile, I try to print the arp entries of my android phone on the IDE.
The number of entries keeps increasing as discovery progresses in FING app.
5 entries before discovery starts
Increases to 1025 entries as the discovery progresses.
Decreases to 150 entries after the discovery is over.
What exactly is happening? There were no ICMP requests. Can ARPRequests be sent in an android application? Please help.
Source: (StackOverflow)