Windows Server 2016 TP3– Nano Server in VM (IP設定及管理Nano)

前面兩篇關於Nano  Server  in VM  安裝分別利用國外網友另外寫的powershell  及 ws 2016 tp3 光碟中的powershell 成功建立VM 但是其中並沒有提到IP設定及管理的部分。

如果是ip設定部分當然環境中如果有dhcp  Server 那Nano 就可以獲得動態IP,如果要設定靜態IP 其中technet 文件中有提到做法是可以在Windows 安裝完成後執行自訂指令碼

使用powershell 把Nano Server 虛擬硬碟建立完畢後,在還沒有開機時,可以先在本機將該虛擬硬碟先掛載起來.並將script 放到 %WINDIR%\Setup\Scripts\ 這個目錄且script 檔名為 SetupComplete.cmd  。

那SetupComplete.com 的內容(technet 文件的範例):

powershell.exe -command “Import-Module C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1; Import-Module C:\windows\system32\WindowsPowerShell\v1.0\Modules\NetAdapter\NetAdapter.psd1; $ifa = (Get-NetAdapter -Name Ethernet).ifalias; netsh interface ip set address $ifa static 192.168.100.23”

 

實作:

掛載虛擬硬碟後可以看到c:\windows 目錄沒有setup\scripts 目錄

nano22

此時可以自行建立setup\scripts 目錄最後再將SetupComplete.cmd  放入即可

nano23

SetupComplete.cmd  內容中我是多新增了DNS 設定

powershell.exe -command “Import-Module C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1; Import-Module C:\windows\system32\WindowsPowerShell\v1.0\Modules\NetAdapter\NetAdapter.psd1; $ifa = (Get-NetAdapter -Name Ethernet).ifalias; netsh interface ip set address $ifa static 192.168.1.30 255.255.255.0 192.168.1.254″; netsh interface ip set dnsservers $ifa static 192.168.1.1 primary ”   

SetupComplete.cmd下載: 點我  (修改IP即可使用)

最後將虛擬硬碟掛載到hyper-v 中並且開機,第一次開機會看到執行該script 的畫面

114

開機後也可以看到靜態IP 及DNS 設定OK

115

利用server manager 來管理

117

在建立時已經將該nano server 加入網域所以可以很輕鬆來管理他

118

119

可以使用powershell 來管理

120

121



本篇瀏覽人數: 1535
分類: Windows Server 2016 TP3-Hyper-v。這篇內容的永久連結

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *