From b2231a592d6aebde7b09353e0db61efa5079a21b Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 30 Jan 2024 21:32:03 +1100 Subject: [PATCH] Reverse DNS docs + NEW status priority #549 --- .github/workflows/docker_cache-cleaner.yml | 2 +- .github/workflows/update_sponsors_table.yml | 2 +- README.md | 4 +- docs/README.md | 13 +++++-- docs/REVERSE_DNS.md | 27 +++++++++++++ front/devices.php | 43 +++++++++++---------- front/plugins/nslookup_scan/nslookup.py | 9 +++-- 7 files changed, 69 insertions(+), 31 deletions(-) create mode 100755 docs/REVERSE_DNS.md diff --git a/.github/workflows/docker_cache-cleaner.yml b/.github/workflows/docker_cache-cleaner.yml index cfeddee6..53925563 100755 --- a/.github/workflows/docker_cache-cleaner.yml +++ b/.github/workflows/docker_cache-cleaner.yml @@ -1,4 +1,4 @@ -name: ci-package-cleaner +name: 🤖Automation - ci-package-cleaner on: diff --git a/.github/workflows/update_sponsors_table.yml b/.github/workflows/update_sponsors_table.yml index 2f3cf8a8..9aadff41 100755 --- a/.github/workflows/update_sponsors_table.yml +++ b/.github/workflows/update_sponsors_table.yml @@ -1,4 +1,4 @@ -name: Update Sponsors Table +name: 🤖Automation - Update Sponsors Table on: schedule: diff --git a/README.md b/README.md index 68b0d1bd..1e692afa 100755 --- a/README.md +++ b/README.md @@ -94,7 +94,9 @@ Get visibility of what's going on on your WIFI/LAN network. Scan for devices, po -### ⭐ Sponsors +### ⭐ Sponsors (Work in progress) + +[![GitHub Sponsors](https://img.shields.io/github/sponsors/jokob-sk?style=social)](https://github.com/sponsors/jokob-sk) Thank you to all the wonderful people who have sponsored this project (=prevented my burnout): diff --git a/docs/README.md b/docs/README.md index 51cbb71b..8ffc8742 100755 --- a/docs/README.md +++ b/docs/README.md @@ -25,6 +25,14 @@ There is also an in-app Help / FAQ section that should be answering frequently a ### 📚 Table of contents +#### 📥 Initial Setup + +- [Subnets and VLANs configuration for arp-scan](/docs/SUBNETS.md) +- [SMTP server config](/docs/SMTP.md) +- [Custom Icon configuration and support](/docs/ICONS.md) +- [Better name resolution with Reverse DNS](/docs/REVERSE_DNS.md) +- [Network treemap configuration](/docs/NETWORK_TREE.md) + #### 🐛 Debugging help & tips - [Debugging tips](/docs/DEBUG_TIPS.md) @@ -33,9 +41,6 @@ There is also an in-app Help / FAQ section that should be answering frequently a #### 🔝 Popular/Suggested -- [Network treemap configuration](/docs/NETWORK_TREE.md) -- [SMTP server config](/docs/SMTP.md) -- [Subnets and VLANs configuration for arp-scan](/docs/SUBNETS.md) - [Home Assistant](/docs/HOME_ASSISTANT.md) - [Bulk edit devices](/docs/DEVICES_BULK_EDITING.md) @@ -43,7 +48,7 @@ There is also an in-app Help / FAQ section that should be answering frequently a - [Manage devices (legacy docs)](/docs/DEVICE_MANAGEMENT.md) - [Random MAC/MAC icon meaning (legacy docs)](/docs/RANDOM_MAC.md) -- [Custom Icon configuration and support](/docs/ICONS.md) + #### 🔎 Examples diff --git a/docs/REVERSE_DNS.md b/docs/REVERSE_DNS.md new file mode 100755 index 00000000..c4f74c25 --- /dev/null +++ b/docs/REVERSE_DNS.md @@ -0,0 +1,27 @@ +## Setting up better name discovery with Reverse DNS + +If you are running a DNS server, such as AdGuard, set up **Private reverse DNS servers** for a better name resolution on your network. Enabling this setting will enable PiAlert to execute dig and nslookup comamnds to automatically resolve device names based on their IP addresses. + +> Example 1: Reverse DNS `disabled` +> +> ``` +> jokob@Synology-NAS:/$ nslookup 192.168.1.58 +> ** server can't find 58.1.168.192.in-addr.arpa: NXDOMAIN +> +> ``` + +> Example 2: Reverse DNS `enabled` +> +> ``` +> jokob@Synology-NAS:/$ nslookup 192.168.1.58 +> 45.1.168.192.in-addr.arpa name = jokob-NUC.localdomain. +> ``` + +### Enabling reverse DNS in AdGuard + +1. Navigate to **Settings** -> **DNS Settings** +2. Locate **Private reverse DNS servers** +3. Enter your router IP address, such as `192.168.1.1` +4. Make sure you have **Use private reverse DNS resolvers** ticked. +5. Click **Apply** to save your settings. + diff --git a/front/devices.php b/front/devices.php index ace29af1..d38824e6 100755 --- a/front/devices.php +++ b/front/devices.php @@ -343,28 +343,29 @@ function filterDataByStatus(data, status) { // ----------------------------------------------------------------------------- function getDeviceStatus(item) { - if(item.dev_PresentLastScan === 1) - { - return 'On-line'; - } - else if(item.dev_PresentLastScan === 0 && item.dev_AlertDeviceDown !== 0) - { - return 'Down'; - } - else if(item.dev_NewDevice === 1) - { - return 'New'; - } - else if(item.dev_Archived === 1) - { - return 'Archived'; - } - else if(item.dev_PresentLastScan === 0) - { - return 'Off-line'; - } + + if(item.dev_NewDevice === 1) + { + return 'New'; + } + else if(item.dev_PresentLastScan === 1) + { + return 'On-line'; + } + else if(item.dev_PresentLastScan === 0 && item.dev_AlertDeviceDown !== 0) + { + return 'Down'; + } + else if(item.dev_Archived === 1) + { + return 'Archived'; + } + else if(item.dev_PresentLastScan === 0) + { + return 'Off-line'; + } - return "Unknown status" + return "Unknown status" } // ----------------------------------------------------------------------------- diff --git a/front/plugins/nslookup_scan/nslookup.py b/front/plugins/nslookup_scan/nslookup.py index 91d8c803..4af6720c 100755 --- a/front/plugins/nslookup_scan/nslookup.py +++ b/front/plugins/nslookup_scan/nslookup.py @@ -51,6 +51,8 @@ def main(): # Retrieve devices unknown_devices = device_handler.getUnknown() + mylog('verbose', [f'[{pluginName}] Unknown devices count: {len(unknown_devices)}']) + for device in unknown_devices: domain_name, dns_server = execute_nslookup(device['dev_LastIP'], timeout) @@ -95,9 +97,10 @@ def execute_nslookup (ip, timeout): mylog('verbose', [f'[{pluginName}] DEBUG OUTPUT : {output}']) - # Parse output using regular expressions - domain_pattern = re.compile(r'Name:\s+(.+)') - server_pattern = re.compile(r'Server:\s+(.+)') + # Parse output using case-insensitive regular expressions + domain_pattern = re.compile(r'name\s*=\s*([^\s]+)', re.IGNORECASE) + server_pattern = re.compile(r'Server:\s+(.+)', re.IGNORECASE) + domain_match = domain_pattern.search(output) server_match = server_pattern.search(output)