How To Add A Secondary IP Address To Windows Container

Recently someone asked me how can he adds a secondary IP address to a Windows Container hosting multiple IIS websites.

Adding a secondary IP Address to a Windows Container can be done using a few PowerShell cmdlets In a matter of a few minutes as you will see below.

Requirements
Get Started

In my case, I have a Windows Server Core 2016 1709 Container and my container host has the Network configuration below.

Next, I’ll create a Container with the Transparent network above

docker run -it --name test --network=MyTransparentNetwork microsoft/windowsservercore:1709 powershell

From the Container, I’ll run the cmdlet below to get the Network Adapter Interface ID

Get-NetAdapter

In the final step, I’ll assign a secondary IP

New-NetIPAddress -InterfaceIndex 23 -IPAddress 192.168.0.26 -PrefixLength 24 -DefaultGateway 192.168.0.1

And as you can see below. The new secondary IP address Is set.

This article Is based on the blog post below where I used it on Windows Nano Server 2016.

https://www.ntweekly.com/2017/05/05/add-secondary-ip-address-to-windows-nano-server-2016/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.