· Vladyslav Baidak · DevOps  · 2 min read

Devops: Configuring Host Name Resolution



Devops: Configuring Host Name Resolution

Introduction

When using Linux, especially in a virtual environment, often devops may face with a necessity of accessing its host by the name, not by IP address. The reason is clear: once a DHCP server leases a new IP address, you have to change your configuration.

In case if these hosts use the same channel network you can configure SAMBA on Linux to make it work not only with Windows host names, but also resolve its own host name within the same network.

In this article we are going to answer the following questions:

  • How to access Windows host using its name from Linux host?

  • How to access Linux host using its name from Windows host?

Devops: Accessing Windows Host Name From Linux

In order to make Windows host names available from Linux follow these steps:

  1. Install a samba-winbind package – a Name Service Switch daemon for resolving names from NT servers:

Debian / Ubuntu:

apt-get -y install samba-winbind

Centos / RedHat / Fedora:

yum -y install samba-winbind

You do not need to start or enable winbind service

  1. Check and modify Name Service Switch configuration in /etc/nsswitch.conf file:you need to find the hosts property key and check if it contains wins value:
hosts: files dns wins
  1. Either disable or configure firewalld service:

Disable:

systemctl stop firewalld
systemctl disable firewalld

Configure:

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

Devops: Accessing Linux Host Name From Windows

In order to make Linux host names available from Windows you need a NetBIOS name server. It is already contained in a samba package – a server to provide SMB/CIFS services to clients. So, you need to do the following:

  1. Install a samba package:

Debian / Ubuntu:

apt-get -y install samba

Centos / RedHat / Fedora:

yum -y install samba

You do not need to start or enable smb service

  1. Setup the netbios name for your host in /etc/samba/smb.conf file: you need to find the netbios name property, uncomment it if it is commented and set the value:
netbios name = myhost
  1. Start and enable the nmb service:
systemctl start nmb
systemctl enable nmb
  1. Either disable or configure firewalld service:

Disable:

systemctl stop firewalld
systemctl disable firewalld

Configure:

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

Enjoy your day and read more devops articles here!

Back to Blog

Related Posts

View All Posts »