No description
| getptr | ||
| LICENSE | ||
| README.md | ||
getptr
A lightweight Bash utility to resolve a hostname to its IP address (preferring IPv6 by default), followed by a reverse DNS (PTR) lookup of that IP.
Features
- Resolves hostnames to either IPv6 (AAAA) or IPv4 (A)
- Performs a reverse DNS (PTR) lookup on the resolved IP
- Supports:
-6to force IPv6 only-4to force IPv4 only- Default mode prefers IPv6 and falls back to IPv4
- Ideal for scripts and network diagnostics
- Pure Bash, portable and dependency-light (uses
dig)
Installation
Copy the script to your ~/.local/bin directory:
mkdir -p ~/.local/bin
cp getptr ~/.local/bin/
chmod +x ~/.local/bin/getptr
Usage
getptr [options] <hostname>
Options
| Flag | Description |
|---|---|
-6 |
Use IPv6 (AAAA record only) |
-4 |
Use IPv4 (A record only) |
| none | Prefer IPv6, fallback to IPv4 |
Examples
getptr interlunium.nl
getptr -6 superworstenbroodje.nl
getptr -4 opperkneus.nl
Example output
$ getptr appdwang.nl
appdwang.nl -> 2a01:7c8:d007:3ae::1 <- jenny.interlunium.nl.
$ getptr -6 almende.com
almende.com -> 2a01:7c8:aac7:11f::1 <- elise.almende.org.
$ getptr -4 bad.solutions
bad.solutions -> 192.64.119.217 <- [no PTR record]
Requirements
- Bash
dig(usually part ofbind-utilsordnsutils)
License
This project is licensed under the GNU General Public License v3.0 (GPLv3). You are free to use, modify, and redistribute it under the terms of the GPLv3.
For details, see: https://www.gnu.org/licenses/gpl-3.0.en.html