Monday, 28 May 2012

Listing Lync Server IP Addresses

Today I had to compile a list of Lync mediation server IP addresses so that we could create firewall rules to allow traffic from the Lync 2010 edge servers and reverse proxies to the internal servers. I found that there was no easy way to do this using the existing admin tools, and it would have been a slow and repetitive manual lookup of each service and hostname.

To create a repeatable way I could get the IP addresses of these servers I came up with this PowerShell one-liner:

Get-CsPool | ? {$_.Services -like "MediationServer*"} | Select Computers -ExpandProperty Computers | % {$Hostname = $_; $IPAddress = [System.Net.Dns]::GetHostAddresses($Hostname) | ? {$_.AddressFamily -eq "InterNetwork"}; Write-Host $IPAddress,$Hostname}

This command will get all the Lync 2010 Mediation Servers in the topology, expand the computer names from each pool, use a .Net call to get the IPv4 IP address, then output a list of IP addresses and hostnames.

For readbility, the same command can be written across several lines as this:

Get-CsPool | ? {$_.Services -like "MediationServer*"} `
| Select Computers -ExpandProperty Computers `
| % {$Hostname = $_; $IPAddress = [System.Net.Dns]::GetHostAddresses($Hostname) `
| ? {$_.AddressFamily -eq "InterNetwork"}; Write-Host $IPAddress,$Hostname}

The command could easily be changed to list IP addresses for other roles (such as Web or Edge) by changing "MediationServer*" to something else (such as "Web*" or "Edge*")

- Ben

2 comments:

  1. Nice blog helpful for those who are looking for some solution to trace the location of any ip address ..I usually find the location of an ip address using sites like ip localization

    ReplyDelete
  2. It will connect through a fake IP relay system, which will generate a fake IP for the computer. hiding ip address

    ReplyDelete