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

Background

Here is how to use Samba to perform name resolution from a Linux Host to MS Windows computers.

Lineage

  1. Windows
    • WINS
      • Installing & Configuring WINS
        Link
  2. Linux
    • Samba
      • Samba – Host Name Resolution
        Link

Steps

Outline

  1. Package Installation
    • samba-winbind
  2. Network Configuration
    • Names Service Switch
      • /etc/nsswitch.conf
    • Samba
      • etc/smb.conf
  3. Firewall Configuration
    • Firewall – firewalld
      • Allow tcp/137 and ucp/137
  4. Restart Services
    • winbind

Package Installation

samba-winbind

yum

yum – is package installed?
Objective

Is samba-winbind installed?

Code

sudo yum list installed | grep samba

Output

package.install.yum.list.01.20190711.png

yum – Install Package
Objective

Install samba-winbind

Code

sudo yum -y install samba-winbind

Output

Image – 1

package.install.yum.install.01.20190711.0801PM.png

Image – 2

package.install.yum.install.01.20190711.0802PM.png

Network Configuration

Files

File :- etc/nsswitch.conf
Outline
  1. Load the /etc/nsswitch.conf file in an editor
  2. Ensure that wins is included in the list of hosts to consult for name resolution requests
    • Original Entry
      • hosts : files dns myhostname
    • Revised Entry
      • hosts : files dns myhostname wins
Images
Image – 01

nsswitch.conf.01.20190711.png

Image – 02

nsswitch.conf.03.20190711.0807PM.png

File :- etc/smb.conf
Outline
  1. Load the /etc/smb.conf file in an editor
  2. Sections
    • Section – Global
      • Configuration Entry
        • workgroup
          • Please have your network domain name
        • netbios name
          • Your computer’s host name
        • wins server
          • Please ensure that your wins server is referenced
Images

smb.conf.01.20190712.0436AM.PNG

 

Network Firewall Configuration

Firewalld

Our OS is centOS and our current firewall is firewalld.

Configuration
Command – Syntax

sudo firewall-cmd --zone={zone} --add-port={port-number}/{protocol} --permanent

Command – Sample

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

sudo firewall-cmd --zone=public --add-port=137/tcp --permanent

Images

firewall.allow.01.20190711.png

Restart Services

Outline

Please restart relevant services.  Those are :-

  1. winbind

 

Configuration

Command – Syntax
sudo service {service} restart
Command – Sample

sudo service winbind restart

Troubleshooting

Issues

ping: unknown host <hostname>

  1. Restart Services
    • Restart winbind
  2. Configuration
    • Linux
      • Configuration – File –
        • /etc/smb.conf
          • Ensure that your WINS Server is referenced

Referenced Work

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

References

  1. StackExchange
    • Ask Ubuntu
      • Windows Hostnames are not resolved
        Link
      • Why can’t my machine resolve local windows hostnames?
        Link

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