
nmblookup Command in Linux
The nmblookup command is part of the Samba suite, a collection of programs that help with file and print sharing between different operating systems over a network.
- nmblookup is specifically used to query NetBIOS names and map them to IP addresses within a network using NetBIOS over TCP/IP queries. This is particularly useful for identifying machines on a local network by their NetBIOS names.
- nmblookup supports directed queries, meaning you can specify a particular IP broadcast area or even a specific machine to which to send the query. This makes it flexible for different network configurations.
All queries made by nmblookup are done over the UDP protocol. UDP is suitable for this purpose because it is fast and efficient for network queries, although it does not guarantee delivery like TCP does.
Table of Contents
Here is a comprehensive guide to the options available with the nmblookup command −
Syntax of nmblookup Command
The general syntax for the nmblookup command is as follows −
nmblookup [options] name
nmblookup Command Options
The following options provide various ways to query NetBIOS names and map them to IP addresses, offering flexibility and control over how nmblookup operates within your network.
Options | Description |
---|---|
-M | Searches for a master browser by looking up the NetBIOS name with a type of 0x1d. In order to use the name "-", you need to make sure "-" isn't parsed as an argument, e.g. use : nmblookup -M -- -. |
-R | Sets the recursion desired bit in the packet to do a recursive lookup, useful when querying a WINS server for names. See RFC1001, RFC1002 for details. |
-S | After a name query returns an IP address, it performs a node status query to return the NetBIOS names registered by the host. |
-r | Tries to bind to UDP port 137 to send and receive UDP datagrams. Useful for dealing with a bug in Windows 95, but requires root privileges on most UNIX systems. |
-A | Interprets the name as an IP address and performs a node status query on this address. |
-n <primary NetBIOS name> | Overrides the NetBIOS name that Samba uses for itself. Identical to setting the netbios name parameter in the smb.conf file, but takes precedence over smb.conf. |
-i <scope> | Specifies a NetBIOS scope to communicate with when generating NetBIOS names. NetBIOS scopes are rarely used and should only be set by the system administrator. |
-W, --workgroup=domain | Sets the SMB domain of the username, overriding the default domain defined in smb.conf. If the domain is the same as the server's NetBIOS name, the client logs on using the server's local SAM instead of the Domain SAM. |
-O <socket options> | Sets TCP socket options on the client socket. See the socket options parameter in the smb.conf manual for valid options. |
-h, --help | Prints a summary of command line options and exits. |
-B <broadcast address> | Sends the query to the specified broadcast address. Without this option, nmblookup sends the query to the broadcast address of the network interfaces as auto-detected or defined in the interfaces parameter of the smb.conf file. |
-U <unicast address> | Performs a unicast query to the specified address or host unicast address. This option, along with the -R option, is needed to query a WINS server. |
-d, --debuglevel=level | Sets the debug level (integer from 0 to 10). Higher levels generate more detailed log data. Overrides the log level parameter in the smb.conf file. |
-V | Prints the program version number and exits. |
-s <configuration file> | Specifies the configuration file containing details required by the server, including descriptions of all services provided. The default file name is determined at compile time. |
-l, --log-basename=dir | Base directory name for log/debug files. The extension ".progname" is appended (e.g., log.smbclient, log.smbd, etc.). The log file is never removed by the client. |
-T | Causes any IP addresses found in the lookup to be looked up via a reverse DNS lookup into a DNS name, and prints out the DNS name before each IP address .... NetBIOS name pair. |
-f | Shows which flags apply to the name that has been looked up, such as Response, Authoritative, Truncated, Recursion_Desired, Recursion_Available, and Broadcast. |
name |
The NetBIOS name being queried. Depending on options, this may be a NetBIOS name or IP address. If a NetBIOS name, different types may be specified by appending #<type> to the name. The name "*" returns all registered names within a broadcast area. |
Examples of nmblookup Command in Linux
The following examples can help you understand how to use the nmblookup command for various network tasks −
Basic Name Lookup
To translate a NetBIOS name to an IP address within your network, you can use the following command −
sudo nmblookup server1
This command looks up the NetBIOS name "server1" and returns its corresponding IP address, helping you identify the machine on your network.

Search for Master Browser
To search for the master browser in your network, you can run the following command −
sudo nmblookup -M server1
This command searches for a master browser by looking up the NetBIOS name with a type of 0x1d.

Recursive Lookup with Unicast
To specify the unicast address for querying server1, you can simply run −
sudo nmblookup -U 192.168.43.94 server1
This command sends the query directly to the specified unicast address, allowing you to get the NetBIOS name resolution for server1.

Node Status Query
To perform a node status query after a name query returns an IP address, you can use the following command −
sudo nmblookup -S server1
This command retrieves the NetBIOS names registered by the host, providing additional details about the network node.

Query by IP Address
To interpret the name as an IP address and perform a node status query, you can use the following command −
sudo nmblookup -A 192.168.43.94
This command queries the specified IP address and returns the NetBIOS names registered on that machine.

Override NetBIOS Name
To override the NetBIOS name that Samba uses for itself, you can use the following command −
sudo nmblookup -n CUSTOMNAME server1
This command overrides the default NetBIOS name and uses "CUSTOMNAME" instead, allowing you to specify a custom name for your queries.

Conclusion
The nmblookup command is a versatile and essential tool for managing and troubleshooting network connections in environments that utilize the NetBIOS protocol.
Whether you need to map NetBIOS names to IP addresses, identify the master browser on your network, or perform detailed node status queries, nmblookup provides a range of options to suit your needs.