Skip to main content

DNX: Minimal cross-platform DNS changer

Codecov PyPI version built with Python3 GitHub repo size Discord Channel

Overview

DNX is a small Python CLI and library for viewing and changing per-interface DNS servers on Linux, macOS, and Windows. It picks a sensible backend automatically (e.g. systemd-resolved, NetworkManager, or /etc/resolv.conf on Linux; PowerShell DNS cmdlets on Windows; networksetup on macOS), validates IP addresses, and can ping resolvers to show latency before or after you switch. Operations that change system DNS typically require administrator privileges.

PyPI Counter PyPI downloads
Github Stars GitHub stars
Branch main dev
CI CI main CI dev
Code Quality CodeFactor

Installation

Source Code

PyPI

Usage

In Python

Backend and current DNS

>>> from dnx.dns import get_backend, get_platform, Platform
>>> get_platform()
<Platform.LINUX: 'linux'>
>>> backend = get_backend()
>>> backend.get_dns()
['192.168.1.1']

Set DNS (requires admin / elevated process)

>>> from dnx.dns import get_backend
>>> backend = get_backend()
>>> backend.set_dns(["8.8.8.8", "8.8.4.4"])
>>> backend.get_dns()
['8.8.8.8', '8.8.4.4']

Ping helpers

>>> from dnx.ping import ping_server, verify_servers
>>> ping_server("1.1.1.1", count=2)
PingResult(ip='1.1.1.1', reachable=True, ...)
>>> verify_servers(["8.8.8.8", "1.1.1.1"])
(True, [PingResult(...), PingResult(...)])

Exceptions

>>> from dnx.exceptions import DNXError, InvalidIPError
>>> from dnx.dns import validate_ips
>>> validate_ips(["999.0.0.1"])
Traceback (most recent call last):
...
InvalidIPError: ...

CLI

ℹ️ You can use dnx or python -m dnx to run this program.

Version

> dnx --version
dnx 0.1

List presets

> dnx list
google: 8.8.8.8, 8.8.4.4
cloudflare: 1.1.1.1, 1.0.0.1
...

List presets with latency

ℹ️ Sends a few ICMP probes per preset IP (may require permission for raw ping on some systems).

> dnx list --latency
Checking latency for all presets...

google:
  8.8.8.8: 12.3ms avg (0% loss)
  ...

Current DNS

> dnx current
Current DNS servers:
  192.168.1.1

Current DNS with latency

> dnx current --latency
Current DNS servers:
  1.1.1.1

Latency:
  1.1.1.1: 8.1ms avg (0% loss)

Set DNS (preset or IPs)

ℹ️ set and reset require an elevated shell (e.g. Administrator on Windows, sudo on Linux/macOS).

> dnx set cloudflare
Using preset 'cloudflare': 1.1.1.1, 1.0.0.1
DNS updated successfully!

Latency comparison:
  Before:
    192.168.1.1: 2.1ms avg (0% loss)
  After:
    1.1.1.1: 9.0ms avg (0% loss)
> dnx set 9.9.9.9 149.112.112.112 --verify

ℹ️ --verify pings first and asks before continuing if a server is unreachable. --no-latency skips the before/after latency block.

Ping only

ℹ️ Preset name or one or more IP addresses. Use -c / --count for probe count.

> dnx ping cloudflare -c 4
Pinging 2 server(s)...

1.1.1.1: 7.5ms avg (0% loss)
1.0.0.1: 8.2ms avg (0% loss)

Reset to system default

> dnx reset
DNS reset to system default

Interface override

ℹ️ When auto-detected interface is wrong (VPN, multiple NICs), pass --iface before the subcommand:

> dnx --iface "Wi-Fi" current

Issues & Bug Reports

Just fill an issue and describe it. We'll check it ASAP! You can also email dnx@openscilab.com.

  • Please complete the issue template

You can also join our discord server

Discord Channel

Show Your Support

Star This Repo

Give a ⭐️ if this project helped you!

Donate to our project

If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .

DNX Donation

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

Added

Changed

0.1 - 2026-06-22

Added

  • Platform enum
  • get_platform function
  • exceptions module
  • DNSBackend class
  • get_backend and get_linux_backend functions
  • SystemdResolvedDNS, NetworkManagerDNS, and ResolvConfDNS classes
  • MacOSDNS and WindowsDNS classes
  • ping module
  • cli module
  • test.yml workflow
  • version_check.py script
  • Test workflow

Metadata

Release files for dnx 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dnx 0.1
File Size Uploaded
dnx-0.1.tar.gz 27.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dnx 0.1
File Interpreter ABI Platform
dnx-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / dnx-0.1.tar.gz

Download URL dnx-0.1.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8016e6953c01e5c3e3ddb032bcf2b4d10f1a7523984f71c42955fe9f7ce7654e
BLAKE2b-256 checksum
How to use checksums
4d36d07d2acd2a4338b5438be4a5f495061a8c2904e408f64677755335e53235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / dnx-0.1-py3-none-any.whl

Download URL dnx-0.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01953a1f21fe21038cfa4f7824869546612cfb489124027b10c8c544ec0892b8
BLAKE2b-256 checksum
How to use checksums
f6f436c0a48249a9a8eb007bc8cb13eb2811a8df9a221562213ead889f52c7c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page