mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Bring back static routes to fix issues reported on Ticext #3179
This commit is contained in:
parent
243680e54d
commit
32a9eb1873
@ -384,14 +384,16 @@ function convert_config() {
|
||||
|
||||
/* special case upgrades */
|
||||
/* fix every minute crontab bogons entry */
|
||||
$cron_item_count = count($config['cron']['item']);
|
||||
for($x=0; $x<$cron_item_count; $x++) {
|
||||
if(stristr($config['cron']['item'][$x]['command'], "rc.update_bogons.sh")) {
|
||||
if($config['cron']['item'][$x]['hour'] == "*" ) {
|
||||
$config['cron']['item'][$x]['hour'] = "3";
|
||||
write_config(gettext("Updated bogon update frequency to 3am"));
|
||||
log_error(gettext("Updated bogon update frequency to 3am"));
|
||||
}
|
||||
if (is_array($config['cron'])) {
|
||||
$cron_item_count = count($config['cron']['item']);
|
||||
for($x=0; $x<$cron_item_count; $x++) {
|
||||
if(stristr($config['cron']['item'][$x]['command'], "rc.update_bogons.sh")) {
|
||||
if($config['cron']['item'][$x]['hour'] == "*" ) {
|
||||
$config['cron']['item'][$x]['hour'] = "3";
|
||||
write_config(gettext("Updated bogon update frequency to 3am"));
|
||||
log_error(gettext("Updated bogon update frequency to 3am"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($config['version'] == $g['latest_config'])
|
||||
|
||||
@ -162,6 +162,18 @@ EOD;
|
||||
$gwifip = find_interface_ip($gateway['interface'], true);
|
||||
if (!is_ipaddrv4($gwifip))
|
||||
continue; //Skip this target
|
||||
|
||||
/*
|
||||
* If the gateway is the same as the monitor we do not add a
|
||||
* route as this will break the routing table.
|
||||
* Add static routes for each gateway with their monitor IP
|
||||
* not strictly necessary but is a added level of protection.
|
||||
*/
|
||||
if (is_ipaddrv4($gateway['gateway']) && $gateway['monitor'] != $gateway['gateway']) {
|
||||
log_error("Removing static route for monitor {$gateway['monitor']} and adding a new route through {$gateway['gateway']}");
|
||||
mwexec("/sbin/route change -host " . escapeshellarg($gateway['monitor']) .
|
||||
" " . escapeshellarg($gateway['gateway']), true);
|
||||
}
|
||||
} else if (is_ipaddrv6($gateway['gateway'])) {
|
||||
/* link locals really need a different src ip */
|
||||
if(is_linklocal($gateway['gateway'])) {
|
||||
@ -173,6 +185,18 @@ EOD;
|
||||
$gateway['monitor'] .= "%{$gateway['interface']}";
|
||||
if (!is_ipaddrv6($gwifip))
|
||||
continue; //Skip this target
|
||||
|
||||
/*
|
||||
* If the gateway is the same as the monitor we do not add a
|
||||
* route as this will break the routing table.
|
||||
* Add static routes for each gateway with their monitor IP
|
||||
* not strictly necessary but is a added level of protection.
|
||||
*/
|
||||
if (is_ipaddrv6($gateway['gateway']) && $gateway['monitor'] != $gateway['gateway']) {
|
||||
log_error("Removing static route for monitor {$gateway['monitor']} and adding a new route through {$gateway['gateway']}");
|
||||
mwexec("/sbin/route change -host -inet6 " . escapeshellarg($gateway['monitor']) .
|
||||
" " . escapeshellarg($gateway['gateway']), true);
|
||||
}
|
||||
} else
|
||||
continue;
|
||||
|
||||
|
||||
@ -104,6 +104,15 @@ if ($_GET['act'] == "del") {
|
||||
}
|
||||
}
|
||||
if ($remove == true) {
|
||||
/* NOTE: Cleanup static routes for the monitor ip if any */
|
||||
if (!empty($a_gateways[$_GET['id']]['monitor']) && $a_gateways[$_GET['id']]['monitor'] != "dynamic" && is_ipaddr($a_gateways[$_GET['id']]['monitor']) &&
|
||||
$a_gateways[$_GET['id']]['monitor'] != $a_gateways[$_GET['id']]['monitor'] && $a_gateways[$_GET['id']]['gateway'] != $a_gateways[$_GET['id']]['monitor']) {
|
||||
if (is_ipaddrv4($a_gateways[$_GET['id']]['monitor']))
|
||||
mwexec("/sbin/route delete " . escapeshellarg($a_gateways[$_GET['id']]['monitor']));
|
||||
else
|
||||
mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateways[$_GET['id']]['monitor']));
|
||||
}
|
||||
|
||||
if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
|
||||
unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
|
||||
$changedesc .= "removed gateway {$realid}";
|
||||
|
||||
@ -384,8 +384,17 @@ if ($_POST) {
|
||||
$gateway['descr'] = $_POST['descr'];
|
||||
if ($_POST['monitor_disable'] == "yes")
|
||||
$gateway['monitor_disable'] = true;
|
||||
else if (is_ipaddr($_POST['monitor']))
|
||||
else if (is_ipaddr($_POST['monitor'])) {
|
||||
/* NOTE: If monitor ip is changed need to cleanup the old static route */
|
||||
if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$id]) && is_ipaddr($a_gateway_item[$id]['monitor']) &&
|
||||
$_POST['monitor'] != $a_gateway_item[$id]['monitor'] && $gateway['gateway'] != $a_gateway_item[$id]['monitor']) {
|
||||
if (is_ipaddrv4($a_gateway_item[$id]['monitor']))
|
||||
mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$id]['monitor']));
|
||||
else
|
||||
mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$id]['monitor']));
|
||||
}
|
||||
$gateway['monitor'] = $_POST['monitor'];
|
||||
}
|
||||
|
||||
if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
|
||||
$i = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user