Hoto: Setup a DNS-Server and using it with hMailServer

This section contains user-submitted tutorials.
Post Reply
User avatar
Dravion
Senior user
Senior user
Posts: 1053
Joined: 2015-09-26 11:50
Location: Germany
Contact:

Hoto: Setup a DNS-Server and using it with hMailServer

Post by Dravion » 2018-11-27 09:53

Setting up a BIND DNS-Server

In this Tutorial we will install and configure ISC BIND 9 OpenSource DNS-Server instead of using Microsofts DNS-Server (which requires Windows Server) we use BIND 9 instead, because it simply runs on any recrent Windows version.

If everything works as expected, hMailServer diagnostic should looklike this:
BIND_DNS_and_hMailServer_Diagnostics.png
Prequesites:
For this Tutorial we need to use Virtualbox to setup our Training VM-Network, just to have a safe place without risking interference with our existing Networksettings.I recommend to carefully check and validate your DNS-Server settings before implementing it in a live environment, because
in a Cooperate or Homenetwork.

Installing Virtualbox

01)
Download and Install Oracles Virtuabox
https://www.virtualbox.org/wiki/Downloads (choose for: "Windows hosts")

02)
Doubleckick and run the downloaded Virtualbox Installer (in my case: VirtualBox-5.2.22-126460-Win.exe)

Important:
If Virtualbox is installed, we need to setup our own Virtualbox NAT-Network so we can create a independet so we can use
a own Subnet with as many, virtual ip addresses as we need, so our DNS-Server has a propper range of ip addresses to
resolve to Host and Domainnames.

Setting up a Virtualbox NAT-Network

01)
Start Virtualbox and navigate to "File" Menue" and click "Preferences" and in "Preferences" click "Network"

02)
Click the "+" Icon Button to add a new NAT-Network, right click and select "Edit NAT-Network"

03)
Rename it to "Bind-NAT-Network" and in Network CIDR type in: 220.185.130.0/24 and click OK

04)
In Mainmenue click "New" and create a new Windows VM (Win7/8/10 or Win Serer 2008_R2/2012/2016)

05)
Edit settings of your new Windows VM goto "Settings" and then navigate to "Network"

06)
In "Adapter 1" set attached to: "NAT-Network" and select "Bind-NAT-Network from the Dropdown list

07)
Start your VM and Install Windows in the VM, it will get a Dynamic IP like (220.185.130.x)

Getting and installing Bind for Windows

Download BIND from https://www.isc.org/downloads/file/bind ... win-64-bit and unzip the file
BIND9.12.3.x64.zip to the folder "BIND9.12.3.x64"

Setting up a few, static IP addresses in our new Windows VM

01)
Rightclick on the Network Icon in your Windows Taskbar near your Windows Clock Icon

02)
Right click on "Open Network and Sharing Center" or on Win 10/20x on "Open Network and Internet settings"
*On Win7/8 click on "Change adapter settings" and if it opens left double click on "Local Area Connection"
*On Win10/2016-Server click on "Ethernet" and then on "Change adapter options", double click on "Ethernet"

03)
Click on "Properties" and then "Internet Protocol Version 4 (TCP/IP) and then again "Properties"

04)
Choose "Use the following IP address" and type as IP Address 220.185.130.5 (our wm main ip)

05)
In Subnet type in: 255.255.255.0 and in Default Gateway: 220.185.130.1

06)
In preferred DNS-Server type in 220.185.130.5 (let it point to our Bind DNS-Server first)

07)
Click the "Advanced" Button and click "Add", in the Groupbox "IP addresses" click

08)
Add 4 additional ip addresses 220.185.130.10, 220.185.130.11, 220.185.130.12, 220.185.130.13

09)
Click "OK", then "OK" again and click the "Close" Button and the next "Close" Button (until all dialogs are closed)

Installing Bind

01)
Goto your Bind unzip folder and lookup BINDInstall.exe and right click on it and select "Run as administrator"

02)
In the new Window setup a service password (for now: "letmein") and select "Start BIND Service after Install"

03)
The Installer installs the Visual C++ 2012 Runtime, click on "Install", wait and click "close" at the end.

04)
Click on "OK" at the message box "BIND Installation completed successfully" and click the "Exit" Button.

05)
Navigate to "C:\ProgramData" and create a new folder "named" and in it reate "logs", "temp" and "zones" subffolders

06)
Download the attached Archive file "Bind9_ConfigFiles.zip" from this Article and unzip it

07)
Enter the unzipped folder and copy the "etc" folder to "C:\Program Files\ISC BIND 9" and "named" folder to "C:\ProgramData"

09)
In Windows Service Control Panel start the Service ISC BIND (if you want, you can set the User to Localmachine)

10)
Open a "Admin command prompt" and type in ipconfig /flushdns ENTER and afterwards in nslookup -type=mx mydomain1x.com ENTER

hMailServer
Now install a new hMailServer version from https://www.hmailserver.com/download and add the Domain "mydomain1x.com"

Summary
Now you have a fully functional Bind DNS-Server which you can extend and customize.

DNS-Domain settings can be changed by editing the C:\ProgramData\named\zones\*.* Zonefiles with a Text editor and simply
restarting the ISC BIND9 Service in the Windows System Controlpanel. For Errors, carefully watch C:\ProgramData\named\logs\named.log

ps:
I recommend reading the BIND9 Administrator Reference (ARM) https://www.isc.org/bind-9-11-arm/
which describes Bind in full Details and gives tips and help and best practice howtos.
Attachments
Bind9_ConfigFiles.zip
(3.36 KiB) Downloaded 5 times
My x64-Bit builds of hMailserver

hMailServer-5.6.8-B2426-x64.msi (LibreSSL)
hMailServer-5.6.8-B2426-x64.exe (OpenSSL)

Downloads:
https://github.com/hMailServer-ComDevs/hmailserver/releases

Post Reply