Recently I was asked about changing a Sharepoint Web Application IP Addresses programatically, is this possible and how will it affect the Sharepoint sites?
I did some testing and it turns out that it is indeed possible to change the IIS Website IP Address without impacting the Sharepoint Web Application(s). For the most part Sharepoint does not care about the IP Address that are assigned to it's Web Application(s), what it cares about is how the IIS sites are mapped to it's Site Collections. The mapping is done via host header in IIS and Alternate Access Mappings in Sharepoint.
Hopefully there are no Sharepoint sites that are accessed using IP Addresses, if so when the IP Address changes, things will break.
Using Host Headers and Alternate Access Mappings allow access via friendly names, these names are only bound by DNS so as
To create a friendly name like 'Portal' first I'll create a host header in IIS to my Sharepoint site, host headers allow me to have several IIS sites and only require one IP address.
In IIS select the Sharepoint site and click Bindings from the Actions menu, enter a friendly name, in my case 'Portal'
Next Ill create a new A record on my DNS server so that the name Portal resolves to my Sharepoint Web Applications IP Address.
Next I'll create a Sharepoint Alternate Access Mapping so that Sharepoint knows what to do when it receives a request for this friendly name 'Portal'
Open Sharepoint Central Administration, select Application Management and under Web Applications select configure alternate access mappings.
Select the alternate access mapping collection for your site and select edit public URLs
Next add the url for your friendly name in one of the zone text boxes
After this configuration is complete Sharepoint can be accessed by typing http://portal. Next I want to programmatically change the IP address of my Sharepoint Web Application.
I found a Powershell script to perform this exact task.
$oldIp = "172.16.3.214"
$newIp = "172.16.3.215"
# Get all objects at IIS://Localhost/W3SVC
$iisObjects = new-object `
foreach($site in $iisObjects.psbase.Children)
# Is object a website?
if($site.psbase.SchemaClassName -eq "IIsWebServer")
$siteID = $site.psbase.Name
# Grab bindings and cast to array
$bindings = [array]$site.psbase.Properties["ServerBindings"].Value
$hasChanged = $false
$c = 0
foreach($binding in $bindings)
# Only change if IP address is one we're interested in
if($binding.IndexOf($oldIp) -gt -1)
$newBinding = $binding.Replace($oldIp, $newIp)
Write-Output "$siteID: $binding -> $newBinding"
$bindings[$c] = $newBinding
$hasChanged = $true
# Only update if something changed
$site.psbase.Properties["ServerBindings"].Value = $bindings
# Comment out this line to simulate updates.
Write-Output "Committed change for $siteID"
Note: Remember DNS will have to be changed first to accommodate the IP Address change.
Provided there are multiple IP Addresses available on the Sharepoint server, this script will look for an old IP Address and update the IIS website to the new IP Address. Again Sharepoint does not care about the IP Address but it only cares about the request coming to it via IIS and matching the name with a Site Collection.
Hopefully this is helpful, it can be useful in fail over scenarios where re-iping at the fail over site is required.