Yesterday we generated the content for Unattend.xml, today we’re going to work on something simple but necessary for many servers.   Assigning a Static IP address.

Now let’s remember, Nano Server is STILL in it’s early days, so we normally would have two options we can’t use at this time.

  • PowerShell Cmdlets for the Network Stack
  • Configuring the IP address using Unattend.xml

We CAN access Nano Server directly through the Text Console and configure an IP address Post install though which is a good option.   But in my case I’d prefer to have the settings injected and ready to go.

Presently you can still use NetSH.exe to configure the settings.

The default network adapter name in Nano Server is called “Ethernet” . In my scenario I would like to assign the following settings to a Nano Server

IPv4 Address : 192.168.1.10
Subnet            : 255.255.255.0
Gateway         : 192.168.1.1
DNS Server     : 192.168.1.5

We can assign these settings with two lines from NetSh.exe

netsh interface ipv4 set address Name=”Ethernet” static 192.168.1.10 255.255.255.0 192.168.1.1
netsh dns set dnsservers name=”Ethernet” source=static address=192.168.1.5

But I’ll be you’re wondering how to get this configured after it boots up?   There is a Script called SetupComplete.cmd that you may not know of.  It’s special to the initial Windows startup that can exist at C:\Windows\Setup\Scripts.

Upon initial startup after processing Unattend.xml and before the login screen, the script will execute.   So we can build this script to autoconfigure our network with a little PowerShell and a HereString.

$IPAddress=’192.168.1.10’
$Subnet=’255.255.255.0’
$Gateway=’192.168.1.1’
$DNS=’192.168.1.5’

$SetupCompleteCMD=@”
netsh interface ipv4 set address Name=”Ethernet” static $IPAddress $Subnet $Gateway
netsh dns set dnsservers name=”Ethernet” source=static address=$DNS
“@

New-Item -ItemType File -Name SetupComplete.cmd -Force | Out-Null
Add-content SetupComplete.cmd -Value $SetupCompleteCMD

Our next phase is tomorrow when we perform the necessary tasks to join this machine to a Domain

Advertisements