大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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服务器角色已经安装!"}
$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 "现在设置" $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" #主机名称
$Aip="192.168.10.12" #主机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 "设置正向搜索区域。。。"
Start-Sleep 2
dnscmd /zoneadd $zonename /primary /file benet.dns #创建正向查找区域
$reversip="10.168.192" #设置反向查找区域网络ID
$reverszone=$reversip+".in-addr.arpa"
Write-Host "设置反向搜索区域。。。"
Start-Sleep 2
dnscmd /zoneadd $reverszone /primary #创建反向查找区域
Write-Host "添加主机记录"
Start-Sleep 2
dnscmd /recordadd $zonename $Aname A $Aip #设置www主机IP
dnscmd /recordadd $reverszone $Aip.split(".")[3] PTR $Aname"."$zonename #设置www主机反向查询名称
Write-Host "设置别名"
Start-Sleep 2
dnscmd /recordadd $zonename $Cname CNAME $Aname"."$zonename #设置www主机别名为ftp
Write-Host "设置Benet.com子域BJ"
Start-Sleep 2
dnscmd /zoneadd $zonename_bj /primary
Write-Host "在bj.benet.com中添加主机记录"
Start-Sleep 2
dnscmd /recordadd $zonename_bj $Aname A $Aip_bj #在子域bj.betnet.com中添加www主机记录
dnscmd /recordadd $reverszone $Aip_bj.split(".")[3] PTR $Aname"."$zonename_bj #在子域bj.benet.com中添加反向查询
Write-Host "在bj.benet.com设置主机别名"
Start-Sleep 2
dnscmd /recordadd $zonename_bj $Cname CNAME $Aname"."$zonename_bj #设置www.bj.benet.com主机别名为ftp
Write-Host "添加名称服务器Server01"
Start-Sleep 2
dnscmd /recordadd $zonename $ns.TrimEnd("benet.com") A $nsip #添加server01的主机记录
dnscmd /recordadd $reverszone $nsip.split(".")[3] PTR $ns #添加server01的反向查询记录
dnscmd /recordadd $zonename "@" NS $ns #将server01设置为名称服务器
Write-Host "对sh.benet.com设置委派为Server01"
Start-Sleep 2
dnscmd /recordadd $zonename sh NS $ns
Write-Host "设置DNS服务转发器为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 #参数Slave表示如果转发器未能完成查询,不进行迭代查询,/noslave 则启用迭代查询
}
InstallDNS
SetIP
DnsConfig
成都创新互联公司长期为上千客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为龙城企业提供专业的成都做网站、网站制作、成都外贸网站建设,龙城网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。