PowerShell DNS †
#enull{{
&tag(PowerShell,DNS,DnsShell,レコード,ゾーン);
}}
PowerShellにてDNSを扱えるようにする †
- DnsShellをCodePlexからダウンロードする。(初めての場合のみ)
- PowerShellのモジュールパスにダウンロード(して解凍)したフォルダをコピー(移動)する。(初めての場合のみ)
Copy-Item -Path "C:\Users\Administrator\Desktop\DnsShell" -Destination (Get-ChildItem -Path Env:\PSModulePath).Value -Recurse
- モジュールをインポートする。
PS> Import-Module -Name DnsShell
コマンドレット一覧 †
Get-Command -Module DnsShell | Select-Object -Property Name
カテゴリ | コマンドレット名 | | | | | | |
消去 | Clear-DnsCache | | | | | | |
取得 | Get-ADDnsPartition | Get-ADDnsRecord | Get-ADDnsZone | Get-Dns | Get-DnsRecord | Get-DnsServer | Get-DnsZone |
作成 | New-ADDnsRecord | New-ADDnsZone | New-DnsRecord | New-DnsZone | | | |
削除 | Remove-ADDnsRecord | Remove-ADDnsZone | Remove-DnsObject | | | | |
リセット | Reset-DnsZoneType | | | | | | |
再開 | Resume-DnsZone | | | | | | |
設定 | Set-ADDnsRecord | Set-ADDnsZone | Set-DnsRecord | Set-DnsServer | Set-DnsZone | Set-DnsZoneTransfer | |
起動・停止 | Start-DnsScavenging | Start-DnsService | Stop-DnsService | Suspend-DnsZone | | | |
更新 | Update-DnsZone | Update-DnsZoneFile | | | | | |
取得 †
レコードを取得する †
任意の種別のレコードを取得する †
ゾーン情報を取得する †
- "testzone.local"ゾーンの情報一覧を取得する
PS> Get-DnsZone -Name testzone.local | Format-List -Property *
- testzone.localゾーンのゾーン種別(プライマリorスレーブ)を取得する
PS> (Get-DnsZone -Name testzone.local).ZoneType
- "1.168.192.in-addr.arpa"ゾーンが逆引きゾーンであるかどうかを取得する
PS> (Get-DnsZone -Name 1.168.192.in-addr.arpa).Reverse
作成 †
レコードを作成する †
- ホスト"server1.testzone.local"について、IPアドレスを"192.168.1.100"とするAレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType A -Name server1 -IPAddress 192.168.1.100
- IPアドレス"192.168.1.100"について、ホスト名を"server1.testzone.local"とするPTRレコードを作成する
PS> New-DnsRecord -ZoneName 1.168.192.in-addr.arpa -RecordType PTR -Name 100 -Hostname server1.testzone.local
- ホスト"server1.testzone.local"の別名を"sv.testzone.local"とするCNAMEレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType CNAME -Name sv -HostName server1.testzone.local
- ホスト"mx.testzone.local"で優先度"10"とするMXレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType MX -Name mail -TargetName mx.testzone.local -Preference 10
- ホスト"ns.testzone.local"を"testzone.local"ゾーンのネームサーバとして指定するNSレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType NS -Hostname ns.testzone.local
- 「"testzone.local"ゾーンからメール発信することはない」と宣言するSPFレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType TXT -Text "v=spf1 -all~"
- 「"testzone.local"では192.168.1.10のサーバからのみメールが発信される」と宣言するSPFレコードを作成する
PS> New-DnsRecord -ZoneName testzone.local -RecordType TXT -Text "v=spf1 +ip4:192.168.1.10 ~all"
ゾーンを作成する †
- "testzone.local"という名前のプライマリDNSゾーンを作成する
PS> New-DnsZone -ZoneName testzone.local -ZoneType Primary
- SOA責任者を"soarp"と指定して、"testzone.local"という名前のプライマリDNSゾーンを作成する
PS> New-DnsZone -ZoneName testzone.local -ZoneType Primary -ResponsiblePerson soarp
- "testzone.local"という名前のActiveDirectory統合DNSゾーンを作成する
PS> New-DnsZone -ZoneName testzone.local -ZoneType Primary -ADIntegrated
- サーバ(IPアドレス:192.168.1.1)が管理する"testzone.local"という名前のプライマリDNSゾーンに対する、セカンダリDNSゾーンを作成する
PS> New-DnsZone -ZoneName testzone.local -ZoneType Secondary -MasterServer 192.168.1.1
- "1.168.192.in-addr.arpa"という名前の逆引きDNSゾーンを作成する
PS> New-DnsZone -ZoneName 1.168.192.in-addr.arpa -ZoneType Primary
- "testzone.local"ゾーン(ドメイン)についての問い合わせを、別のサーバ(IPアドレス:192.168.1.1)にフォワードする条件付きフォワーダを作成する
PS> New-DnsZone -ZoneName testzone.local -ZoneType Forwarder -MasterServer 192.168.1.1
削除 †
レコードを削除する †
ゾーンを削除する †