Samba :- Linux & Windows Integration

Background

Mid last week as I was returning home received a word.

It read :-

The Linux Host is not accessible and the Linux Subsystem on our Window 10 desktop is not working either.

 

Working Through

Windows 10 Linux Subsystem

Looked at the Windows 10 Subsystem and the issue appears to be newbie issues.

It looks like a few of the commands from the Linux Study Guide that my family member  is following is not available in the Windows Subsystem.

 

Linux Host

The Linux host was more complicated.

Rebooted

Tried to connect to the Linux Host, but it wouldn’t respond

Due to lack of affection and attention and it needed a reboot badly.

 

Applied Patches

Waiting for me was a trek load of patches.

Applied them.

 

SSH

Tried to ssh it from one of our Windows systems.  But, I couldn’t get a response.

Wireless Access Point

Dynamic IP Address

The Linux host is connected to our network via a Wireless connection.

Connected to the WAP via a browser.

Confirmed that the IP Address had changed from the one registered with the DNS server.

 

DHCP Reservation

Tried to see whether the WAP supports DHCP Reservation.

DHCP Reservation basically states that a given MAC Address should be granted exclusive access to an IP Address.

DNS

Knowing the the WAP could end up offering a different IP Address, it was time to untie our Linux host from a permanent IP Address.

 

SAMBA

Years ago, played around with SAMBA.

But, that was yearns ago.

Vladyslav Baidak @ Scalified

Googled on the right terms.

And, ended up finding a quality post from Vladyslav Baidak @ Scalified.

That post is here :-

Devops: Configuring Host Name Resolution
Link

 

Linked In

Had a few suggestions and reached out to Vladyslav Baidak via Linked In.

Textual

Hi Daniel! Thanks for your interest. I’m really glad I could help you. Indeed that was the reason for writing this mini article – I had the same question some time ago.   As for the title – that’s a typo for sure, we’ll fix it soon

Daniel, we fixed the title and added possibility to add comments as you asked.

 

Image

VladyslavBaidak.linkedIn.20190715.1120AM

 

 

 

 

 

 

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