This project updates the DNS record for a specified domain and subdomain with the current public IP address using the OpenProvider API.
- Node.js (version 12 or higher)
- An OpenProvider account
-
Clone the repository:
git clone https://github.com/yourusername/update-home-ip.git cd update-home-ip
-
Install dependencies:
pnpm install
-
Create a
.env
file in the root directory and add your OpenProvider credentials and domain information. You can use the.env.example
file as a template:cp .env.example .env
Fill in the required environment variables in the
.env
file:OPENPROVIDER_USERNAME=your_openprovider_username OPENPROVIDER_PASSWORD=your_openprovider_password DOMAIN=your_domain SUBDOMAIN=your_subdomain
To update the DNS record with the current public IP address, run the following command:
node update-home-ip.mjs
- The script loads environment variables from the .env file using the dotenv package.
- It creates an instance of the
OpenProviderDNSUpdater
-class, which handles authentication and DNS record updates. - The
updateDNSRecord
-method is called to update the DNS record for the specified domain and subdomain with the current public IP address.
getPublicIP()
: Fetches the public IP address using various IP services.isValidIPv4(ip)
: Validates the IPv4 address format.
constructor(auth)
: Initializes the updater with authentication credentials.authenticate()
: Authenticates with the OpenProvider API.makeRequest(endpoint, options)
: Makes an API request to OpenProvider.updateDNSRecord(domain, subdomain, newIp)
: Updates the DNS record for the specified domain and subdomain.
This project is licensed under the MIT License.