Samba :- Name Resolution – From Windows, Resolve Linux Host Names

Background

Upon trying to connect to the lone Linux host on our LAB network found it inaccessible.

Later found out that the IP Address received from the DHCP Server has changed.

 

Goal

Need to be able to use name resolution and find the Linux host from a windows box.

 

Network Ports

  1. Netbios Name Service
    • UDP Port 137
  2. Netbios Datagram Service
    • UDP Port 138
  3. SMB/CIFS Network Traffic
    • Windows NT 4.0 and Below
      • TCP Port 139
      • UDP Port 139
    • Windows 2000 and above
      • TCP Port 445

Access Linux Hosts from Windows

Outline

  1. Samba Package
    • Is Samba Package Installed?
    • If not, install Samba Package
  2. Configuration
    • /etc/samba/smb.conf
      • netbios name
  3. Start and Enable Services
    • smb
      • Start & Enable for auto-start
      • Check Status
  4. Firewall
    • Netbios Naming Service
      • UDP port 137
      • TCP port 137
  5. Confirm
    • Linux
      • Confirm listening network ports
    • Windows
      • Confirm windows hosts name resolution

Tasks

Samba Package

Is Samba Installed?

yum
Syntax
sudo yum list installed

Sample
sudo yum list installed | grep samba

Output – Image

source.windows.01.20190709.0847PM

Explanation
  1. Samba Installed

Install Samba

If Samba has not yet been installed, we install it.

yum
Syntax
sudo yum -y install {package}
Sample
sudo yum -y install samba

Samba Configuration

Outline

  1. /etc/samba/smb.conf
    • Domain
    • Host
Editor
Syntax
sudo vi {file}
Sample
sudo vi /etc/samba/smb.conf

Output – Image

smb.conf.02.20190709.0946PM.PNG

Service

Service Start and Enable for auto-start

Syntax
sudo systemctl start {service}
sudo systemctl enable {service}
Sample
sudo systemctl start nmb
sudo systemctl enable nmb

 

Service Status

Syntax
sudo service {service} status -l
Sample
sudo service nmb status -l
Output

service.nmb.status.01.20190709.0913PM.PNG

Explanation
  1. Local Master Browser
    • Our Linux host takes upon the role of a local master browser
    • The role is for a specific subnet based on the Interface’s IP Address

Firewall

Firewall – Open
Syntax
sudo firewall-cmd --zone=public --add-port={port}/{protocol} --permanent

Sample
sudo firewall-cmd --zone=public --add-port=137/udp --permanent
sudo firewall-cmd --zone=public --add-port=137/tdp --permanent

Output – Image

firewall.137.01.20190709.0902PM

Explanation
  1. TCP Port 137
    • Opened
  2. UDP Port 137
    • Opened

Confirmation

Confirm Listening Ports

On Linux Hosts, confirm listening network ports

netstat
Syntax
netstat
Sample
netstat -lu | grep netbios
Output – Image

netstat.listening.01.20190710.0218M

Explanation
  1. The listening ports are listed
    • Network Ports
      • They are udp ports
        • netbios-ns
        • netbios-dgm
    • Services
      • /etc/services
        • Please consult the /etc/services file for corresponding network port numbers for the listed service

 

Confirm Windows Host Name Resolution

Confirm that windows host able to perform name resolution against Linux Hosts

Command Line Tools
Syntax
ping {linux-host-name}
Sample
ping linuxdbhost
Output – Image

ping.windows.02.20190710.0144AM

Explanation
  1. The windows host is able to perform name resolution against the windows host

 

Referenced Work

Vladyslav Baidak
Backend Engineer at Scalified
Devops: Configuring Host Name Resolution
Link
September 24, 2017

References

  1. Samba.org
    • Firewalling Samba
      Link
  2. Centrify
    • Configuring the Samba integration
      • Modifying the Samba smb.conf configuration file
        Link
  3. Stack Exchange
    • superuser
      • What is NetBIOS? Does Windows need its ports 137 and 138 open?
        Link
  4. Rackspace
    • How To
      • Check running services on Linux
        Link
  5. Makandra Cards
    • netstat: show listening ports
      Link
  6. Red Hat
    • Archives
      • Re: What is NMB ?
        Link
  7. OS Technix
    • How To Find The Port Number Of A Service In Linux
      Link