Add a knob to prefer IPv4 over IPv6, it fixes #2833

This commit is contained in:
Renato Botelho 2013-12-06 11:39:29 -02:00
parent 09e14acf5b
commit 77a341a458
3 changed files with 33 additions and 0 deletions

View File

@ -2064,4 +2064,14 @@ function get_current_theme() {
return $theme;
}
/* Define what is preferred, IPv4 or IPv6 */
function prefer_ipv4_or_ipv6() {
global $config;
if (isset($config['system']['prefer_ipv4']))
mwexec("/etc/rc.d/ip6addrctl prefer_ipv4");
else
mwexec("/etc/rc.d/ip6addrctl prefer_ipv6");
}
?>

View File

@ -409,6 +409,9 @@ upnp_start();
/* If powerd is enabled, lets launch it */
activate_powerd();
/* Set preferred protocol */
prefer_ipv4_or_ipv6();
/* Remove the old shutdown binary if we kept it. */
if (file_exists("/sbin/shutdown.old"))
@unlink("/sbin/shutdown.old");

View File

@ -51,6 +51,7 @@ require_once("shaper.inc");
$pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']);
$pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr'];
$pconfig['ipv6allow'] = isset($config['system']['ipv6allow']);
$pconfig['prefer_ipv4'] = isset($config['system']['prefer_ipv4']);
$pconfig['polling_enable'] = isset($config['system']['polling']);
$pconfig['sharednet'] = $config['system']['sharednet'];
$pconfig['disablechecksumoffloading'] = isset($config['system']['disablechecksumoffloading']);
@ -88,6 +89,12 @@ if ($_POST) {
unset($config['system']['ipv6allow']);
}
if($_POST['prefer_ipv4'] == "yes") {
$config['system']['prefer_ipv4'] = true;
} else {
unset($config['system']['prefer_ipv4']);
}
if($_POST['sharednet'] == "yes") {
$config['system']['sharednet'] = true;
system_disable_arp_wrong_if();
@ -136,6 +143,9 @@ if ($_POST) {
// Configure flowtable support from filter.inc
flowtable_configure();
// Set preferred protocol
prefer_ipv4_or_ipv6();
$retval = filter_configure();
if(stristr($retval, "error") <> true)
$savemsg = get_std_save_message(gettext($retval));
@ -227,6 +237,16 @@ function enable_change(enable_over) {
<input name="ipv6nat_ipaddr" type="text" class="formfld unknown" id="ipv6nat_ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipv6nat_ipaddr']);?>" />
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Prefer IPv4 over IPv6"); ?></td>
<td width="78%" class="vtable">
<input name="prefer_ipv4" type="checkbox" id="prefer_ipv4" value="yes" <?php if ($pconfig['prefer_ipv4']) echo "checked=\"checked\""; ?> />
<strong><?=gettext("Prefer to use IPv4 even if IPv6 is available"); ?></strong><br/>
<?=gettext("By default, if a hostname resolves IPv6 and IPv4 addresses ".
"IPv6 will be used, if you check this option, IPv4 will be " .
"used instead of IPv6."); ?><br />
</td>
</tr>
<tr>
<td colspan="2" class="list" height="12">&nbsp;</td>
</tr>