Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 36188

Azure Virtual Machine Scale Set – Dynamic DNS Update – Linux

$
0
0

The below articles provides basic understanding on how to configure the dynamic DNS update when the application in the virtual machine scale set uses the fqdn for resolving the hosts in the scale out occurs in the Linux serve. Performed the below configuration steps in Red hat Enterprise Linux 7.2 VM Scale Set and upload them as custom image for the VM Scale set. The below procedure can also be followed for the Linux Virtual Machine in Azure if it requires to perform dynamic update in the dns server. Validate in the test lab before getting into the production environment.

There are few pre-requisites should be considered before moving to the configuration in the Red hat Linux.

  1. DNS Server should be configured properly allowing the port 53.
  2. Change the DNS update properties as Non Secure and Secure Dynamic Update (this is for testing purpose)
  3. Make sure the Virtual network is setup with DNS address details

After validating the above steps follow the below configuration to perform in the Linux system

  1. Login in the VM Scale Set

The root password remains private. First login with the user account you created. When you need to "become root" this is the command you use.

sudo -s

it will ask you to type in your own password again (not the root password, just your own). After that you will be logged in as root.

  1. Check the resolve.conf file has the DNS server IP Address. Check the VMScale Sets can able to communicate the DNS server use nslookup and ping tool for validation

[root@vmss01irl000000 var]# cat /etc/resolv.conf

# Generated by NetworkManager

search reddog.microsoft.com
nameserver 10.0.0.5

 

[root@vmss01irl000000 dhcp]# nslookup dc01.azureinfra.info

Server:         10.0.0.5
Address:       10.0.0.5#53
Name:   dc01.azureinfra.info

Address: 10.0.0.5

 

[root@vmss01irl000000 dhcp]# ping 10.0.0.5

PING 10.0.0.5 (10.0.0.5) 56(84) bytes of data.
64 bytes from 10.0.0.5: icmp_seq=1 ttl=128 time=1.85 ms
64 bytes from 10.0.0.5: icmp_seq=2 ttl=128 time=0.558 ms
64 bytes from 10.0.0.5: icmp_seq=3 ttl=128 time=0.631 ms

--- 10.0.0.5 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 0.558/1.016/1.859/0.596 ms

 

  1. Create a file with filename.sh in the DHCP folder and add the below script. Change the variable declaration as per your requirement.

[root@vmss01irl000000 dhcp]# vi /etc/dhcp/dnsreg.sh

#!/bin/sh
host=`hostname`
requireddomain=azureinfra.info
new_ip_address="$(ip addr show eth0 | grep "inetb" | awk '{print $2}' | cut -d/ -f1)"
nsupdatecmds=/var/tmp/nsupdatecmds1
echo "update delete $host.$requireddomain a" > $nsupdatecmds
echo "update add $host.$requireddomain 3600 a $new_ip_address" >> $nsupdatecmds
echo "send" >> $nsupdatecmds
nsupdate $nsupdatecmds

Save and quit the file using the command : wq!

 

  1. Provide the executable permission for the file and check the same.

[root@vmss01irl000000 dhcp]# chmod +x /etc/dhcp/dnsreg.sh
[root@vmss01irl000000 dhcp]# chmod +x /etc/rc.d/rc.local
[root@vmss01irl000000 dhcp]# chmod +x /etc/rc.local
[root@vmss01irl000000 dhcp]# ls -l /etc/dhcp/dnsreg.sh
-rwxr-xr-x. 1 root root 373 Dec 17 02:20 /etc/dhcp/dnsreg.sh
[root@vmss01irl000000 dhcp]#

 

  1. Add the file path of the dnsreg.sh in the rc.local file and save the file

[root@vmss01irl000000 dhcp]# vi /etc/rc.local

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
sh /etc/dhcp/dnsreg.sh

:wq!

 

  1. Upload the custom image in the VM Scale Set .When the VM boot it's updates automatically the DNS record in the DNS Server

Viewing all articles
Browse latest Browse all 36188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>