Knowledgebase

How do I override public DNS?


If you are looking to override public DNS settings for you domain, you can do that with the util.dns_remap function. This is equivalent to modifying the hosts file on operating systems to override DNS lookups.

1
2
3
4
5
6
7
8
9
-- Remap loadimpact.com to IP 195.178.177.179
util.dns_remap("loadimpact.com", "195.178.177.179")

-- All requests to loadimpact.com will now be sent to 195.178.177.179
local response = http.request_batch({
    {"GET", "http://loadimpact.com/"}
})

log.info("IP used: " .. response[1].ip)

Note: If any other port than the default port 80 is targeted the port number has to be specified. For https this means the port 443 must be specified.

Example:

1
2
3
4
5
-- Make sure clients that load things from loadimpact.com (port 80 and 443) connects to 123.123.123.123

util.dns_remap("loadimpact.com", "123.123.123.123")

util.dns_remap("loadimpact.com:443", "123.123.123.123")