Physical IP and DNS mapping with vRealize Network Insight

vRealize Network Insight is the must-have tool to gain visibility into all your network flows in your infrastructure. When adding vCenter Servers as data sources in vRNI it can map VM names and IP addresses. As in almost every environment, there are running physical workloads as well. Those names are not being recognized or mapped by vRNI and show only the IP address in the flows.

For every human being, except for the hard-core networking guys 😉 it is easier to view flows by hostnames instead of IP addresses. Therefore, vRNI provide you the possibility to map A records to IP addresses. In this blog post, I will explain how to do this with the help of a PowerShell script.

First I will start off the PowerShell code you’ll find below. A lot of credits for this code goes to my colleague Hans Jaspers specialized in the End-User Computing stack.

###Export DNS Records from Active Directory for import in vRealize Network Insight###
##############################Version: 1.0###########################################
######################By: Wesley Geelhoed and Hans Jaspers###########################

##Environment information and variables##
$credentials = Get-Credential
$DNSServer = "dnsserver.domain.com"

##Set the ExecutionPolicy to allow execution of scripts##
Set-ExecutionPolicy Unrestricted -Force

##Connect to your Domain Controller(DC)##
$session = New-PSSession -ComputerName $DNSServer -Credential $credentials
Invoke-Command $session -Scriptblock { Import-Module ActiveDirectory }
Import-PSSession -Session $session -module ActiveDirectory -AllowClobber


##Get a list of all domain controllers in your environment##
Write-Host 'Currently connected to the following Domain Controllers:' -ForegroundColor Green
Get-ADDomainController -Filter * | Select-Object name | Write-Output


##Domain##
##Export DNS server zone to file##
[string]$DNSServer = "dnsserver.domain.com"
[string]$Domain = "dnszone"
[string]$Filename = "zone_name.csv"

$DNSRecords = Get-DnsServerZone -Computername $DNSServer -Name $Domain | Get-DnsServerResourceRecord -ComputerName $DNSServer -RRType A | select HostName,RecordType,Timestamp,TimeToLive,@{Name='RecordData';Expression={$_.RecordData.IPv4Address.ToString()}} | Where {$_.RecordData -match $IPAddress}

foreach ($DNSRecord in $DNSRecords) {

[array]$ExportList += New-Object PSObject -Property @{

"Hostname" = $DNSRecord.Hostname
"IPAddress" = $DNSRecord.Recorddata
"Domain"= $Domain
}
}

$ExportList | Select-Object Hostname,IPAddress,Domain | Export-CSV -Path $Filename -NoTypeInformation

(Get-Content $Filename) | select-object -Skip 1 | ForEach-Object {$_ -replace '"',''} | Out-File $Filename

Remove-Variable * -ErrorAction SilentlyContinue

To get the script working in your own environment, you need to adjust some variables. The $DNSServer, $Domain, and $Filename variables need to be changed. After the script ran, you should have a *.csv file with the DNS mappings. (by default located in the ‘System 32’ folder). Add the CSV file(s) to a zipped file and you are all set.

Go to Settings -> IP Properties and Subnets -> Physical IP and DNS Mapping in the vRNI user interface and click on Upload and Replace.
2019-06-05 08_32_56-settings - VMware vRealize Network Insight_ vrni.ssc.lan

 

Browse for the *.zip file with the CSV files and upload and validate the files. When the files in the zipped package are correct you will see that a certain amount of A records successfully were parsed. When you click on submit, those A records will be imported.
2019-06-05 08_37_18-settings - VMware vRealize Network Insight_ vrni.ssc.lan

If you want to update the records in the future you need to upload the complete new DNS zone file again, and not only the new records. Since vRNI uses a ‘replace’ principle for the IP-DNS mapping.

Please feel free to reach out if you have any questions or remarks.

sources: vmware.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s