{"id":13586065,"url":"https://github.com/pobradovic08/PyTR","last_synced_at":"2025-04-07T14:33:24.383Z","repository":{"id":76244384,"uuid":"93307852","full_name":"pobradovic08/PyTR","owner":"pobradovic08","description":"Update DNS PTR RRs based on device hostname and interface names","archived":false,"fork":false,"pushed_at":"2018-02-13T13:30:32.000Z","size":199,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-02-13T21:22:07.536Z","etag":null,"topics":["dns","ptr"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pobradovic08.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-04T11:04:41.000Z","updated_at":"2024-08-01T16:32:00.497Z","dependencies_parsed_at":null,"dependency_job_id":"02394b83-77ad-43c3-8d40-a164fa6ba422","html_url":"https://github.com/pobradovic08/PyTR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pobradovic08%2FPyTR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pobradovic08%2FPyTR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pobradovic08%2FPyTR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pobradovic08%2FPyTR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pobradovic08","download_url":"https://codeload.github.com/pobradovic08/PyTR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223285042,"owners_count":17119823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","ptr"],"created_at":"2024-08-01T15:05:18.316Z","updated_at":"2025-04-07T14:33:24.376Z","avatar_url":"https://github.com/pobradovic08.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# PyTR — Python DNS PTR updater [![Build Status](https://travis-ci.org/pobradovic08/PyTR.svg?branch=master)](https://travis-ci.org/pobradovic08/PyTR) [![Coverage Status](https://coveralls.io/repos/github/pobradovic08/PyTR/badge.svg?branch=master)](https://coveralls.io/github/pobradovic08/PyTR?branch=master)\n\u003eThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\u003e\n\u003eThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\u003e\n\u003eYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n\n\nPyTR collects interface (IP address, IF-MIB::ifName)\ndetails for a given list of devices, checks and updates PTR RR for those\nIP addresses. PyTR features [_Connectors_](#connectors) for importing and exporting list of\ndevices or existing PTR lists from/to 3rd party data sources.\n\nIt features flexible JSON configuration file for simple implementation\nof rules for:\n- Ignoring devices or/and interfaces (regexp matching of hostname or `ifName`)\n- Ignoring IP addresses (matching prefixes in CIDR notation — `192.0.2.0/24`)\n- Exclusion of HSRP VIP addresses\n- Default and per host community strings (regexp matching of hostname)\n- List of name servers to query\n- List of name servers to update (*not working atm*)\n- List of domain names to build FQDN with\n- Connector configuration\n\nResulting PTR has a form of:\n\n`hostname-ifname.domain.example`\n\n## Installation\n\n- Install pip and Python headers (`python-pip`, `python-devel` on CentOS)\n- Clone git repo: `git clone https://github.com/pobradovic08/PyTR.git`\n- Install dependencies `cd PyTR \u0026\u0026 pip install -r requirements.txt`\n- Create configuration file using provided example:\n`cp example_configuration.json configuration.json`\n- Make sure that you have configured all connectors or to remove `enabled: true`\nfrom configuration file.\n\n## Device PTR check\n`device-ptr-update` is a Python script that displays info about specific device.\nIt shows a list of interfaces that have IP addresses configured, existing\nPTR, IP address and a current status of PTR.\n~~~~\n╒═══════════════════════════════════════════════════════════════════════════════════════════════╕\n│ Device:       r-sc-3.domain.example                                                           │\n│ Interfaces:   10                                                                              │\n│ IP addresses: 10                                                                              │\n╞═══════════════════════════════════════════════════════════════════════════════════════════════╡\n│ifName                     PTR                                          IP address             │\n╞═══════════════════════════════════════════════════════════════════════════════════════════════╡\n│MgmtEth0/RSP0/CPU0/0     ┌ r-sc-3.oobm.domain.example                   192.0.2.210            │\n│                         └─► r-sc-3-mg0-0-0-0..domain.example                                  │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI439                   ┌ r-sc-2-vl410.domain.example                  192.0.2.177            │\n│                         └─► r-sc-3-bvi439.domain.example                                      │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI63                    i r-sc-3-bvi63.domain.example                  172.28.0.1             │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI64                    ┌ dynamic-192-0-2-1.domain.example             192.0.2.1              │\n│                         └─► r-sc-3-bvi64.domain.example                                       │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI65                    i r-sc-3-bvi65.domain.example                  10.137.148.1           │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│Loopback0                ● r-sc-3.domain.example                        192.0.2.249            │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI67                    i r-sc-3-bvi67.domain.example                  172.28.16.1            │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI68                    ■ r-sc-3-bvi68.domain.example                  192.0.2.193            │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│BVI69                    i r-sc-3-bvi69..domain.example                 10.137.47.1            │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n│Bundle-Ether1.230        ┌ r-sc-4-gi0-0-230.domain.example              192.0.2.121            │\n│                         └─► r-sc-3-bu1-230.domain.example                                     │\n├───────────────────────────────────────────────────────────────────────────────────────────────┤\n╘═══════════════════════════════════════════════════════════════════════════════════════════════╛\n~~~~\n\n## Batch PTR update\n`ptr-update` is a Python script that loads devices and PTRs from external sources\n(via Connectors). It merges the list of PTRs loaded through Connectors with\nthe PTR list it obtained from each device.\n~~~~\nLoaded connectors: ObserviumConnector\nLoaded 10 device(s) from 1 connector(s)\nFetching data from devices:\n│▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌│ 100%\n╒═════════════════════════════════════╤══════╤════════╤════════╤══════════╤══════════╤══════════╕\n│Device                               │ OK   │ UPDATE │ CREATE │ NO AUTH  │ IGNORED  │ UNKNOWN  │\n╞═════════════════════════════════════╪══════╪════════╪════════╪══════════╪══════════╪══════════╡\n│dhcp.domain.example                  │ 1    │ 0      │ 0      │ 0        │ 1        │ 0        │\n│imap.different-domain.example        │ 0    │ 2      │ 1      │ 0        │ 1        │ 0        │\n│mtik-pb-2.domain.example             │ 1    │ 2      │ 0      │ 0        │ 0        │ 0        │\n│edge-nv-1.domain.example             │ 5    │ 0      │ 0      │ 1        │ 1        │ 0        │\n│cns2.domain.example                  │ 1    │ 1      │ 0      │ 0        │ 1        │ 0        │\n│olt-sc-1.domain.example              │ 2    │ 0      │ 0      │ 0        │ 0        │ 0        │\n│r-kp-1.domain.example                │ 11   │ 1      │ 1      │ 0        │ 0        │ 0        │\n│asa-bg-1.domain.example              │ 2    │ 0      │ 0      │ 0        │ 0        │ 0        │\n│avas.domain.example                  │ 1    │ 0      │ 0      │ 0        │ 1        │ 0        │\n│asa-bo-2.domain.example              │ 2    │ 0      │ 0      │ 0        │ 0        │ 0        │\n╘═════════════════════════════════════╧══════╧════════╧════════╧══════════╧══════════╧══════════╛\n~~~~\n\n## General information\n### Code structure\nBasic structure looks like this:\n~~~~\n├── classes\n│   ├── connectors\n│   └── output\n└── test\n    ├── configuration_examples\n    ├── connectors\n    ├── output\n    └── system\n    \n~~~~\n\n- `classes/` - main program classes\n- `classes/connectors/` - Autoloaded Connector modules\n- `classes/output/` - Output classes\n- `test` - Unit tests\n- `test/configuration_examples` - Config files for unit tests\n- `test/connectors` - Connectors unit tests\n- `test/output` - Output modules unit tests\n- `test/system` - System configuration files used for testing (snmpd, named)\n\n### PTR statuses\n|Status|Value|Description|\n|------|:-----:|-----------|\n|`STATUS_UNKNOWN` | `0` | PTR status not checked yet |\n|`STATUS_OK` | `1` | PTR exists and is equal to generated PTR\n|`STATUS_NOT_UPDATED` | `2` | PTR exists but differs from generated PTR\n|`STATUS_NOT_CREATED` | `3` | PTR doesn't exists\n|`STATUS_NOT_AUTHORITATIVE` | `4` | None of the configured DNS servers are authoritative for this PTR zone\n|`STATUS_IGNORED` | `5` | Not checked. Device, interface or IP address are on ignore list\n|`STATUS_FOR_DELETION` | `6` | PTR marked to be deleted\n\n## Connectors\n\nCurrently\nimplemented connectors:\n- [ObserviumConnector](classes/connectors/observium) — Observium (requires MySQL database access)\n- [SqliteConnector](classes/connectors/sqlite) — Local SQLite database\n- [DnsConnector](classes/connectors/dns) - DNS server (BIND)\n\nEach connector has it's own subdirectory in `classes/connectors/`. Directory, file and class naming should follow\nsimple rules to make autoloading connectors easier.\nAutoloader will go through all directories in `classes/connectors/` and try to find a file with \na filename of `{dir_name}_connector.py` that has class `{Dir_name}Connector` defined in it.\n\nFor connector named `example` structure would look like:\n~~~~\n├── classes\n│   └── connectors\n│       └── example\n│           ├── __init__.py\n│           └── example_connector.py\n└── test\n    └── connectors\n        └── example\n            └── test_example_connector.py\n~~~~\nwith a class named `ExampleConnector`.\n\n### Connector methods\nAll connectors should be instances of `BaseConnector` class and override all it's methods, needed or not.\nThose methods are:\n- `load_devices` - Returns a list of device hostnames\n- `load_ptrs` - Returns a dictionary of Ptr objects - `{ 'ip_address': Ptr, ... }`\n- `save_ptrs` - Save a dictionary of Ptr objects\n- `delete_ptrs` - Deletes multiple Ptr objects for a list of given IP addresses\n- `delete_stale_ptrs` - Deletes Ptr objects that are most likely obsolete. Connector-dependent behaviour.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpobradovic08%2FPyTR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpobradovic08%2FPyTR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpobradovic08%2FPyTR/lists"}