Microsoft DNS
Articles related to Microsoft DNS Server Administration
DNS SPF and DomainKey record
Jan 30th
This script helps you to generate DNS SPF records and DKIM Keys.
Requires: openssl installed and configured
How to execute
GenDKIM.bat selector mydomain.com
GenDKIM.bat
@echo off openssl genrsa -out %2.private 1024 openssl rsa -in %2.private -out %2.public -pubout -outform PEM GenDKIM.vbs %1 %2
GenDKIM.vbs
' Generate DKIM for DNS
If (Wscript.Arguments.Count < 2) Then
Wscript.Echo "missing arguments" & vbCrLf & "usage: GenDKIM.vbs selector domain.com"
Wscript.Quit(-1)
End If
Const ForReading = 1
Const ForWriting = 2
' create file object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' open public key file
Set objPublic = objFSO.GetFile(Wscript.Arguments(1) & ".public")
' check file has content
If objPublic.Size > 0 Then
' open file for reading
Set objReadFile = objFSO.OpenTextFile(Wscript.Arguments(1) & ".public", ForReading)
' create output file
Set ojbWrteFile = objFSO.OpenTextFile(Wscript.Arguments(1) & ".public.dns", ForWriting, TRUE)
' replace content
strContents = Trim(objReadFile.ReadAll)
srtContents = ReplaceTest(strContents, "-----BEGIN PUBLIC KEY-----", "")
srtContents = ReplaceTest(strContents, "-----END PUBLIC KEY-----", "")
srtContents = ReplaceTest(strContents, "\n", "")
' write SPF (You can add IPV4|IPV6)
ojbWrteFile.Write "_domainkey @ 86400 TXT ( ""v=spf1 a mx ptr ?all"" )"
' write DomainKey
ojbWrteFile.Write "_domainkey @ 86400 TXT ( ""t=y; o=~;"" )"
ojbWrteFile.Write Wscript.Arguments(0) & "._domainkey @86400 TXT ""k=rsa; p=" & srtContents & """"
' close files
objReadFile.Close
ojbWrteFile.Close
Else
Wscript.Echo "The file is empty."
End If
' success
WScript.Quit(0)
' regex function
Function ReplaceTest(str, patrn, replStr)
Dim regEx
' Create regular expression.
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
' Make replacement.
While regEx.Test(str)
str = regEx.Replace(str, replStr)
Wend
ReplaceTest = str
End Function


LinkedIn
Twitter
Skype