Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/superstes/python3_resolver
Script to resolve A/AAAA DNS records
https://github.com/superstes/python3_resolver
dns dns-resolution helper-functions script utility
Last synced: 4 days ago
JSON representation
Script to resolve A/AAAA DNS records
- Host: GitHub
- URL: https://github.com/superstes/python3_resolver
- Owner: superstes
- License: gpl-3.0
- Created: 2023-01-04T14:18:58.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-29T18:28:54.000Z (over 1 year ago)
- Last Synced: 2025-01-03T09:27:03.427Z (5 days ago)
- Topics: dns, dns-resolution, helper-functions, script, utility
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Python3 - DNS Resolver
This is a simple script to resolve DNS A/AAAA records.
It only uses builtin modules.
## Install
```bash
python3 -m pip install python3-resolver
```See: [PyPI](https://pypi.org/project/python3-resolver/)
## Usage
### Shell
If ran from the shell - use the following parameters:
* **-n/--hostname** => The hostname/DNS-record to resolve
* **-p/--protocol** => IP-Protocol to return (_optional; one of '4/6/46'_)```bash
python3 dns_resolver.py -h
> usage: DNS Resolver [-h] -n HOSTNAME [-p {4,6,46}]
>
> Script to resolve A/AAAA DNS records
>
> options:
> -h, --help show this help message and exit
> -n HOSTNAME, --hostname HOSTNAME
> The hostname/DNS-record to resolve
> -p {4,6,46}, --protocol {4,6,46}
> IP-Protocol to returnpython3 dns_resolver.py -n superstes.eu
> ['89.43.33.99', '2a05:8280:f:42ea::3']python3 dns_resolver.py -n superstes.eu -p 4
> ['89.43.33.99']python3 dns_resolver.py -n unsetdomain.com
> []
```### Programmatically
You can import the resolver from other python modules/scripts.
#### Installed via PIP
```python3
from dns_resolver import resolve, resolve_ipv4, resolve_ipv6resolve('superstes.eu')
# list(['89.43.33.99', '2a05:8280:f:42ea::3'])resolve_ipv4('superstes.eu')
# list(['89.43.33.99'])resolve_ipv6('superstes.eu')
# list(['2a05:8280:f:42ea::3'])
```#### Copied
Per example if the scripts are saved in the same directory.
```bash
ls .
> dns_resolver.py
> program.py
``````python3
from dns_resolver import resolve, resolve_ipv4, resolve_ipv6resolve('superstes.eu')
# list(['89.43.33.99', '2a05:8280:f:42ea::3'])resolve_ipv4('superstes.eu')
# list(['89.43.33.99'])resolve_ipv6('superstes.eu')
# list(['2a05:8280:f:42ea::3'])
```