SOLVED

DNS block list

Brass Contributor

Hi,

is it possible to block a list of domain that i have on a txt file on a dns server?

5 Replies
You could do it by creating a empty zone, example creating google.com but don't put anything in the zone.
Yes I already thought about that, but it's 50 entries and could get more and more and i want somethig more practical like a txt file with an entry every line.
best response confirmed by alescan (Brass Contributor)
Solution

@alescan 

You may automate it using PowerShell, you may add the list into a Excel document and save it with CSV format and then use Import-Csv command to import it as a list in the PowerShell, take a look at Import-Csv (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs 

Then use function like Add-DnsServerPrimaryZone in a loop or and it will read each record and add it to the DNS. Take a look at Add-DnsServerPrimaryZone (DnsServer) | Microsoft Docs

Try to create a script for one record and then if it works as you expected then use the list.

 

This is not a bad idea, but instead of make and import csv, is better to read the txt file directly with:
Get-Content .\file.txt | ForEach-Object {
Add-DnsServerPrimaryZone ....
}

True, that's work too , however from experience I find out the CSV format is more reliable for large set of data but like you said reading from text file works too.
1 best response

Accepted Solutions
best response confirmed by alescan (Brass Contributor)
Solution

@alescan 

You may automate it using PowerShell, you may add the list into a Excel document and save it with CSV format and then use Import-Csv command to import it as a list in the PowerShell, take a look at Import-Csv (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs 

Then use function like Add-DnsServerPrimaryZone in a loop or and it will read each record and add it to the DNS. Take a look at Add-DnsServerPrimaryZone (DnsServer) | Microsoft Docs

Try to create a script for one record and then if it works as you expected then use the list.

 

View solution in original post