Page 1 of 1

Use Vesta CP as a Dynamic DNS Service

Posted: Fri Aug 26, 2016 12:26 pm
by rbrownell
Hello All;

I am really enjoying Vesta CP and so I figured I would contribute these scripts and some instructions on how to remotely update VestaCP's DNS information with your dynamic WAN IP address. This allows for users to connect to their respective home/office networks without the need for a static WAN IP address by providing a domain name that they can use to connect with instead.

*** Integration with Vesta Control Panel *** - NEW!
The functionality of this script has been built out for inclusion as a service in Vesta Control Panel and is currently pending a Pull request on GitHub. With this functionality, updating your DNS Record associated with the DDNS service is as simple as requesting a URL with a few parameters for authentication purposes.

For a demonstration of this functionality, please check out the video found on the bottom of https://ryanbrownell.com/project/69

If you would help get this pushed into Vesta, please check out the pull request found at https://github.com/serghey-rodin/vesta/pull/1477, test the code and add comments indicating that you would use such a feature.

Warnings:
Should the DDNS service be added to the main Vesta Control Panel code base, this script will be abandoned.

This script was written with optional SSH authentication using a password. Use of this feature involves saving a password into your Linux machine's crontab in plain text format. The general convention states that this method is highly insecure. You should be using RSA keys for SSH authentication instead which is also supported by this script.

Requirements:
A Linux machine attached to the network with the dynamic WAN IP address. (I used a Raspberry Pi for this.)

Step 1:
Download scripts from https://github.com/ryanbrownell/DDNS-for-Vesta-CP/

Step 2:
Copy index.php into /home/{vesta username}/web/{domain name}/{public_html or public_shtml}/ip

Step 3:
Install sshpass on the Linux machine attached to the network with the dynamic WAN IP address.

Step 4:
Copy ddns-client.sh to the Linux machine attached to the network with the dynamic WAN IP address, into the user's ~/scripts directory.

Step 5:
Copy ddns-server.sh to the remote server running Vesta CP into the admin (or root) user's ~/scripts directory. Copy the contents of .bashrc into the admin user's .bashrc file.

Step 6:
Copy the following command into your crontab

Code: Select all

bash ~/scripts/ddns-client.sh {URL to index.php} {server domain name} {vesta username} {domain} {subdomain} {record type} {server admin username} {OPTIONAL server admin password}
and set it to run as frequently as you want, I would suggest hourly is best.

Notes:
For the URL to index.php, if you only use the directory instead of specifying the exact file, ensure to include a trailing slash (example.com/ip/) otherwise, CURL will only pull the header information for the redirect and not return a valid IP address.

This script is hosted on GitHub, so feel free to contribute.

TODO:
I plan to implement RSA SSH Authentication in the near future. (DONE)

Enjoy!

Re: Use Vesta CP as a Dynamic DNS Service

Posted: Wed Oct 12, 2016 7:20 pm
by flaviustech
Can be more precise with step 4 and 5?

Re: Use Vesta CP as a Dynamic DNS Service

Posted: Thu Feb 15, 2018 10:40 pm
by rbrownell
flaviustech wrote:Can be more precise with step 4 and 5?
How so? The tilde (~) character represents the home directory which is usually found at /home/(USERNAME)

Hope this helps.

Re: Use Vesta CP as a Dynamic DNS Service

Posted: Thu Feb 15, 2018 10:41 pm
by rbrownell
This script is likely going to be abandoned with the approval of a pull request to add the same functionality directly to Vesta Control Panel itself. If you would help get this pushed into Vesta, please check out the pull request found at https://github.com/serghey-rodin/vesta/pull/1477 and test and add comments indicating that you would use such a feature.

Re: Use Vesta CP as a Dynamic DNS Service

Posted: Tue May 07, 2019 12:27 pm
by rj2010ism
Good day.

I want to try this out? but i got a question?


Question? When setting this up with VestaCP.. how does this work?

1. Host(PC) login to VestaCP server give IP for remote client and use the VestaCP Upload speed to do connection in between?

or

2. Host(PC) login to VestaCP server give IP for remote client and use direct Dynamic IP that VestaCP got from host and give to client and not using VestaCP upload speed??

Thanks..