Utility to update IP Range address

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
mikedibella
Senior user
Senior user
Posts: 837
Joined: 2016-12-08 02:21

Utility to update IP Range address

Post by mikedibella » 2021-06-10 21:05

I needed a way to periodically update a named IP Range with a single address to customize the IP Range characteristics for a client with a dynamic IP address.

hmsUpdateRangeIP.exe was written to update a specific IP Range identified by hostname with the address that hostname resolves to in DNS.

To use hmsUpdateRangeIP.exe, edit the appropriate .reg file for your OS and populate the Nameserver, Username, and Password fields with the DNS server, and credentials to access HMS. Change the Logging level (0-2) if you want more or less verbosity in the event log. Copy hmsUpdateRangeIP.exe to your hMailServer\Bin directory and schedule it to run using Task Scheduler, passing the IP Range name as a parameter.

The named IP Range must already exist in HMS, with the same name as the hostname being looked up. Set the range characteristics to your preference. hmsUpdateRangeIP.exe only updates the Upper IP and Lower IP with the first address returned by DNS. All other properties of the range are unchanged.

Written in Delphi. Source included. Requires The Indy Project libraries to compile. Freeware under The MIT License.
Attachments
hmsUpdateRangeIP.zip
IP Range DDNS Updater
(202.14 KiB) Downloaded 339 times

mikedibella
Senior user
Senior user
Posts: 837
Joined: 2016-12-08 02:21

Re: Utility to update IP Range address

Post by mikedibella » 2021-10-14 03:07

Well, I'm bumping this thread myself because today I learned a powerful lesson and this utility is the answer to it not repeating.

I auto-banned myself and spent hours troubleshooting because auto-band connection drop actions are not logged in the Application log (maybe they are logged in the Debug log but I don't keep that enabled).

So I found another use for this utility...keep you own dynamic IP from being auto-banned accidentally.

Just create a range with your hostname as the Name, set the Priority higher that 20, and set the other settings to your preference.

See above for the rest of the implementation detail.

User avatar
jimimaseye
Moderator
Moderator
Posts: 10060
Joined: 2011-09-08 17:48

Re: Utility to update IP Range address

Post by jimimaseye » 2021-10-14 08:58

Why are connections on the same wan address presented as the external address instead of an internal LAN address?
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

palinka
Senior user
Senior user
Posts: 4461
Joined: 2017-09-12 17:57

Re: Utility to update IP Range address

Post by palinka » 2021-10-14 12:17

jimimaseye wrote:
2021-10-14 08:58
Why are connections on the same wan address presented as the external address instead of an internal LAN address?
In my case its a router that doesn't do hairpinning very well (or at all). I fixed that by changing my hosts file on the client machine to point to the LAN address of the server on my domains.

Also, I excluded dynamic WAN IP from scripted filters like this:

Code: Select all

Function WANIP
	With CreateObject("DNSLibrary.DNSResolver")
		WANIP = .IPv4A("mydomain.tld")
	End With
End Function

Sub OnClientConnect(oClient)
	If oClient.IPAddress = WANIP Then Exit Sub
	'
	' etc
	'
End Sub

Post Reply