hookdns
HookDNS is a library which allow you to modify a name resolution in your Python script without any modification in your hosts file or by using a fake DNS resolver.
import requests
from hookdns import hosts
with hosts({"example.org": "127.0.0.1"}):
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Installation
pip install hookdns
Usage
Custom DNS resolutions are describe by a dictionnary where the keys are hostnames and the values the expected corresponding addresses.
{
"hostname1": "addr1",
"hostname2": "addr2"
}
hostname and addr could be a domain name or a string representation of an IPv4/IPV6.
Example using the patch as a decorator
import requests
from hookdns import hosts
@hosts({"example.org": "127.0.0.1"})
def myfunc():
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Example using the patch as a context manager
import requests
from hookdns import hosts
with hosts({"example.org": "localhost"}):
...
r = requests.get("http://example.org") # the request is sent to your local server
...
Metadata
Release files for hookdns 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hookdns-2.0.2.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hookdns-2.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.4 kB
Release files / hookdns-2.0.2.tar.gz
| Download URL | hookdns-2.0.2.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9116f443d67ec2aacad162cab067d6f12200dcf72ca1bc194a5dbef77b7d513b
|
|
BLAKE2b-256 checksum How to use checksums |
608dddae796c0dce333ab97b9a5a33aae666e3f1333fd4e601fd685eade8ebe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency logRelease files / hookdns-2.0.2-py3-none-any.whl
| Download URL | hookdns-2.0.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d4008e1b00a35a209644d61c31e8356703f53bd9a80062c02585cf48e430488
|
|
BLAKE2b-256 checksum How to use checksums |
add184222d79e3dec52c419e412d43cad56d4d783cdd4ee41c2a4e786d636668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency log