|
下面是 Cheanll 的 SRS, iSCSI 演示中帶有的 Hanewindhcp (我的是3.0.2.4) 批次 (我修改了小許), 全自動偵測 IP, 只需預先設定好如注冊名, 注冊碼, tftp 目錄, boot file.
Hanewindhcp 的設定檔是 DHCPsrv.ini 參數全在裡面 , 啟動是調用 dhcp4nt.exe -install&&start dhcpsrv.cpl.
速度方面一兩台機連接時, Hanewin 與 tftp32 是差不了多小. 在多機連接的情況下, Hanewin 是比較穩定 (有些客機收不到 pxe server 的響應), 尤其在 客機 dos 下向 pxe server 取文件, tftp32 很多時失去響應.
@echo off
title HaneWindhcp 服務器安裝 by chenall@366840202.cn
setlocal
cd /d "%~dp0"
:: for /f "usebackq tokens=2 delims=[]" %%i in (`ping /n 1 %Computername%`) do set myip=%%i
:: for /f "tokens=1-3,4 delims=." %%i in ("%myip%") do set mynet=%%i.%%j.%%k
:: 不需寫文件, 但太多 ipconfig /all, 還是寫文件較好
:: for /f "delims=: tokens=2" %%a in ('ipconfig /all^|find /i "Default Gateway"') do set default_gateway=%%a
ipconfig /all > %temp%\ipcfg_out.txt
for /f "delims=: tokens=2" %%a in ('find /i "IP Address" %temp%\ipcfg_out.txt') do set IP_Address=%%a
set IP_Address=%IP_Address: =%
for /f "tokens=1-3,4 delims=." %%i in ("%IP_Address%") do set My_IP_Range=%%i.%%j.%%k
for /f "delims=: tokens=2" %%a in ('find /i "Default Gateway" %temp%\ipcfg_out.txt') do set default_gateway=%%a
set default_gateway=%default_gateway: =%
for /f "delims=: tokens=2" %%a in ('find /i "DNS Suffix Search List" %temp%\ipcfg_out.txt') do set DNS_Suffix_Search_List=%%a
set DNS_Suffix_Search_List=%DNS_Suffix_Search_List: =%
for /f "delims=: tokens=2" %%a in ('find /i "subnet Mask" %temp%\ipcfg_out.txt') do set Subnet_Mask=%%a
set Subnet_Mask=%Subnet_Mask: =%
for /f "delims=: tokens=2" %%a in ('find /i "DHCP Server" %temp%\ipcfg_out.txt') do set DHCP_Server=%%a
set DHCP_Server=%DHCP_Server: =%
for /f "delims=: tokens=2" %%a in ('find /i "DNS Server" %temp%\ipcfg_out.txt') do set DNS_Server=%%a
set DNS_Server=%DNS_Server: =%
for /f "delims=: tokens=2" %%a in ('find /i "Primary WINS Server" %temp%\ipcfg_out.txt') do set Primary_WINS_Server=%%a
set Primary_WINS_Server=%Primary_WINS_Server: =%
Echo SubnetMask=%Subnet_Mask%
Echo BaseIP=%my_ip_range%.100
Echo NextIP=%ip_address%
Echo GatewayIP=%default_gateway%
Echo DNSName=%DNS_Suffix_Search_List%
Echo DNS1IP=%DNS_Server%
Echo WINS1IP=%Primary_WINS_Server%
Echo InterfaceIP=%ip_address%
>DHCPsrv.ini echo.[License]
>>DHCPsrv.ini echo.Key=這裡要改你的Key
>>DHCPsrv.ini echo.Name=這裡要改你的注冊名
>>DHCPsrv.ini echo.[DHCPsrv]
>>DHCPsrv.ini echo.Profile0=%ip_address%
>>DHCPsrv.ini echo.Include=%ip_address%
>>DHCPsrv.ini echo.TFTPDirectory=D:\
>>DHCPsrv.ini echo.Multicast=0
>>DHCPsrv.ini echo.TestIP=1
>>DHCPsrv.ini echo.TFTPEnable=1
>>DHCPsrv.ini echo.TFTPMode=0
>>DHCPsrv.ini echo.Log=0
>>DHCPsrv.ini echo.[%ip_address%]
>>DHCPsrv.ini echo.SubnetMask=%Subnet_Mask%
>>DHCPsrv.ini echo.BaseIP=%my_ip_range%.100
>>DHCPsrv.ini echo.Range=101
>>DHCPsrv.ini echo.NextIP=%ip_address%
>>DHCPsrv.ini echo.BootFile=\boot\grub\grldr
>>DHCPsrv.ini echo.RootPath=iscsi:%ip_address%::3268::MicroPE
>>DHCPsrv.ini echo.UseOpt=1
>>DHCPsrv.ini echo.DNSUpdate=0
>>DHCPsrv.ini echo.GatewayIP=%default_gateway%
>>DHCPsrv.ini echo.DNSName=%DNS_Suffix_Search_List%
>>DHCPsrv.ini echo.DNS1IP=%DNS_Server%
>>DHCPsrv.ini echo.WINS1IP=%Primary_WINS_Server%
>>DHCPsrv.ini echo.InterfaceIP=%ip_address%
dhcp4nt.exe -install&&start dhcpsrv.cpl
endlocal
[ 本帖最后由 adatsui 于 2009-9-1 12:09 编辑 ] |
|