Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Shall script-DHCP installation and configuration

Shulou Source: shulou.com Published: 2022-06-01 05:03:05 10月03日 Update

$dhcpscope=read-host-Prompt "Please enter dhcp scope address"

$scopename=Read-Host-Prompt "Please enter dhcp scope name"

$scopedescript=Read-Host-Prompt "Please enter a description of the dhcp scope"

# get the current computer name #

$Hostname=$env:COMPUTERNAME

# get the fully qualified domain name of this machine #

$fqdnname= ([system.net.dns]:: gethostentry ($Hostname)) .Hostname

$iprangea=Read-Host-Prompt "Please enter dhcp to assign the starting address"

$iprangeb=Read-Host-Prompt "Please enter the dhcp assignment end address"

$ipexcludea=Read-Host-Prompt "Please enter dhcp to exclude the starting address"

$ipexcludeb=Read-Host-Prompt "Please enter dhcp exclusion end address"

$ipgateway=Read-Host-Prompt "Please enter the gateway address assigned by dhcp"

$ipdns=Read-Host-Prompt "Please enter the dns address assigned by dhcp"

# automatically install DHCP service in windows server 2008 #

ServerManagercmd-I dhcp

# set the DHCP service startup mode to automatic #

Get-Service dhcpserver | Set-Service-StartupType automatic

# start the DHCP service #

Start-Service dhcpserver

# add address scope #

Netsh dhcp server add scope $dhcpscope 255.255.255.0$ scopename $scopedescript

# add DHCP service authorization to active Directory #

Netsh dhcp add server $fqdnname

# add IP address range in DHCP service #

Netsh dhcp server scope $dhcpscope add iprange $iprangea $iprangeb dhcp

# add an excluded address to the distribution domain #

Netsh dhcp server scope $dhcpscope add excluderange $ipexcludea $ipexcludeb

# add the distribution gateway address to the DHCP service #

Netsh dhcp server scope $dhcpscope set optionvalue 003 ipaddress $ipgateway

# add a DNS address to the DHCP service #

Netsh dhcp server scope $dhcpscope set optionvalue 006 ipaddress $ipdns

# activate the DHCP distribution domain #

Netsh dhcp server scope $dhcpscope set state 1

Tags: Address input service role assignment domain name gateway start mode activation directory scope computer native activity script configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Shulou Information Shulou Technology Microsoft