Softaculous


Topic : How to use rDNS with OVH/Hetzner


Posted By: northnetworking on November 18, 2019, 10:43 am
Hello,

I have setup two PDNS server and they are working fine. I added a rDNS to one of my VPS but after a day, when I check the rDNS, the rDNS is still the default one at my provider and not what I set in Virtualizor.

So how do you setup rDNS in Virtualizor to work on IPs that you rent from OVH or Hetzner?

Thanks

-----------------------
Networking made easy
contact[at]northnetworking.com
https://northnetworking.com

Posted By: wolke on November 18, 2019, 10:53 am | Post: 1
How should your provider know what you set in PDNS?
These IP addresses and the rdns entries are managed by your provider, so you need to set the rdns in their controlpanel not in your pdns server.

Posted By: northnetworking on November 18, 2019, 1:14 pm | Post: 2
Exactly my point.

I'm guessing the rDNS in Virtualizor only works when you own the IPs or rent them with the provider announcing the IPs towards you.

-----------------------
Networking made easy
contact[at]northnetworking.com
https://northnetworking.com

Posted By: wolke on November 18, 2019, 1:48 pm | Post: 3
Why don´t you use hooks to change the rdns at your provider via API calls?

Posted By: northnetworking on November 18, 2019, 2:23 pm | Post: 4
Yeah, could work. Not sure how to do hooks with Virtualizor tho. I saw the docs on hooks, but from the quick look it only has hooks for after config, after create, before delete, after delete etc?

Could you point me in the right direction?

-----------------------
Networking made easy
contact[at]northnetworking.com
https://northnetworking.com

Posted By: wolke on November 18, 2019, 2:48 pm | Post: 5
At master, create a file editvs.php in /usr/local/virtualizor/hooks

I made an example with hetzner webservice API (need to create a user for that in hetzner robot):

PHP Code

<?php
function __editvs($old_vps$new_vps){
#Hetzner Curlcall:#curl -u user:password https://robot-ws.your-server.de/rdns/[IP] -d ptr=[HOSTNAME] -X PUT}
# Translated into PHP curl:

$ch curl_init();

//we take the first value from $new_vps['ips'] => reset
curl_setopt($chCURLOPT_URL'https://robot-ws.your-server.de/rdns/'.reset($new_vps["ips"]));
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_CUSTOMREQUEST'PUT');
curl_setopt($chCURLOPT_POSTFIELDS"ptr=".$new_vps['hostname']);curl_setopt($chCURLOPT_USERPWD'YOURWEBSERVICEUSER' ':' 'YOURWEBSERVICEPASSWORD');
$headers = array();$headers[] = 'Content-Type: application/x-www-form-urlencoded';curl_setopt($chCURLOPT_HTTPHEADER$headers);
$result curl_exec($ch);
if (
curl_errno($ch)) {    echo 'Error:' curl_error($ch);}
curl_close($ch);
?>


I did not test this, but it should be enough to point you into the right direction.
remember to change your username and password in this example and to secure access to your webservice user by setting Ip restriction in the robot.


Edited by wolke : November 18, 2019, 2:50 pm

Posted By: northnetworking on November 18, 2019, 8:56 pm | Post: 6
Thank you!

How well does it work when you have both Hetzner and OVH? Will the editvs.php be able to handle both?

-----------------------
Networking made easy
contact[at]northnetworking.com
https://northnetworking.com

Posted By: wolke on November 19, 2019, 10:53 am | Post: 7
In that case you need to verify first which provider is in charge for the given IP and then call the specific providers API.


Posted By: wolke on November 20, 2019, 6:01 pm | Post: 8
Found that example too buggy to be useful. Made a working one (just replace username and password obviously) which works right away with hetzner (using their php client).
You can download the php client directly from hetzner at:
https://robot.your-server.de/downloads/robot-client.zip
or just use the ready template attached to this posting.Take care not to overwrite your editvs.php file if you are already using it.

Powered By AEF 1.0.8 © 2007-2008 Electron Inc.