Question
Is it possible to have IPv6 support enabled by default when creating cPanel accounts?
Answer
At this time, IPv6 support is not possible by default.
It is possible to add a new account to an IPv6 range automatically using the hook interface. cPanel Technical Support does not directly support the creation of custom hooks, but the following can serve as a working example.
Please note that the following hook is unable to be used as-is. In order for it to function, an IPv6 range has to exist on the server already, and its name must be placed in the $range variable.
- Access the server using SSH as the root user
- Create the following file:
/var/cpanel/perl5/lib/IPv6Hook.pm
- Using your preferred text editor, place the following code into the file and save the contents:
#!/usr/bin/perl
package IPv6Hook;
use strict;
use warnings;
use Cpanel::Logger;
use JSON;
my $logger = Cpanel::Logger->new();
sub describe {
my $hook = [
{
'category' => 'Whostmgr',
'event' => 'Accounts::Create',
'stage' => 'post',
'hook' => 'IPv6Hook::enableipv6',
'exectype' => 'module'
}
];
return $hook;
}
sub enableipv6{
my ( $contect, $data ) = @_;
my $user = $data->{'user'};
my $range = 'RANGE_NAME';
$logger->info("Enabling IPv6 on user: $user");
my $enable = qx(whmapi1 ipv6_enable_account user=$user range=$range --output=json);
$logger->info($enable);
} - Register the hook with WHM:
/usr/local/cpanel/bin/manage_hooks add module IPv6Hook
- The next time an account is created, this hook will run after account creation and will add the account to the configured IPv6
Comments
0 comments
Article is closed for comments.