This hack is to enable Virtualmin to display and edit ipv6 SPF records.
First locate where the webmin install is located then open the file “virtual-server/edit_spf.cgi”
On line 23
# Extra a, mx, ip4
$edspf = $spf || $defspf;
foreach $t ('a', 'mx', 'ip4', 'include') {
print &ui_table_row(&hlink($text{'spf_'.$t}, 'spf_'.$t),
&ui_textarea('extra_'.$t,
join("\n", @{$edspf->{$t.':'}}), 3, 40));
}
Change to
# Extra a, mx, ip4 and ip6
$edspf = $spf || $defspf;
foreach $t ('a', 'mx', 'ip4', 'ip6', 'include') {
print &ui_table_row(&hlink($text{'spf_'.$t}, 'spf_'.$t),
&ui_textarea('extra_'.$t,
join("\n", @{$edspf->{$t.':'}}), 3, 40));
}
Close file.
Open “virtual-server/lang/en”
add the line
setup_eip6=Missing or invalid IPv6 address
close the file.
Open “virtual-server/save_spf.cgi”
Find
elsif ($a eq "ip4") {
# Must be a valid IP or IP/cidr or IP/mask
&check_ipaddress($v) ||
($v =~ /^([0-9\.]+)\/(\d+)$/ &&
$2 > 0 && $2 <= 32 &&
&check_ipaddress("$1")) ||
($v =~ /^([0-9\.]+)\/([0-9\.]+)$/ &&
&check_ipaddress("$1") &&
&check_ipaddress("$2")) ||
&error(&text('spf_e'.$t, $v));
}
Add after
elsif ($a eq "ip6") {
# Must be a valid IP or IP/cidr or IP/mask
#This needs to be completed
}
Close file.
Make the file “virtual-server/help/spf_ip6.html” and open it paste
This field is similar to Allowed sender hostnames, but is for entering
IP addresses of systems that also send email from this domain, and do not
have hostnames.
Close file
Open “virtual-server/modify-dns.pl”
go to line 80
you should see
elsif ($a =~ /^--spf-add-(a|mx|ip4)$/) {
$add = shift(@ARGV);
$type = $1;
$add =~ /^[a-z0-9\.\-\_]+$/ ||
&usage("$a must be followed by a hostname or IP address");
push(@{$add{$type}}, $add);
}
elsif ($a =~ /^--spf-remove-(a|mx|ip4)$/) {
$rem = shift(@ARGV);
$type = $1;
$rem =~ /^[a-z0-9\.\-\_]+$/ ||
&usage("$a must be followed by a hostname or IP address");
push(@{$rem{$type}}, $rem);
}
change this to
elsif ($a =~ /^--spf-add-(a|mx|ip4|ip6)$/) {
$add = shift(@ARGV);
$type = $1;
$add =~ /^[a-z0-9\.\-\_]+$/ ||
&usage("$a must be followed by a hostname or IP address");
push(@{$add{$type}}, $add);
}
elsif ($a =~ /^--spf-remove-(a|mx|ip4|ip6)$/) {
$rem = shift(@ARGV);
$type = $1;
$rem =~ /^[a-z0-9\.\-\_]+$/ ||
&usage("$a must be followed by a hostname or IP address");
push(@{$rem{$type}}, $rem);
}
I think that’s all I changed.
Now when you look at the DNS Options you should see a section for IPv6 address’s.
Also you can now use modify-dns.pl to add ip6 SPF records.
Example
virtual-server/modify-dns.pl --all-domains --spf-add-ip6 2a90:490:190:4fff::ffff