This project provides a web interface for adding and removing DNS records in a Windows environment. The program is written using Python and the Flask library, enabling easy management of DNS records through a REST API.
-
Install necessary Windows features and enable PSRemoting:
Install-WindowsFeature -Name "WindowsPowerShellWebAccess" Enable-PSRemoting -Force Set-Item WSMan:\localhost\Client\TrustedHosts -Value "RemoteHostName" Enable-NetFirewallRule -Name "WINRM-HTTP-In-TCP" Enable-NetFirewallRule -Name "WINRM-HTTPS-In-TCP" Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP" -Enabled True winrm enumerate winrm/config/listener Enable-PSRemoting -Force
-
Install
curl
:Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) choco install curl -y
-
Install Python from python.org.
-
Install required Python packages:
pip install flask pywinrm
- Run the DNS API program:
python dns_api.py
-
Install
pywin32
package:pip install pywin32
-
Install and start the service:
python flask_service.py install python flask_service.py start sc config FlaskDNSService start= auto
- Stop and remove the service:
python flask_service.py stop python flask_service.py remove
The API provides endpoints to add and remove DNS records. Below are examples of how to use the API with curl
.
-
Create DNS record A:
curl -X POST -H "Content-Type: application/json" -d "{\"name\": \"test\", \"type\": \"A\", \"value\": \"192.168.1.1\"}" http://localhost:5000/dns/add
-
Delete DNS record A:
curl -X POST -H "Content-Type: application/json" -d "{\"name\": \"test\", \"type\": \"A\", \"value\": \"192.168.1.1\"}" http://localhost:5000/dns/delete
-
Create PTR record:
curl -X POST -H "Content-Type: application/json" -d "{\"ip\": \"147.232.204.10\", \"ptr_name\": \"example.yourdomain.com\"}" http://localhost:5000/dns/add_ptr
-
Delete DNS record PTR:
curl -X POST -H "Content-Type: application/json" -d "{\"ip\": \"147.232.204.10\"}" http://localhost:5000/dns/delete_ptr
- Web interface for managing DNS records
- Support for A and PTR records
- Easy integration with Windows services
- Windows OS with PowerShell Web Access
- Python 3.12.4 or later
- Flask
- pywinrm
- pywin32
No additional configuration is required beyond the installation steps provided.
- Martin Hasin @matoh12
This project is licensed under the MIT License. See the LICENSE file for more details.