Skip to content

Commit 8df1d74

Browse files
authored
Using public IP instead of internal IP when creating DNS
Gets public IP from 'v-list-user-ips' command (that reads /vesta/data/ips/ip), precisely from 'NAT' field
1 parent 098a454 commit 8df1d74

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

web/add/web/index.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
// Define domain ip address
4848
$v_ip = escapeshellarg($_POST['v_ip']);
4949

50+
$v_public_ip = $v_ip;
51+
$v_temp_ip = $_POST['v_ip'];
52+
exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var);
53+
$ips = json_decode(implode('', $output), true);
54+
unset($output);
55+
if (isset($ips[$v_temp_ip]) && isset($ips[$v_temp_ip]['NAT']) && trim($ips[$v_temp_ip]['NAT'])!='') {
56+
$v_public_ip = trim($ips[$v_temp_ip]['NAT']);
57+
$v_public_ip = escapeshellarg($v_public_ip);
58+
}
59+
5060
// Define domain aliases
5161
$v_aliases = $_POST['v_aliases'];
5262
$aliases = preg_replace("/\n/", ",", $v_aliases);
@@ -114,7 +124,7 @@
114124

115125
// Add DNS domain
116126
if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) {
117-
exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip, $output, $return_var);
127+
exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_public_ip, $output, $return_var);
118128
check_return_code($return_var,$output);
119129
unset($output);
120130
}

0 commit comments

Comments
 (0)