您好,登錄后才能下訂單哦!
function InstallDNS
{
servermanagercmd -q c:\role.xml|Out-Null
$xml=[xml](Get-Content c:\role.xml)
$dnsrole=$xml.servermanagerconfigurationquery.role|where{$_.id -eq "dns"}
if($dnsrole.Installed -eq $false)
{
servermanagercmd -i $dnsrole.id
}
else{Write-Host "DNS服務(wù)器角色已經(jīng)安裝!"}
$dns=Get-Service dns
if($dns.status -ne "Running")
{
Start-Service dns
}
}
function SetIP
{
$nic=gwmi Win32_NetworkAdapterConfiguration -Filter "IPEnabled=$true"
if($nic.DHCPEnabled)
{
Write-Host "現(xiàn)在設(shè)置" $nic.Description
$ip="192.168.10.10"
$mask="255.255.255.0"
$dns="127.0.0.1"
$nic.EnableStatic($ip,$mask)
$nic.SetDNSServerSearchOrder($dns)
}
}
function DnsConfig
{
$zonename="benet.com"
$Aname="www" #主機(jī)名稱
$Aip="192.168.10.12" #主機(jī)IP地址
$Aip_bj="192.168.10.32"
$Cname="ftp"
$zonename_bj="bj.benet.com"
$ns="server01.benet.com"
$nsip="192.168.10.20"
$forwarder="server02.benet.com"
$forwarderip="192.168.10.30"
Write-Host "設(shè)置正向搜索區(qū)域。。。"
Start-Sleep 2
dnscmd /zoneadd $zonename /primary /file benet.dns #創(chuàng)建正向查找區(qū)域
$reversip="10.168.192" #設(shè)置反向查找區(qū)域網(wǎng)絡(luò)ID
$reverszone=$reversip+".in-addr.arpa"
Write-Host "設(shè)置反向搜索區(qū)域。。。"
Start-Sleep 2
dnscmd /zoneadd $reverszone /primary #創(chuàng)建反向查找區(qū)域
Write-Host "添加主機(jī)記錄"
Start-Sleep 2
dnscmd /recordadd $zonename $Aname A $Aip #設(shè)置www主機(jī)IP
dnscmd /recordadd $reverszone $Aip.split(".")[3] PTR $Aname"."$zonename #設(shè)置www主機(jī)反向查詢名稱
Write-Host "設(shè)置別名"
Start-Sleep 2
dnscmd /recordadd $zonename $Cname CNAME $Aname"."$zonename #設(shè)置www主機(jī)別名為ftp
Write-Host "設(shè)置Benet.com子域BJ"
Start-Sleep 2
dnscmd /zoneadd $zonename_bj /primary
Write-Host "在bj.benet.com中添加主機(jī)記錄"
Start-Sleep 2
dnscmd /recordadd $zonename_bj $Aname A $Aip_bj #在子域bj.betnet.com中添加www主機(jī)記錄
dnscmd /recordadd $reverszone $Aip_bj.split(".")[3] PTR $Aname"."$zonename_bj #在子域bj.benet.com中添加反向查詢
Write-Host "在bj.benet.com設(shè)置主機(jī)別名"
Start-Sleep 2
dnscmd /recordadd $zonename_bj $Cname CNAME $Aname"."$zonename_bj #設(shè)置www.bj.benet.com主機(jī)別名為ftp
Write-Host "添加名稱服務(wù)器Server01"
Start-Sleep 2
dnscmd /recordadd $zonename $ns.TrimEnd("benet.com") A $nsip #添加server01的主機(jī)記錄
dnscmd /recordadd $reverszone $nsip.split(".")[3] PTR $ns #添加server01的反向查詢記錄
dnscmd /recordadd $zonename "@" NS $ns #將server01設(shè)置為名稱服務(wù)器
Write-Host "對sh.benet.com設(shè)置委派為Server01"
Start-Sleep 2
dnscmd /recordadd $zonename sh NS $ns
Write-Host "設(shè)置DNS服務(wù)轉(zhuǎn)發(fā)器為Server02"
Start-Sleep 2
dnscmd /recordadd $zonename $forwarder.TrimEnd("benet.com") A $forwarderip
dnscmd /recordadd $reverszone $forwarderip.split(".")[3] PTR $forwarder
dnscmd /resetforwarders $forwarderip /timeout 5 /slave #參數(shù)Slave表示如果轉(zhuǎn)發(fā)器未能完成查詢,不進(jìn)行迭代查詢,/noslave 則啟用迭代查詢
}
InstallDNS
SetIP
DnsConfig
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。