0

I need locust to use a different DNS server - when resolving the URL? Is this possible?

class User(HttpUser):
    @task
    def get_data(self):
        headers = {'authToken': self.token,
                   'Content-Type': 'application/json'}

        res = self.client.get("/data", headers=headers, dns=8.8.8.8)

that dns = 8.8.8.8 doesn't exist but its the functionality I'd like.

nslookup has this functionality: nslookup google.com 8.8.8.8

alex
  • 1,905
  • 26
  • 51
  • 1
    Applications don't generally control how name resolution is done, this is a system configuration setting. – Barmar Aug 24 '22 at 20:24
  • Why would you want to override the user's DNS settings? This is a horrible UX that many pro users have complained about extensively in the past when used (inadvertently or otherwise) to bypass things like Pi-Hole/etc. This will also break your code unnecessarily on higher-security networks where outbound DNS is filtered to specific addresses. – esqew Aug 24 '22 at 20:27
  • "Why would you want to override the user's DNS settings? " I can think of a few reasons. users who are in different regions will get different DNS servers. – alex Aug 24 '22 at 20:34

1 Answers1

1

The Locust client inherits from Requests. Something like the answers to this question should work.

Python 'requests' library - define specific DNS?

Solowalker
  • 2,431
  • 8
  • 13