Compare commits
2 Commits
7e4d2c0967
...
2797079ecf
| Author | SHA1 | Date | |
|---|---|---|---|
| 2797079ecf | |||
| 56310f654b |
@@ -2,6 +2,7 @@
|
||||
<?php
|
||||
|
||||
require_once("config.inc");
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("util.inc");
|
||||
require_once("filter.inc");
|
||||
@@ -104,8 +105,10 @@ if ($carpStatus == "MASTER") {
|
||||
$config['interfaces'][$wanInterface]['ipaddr'] = 'dhcp';
|
||||
$config['interfaces'][$wanInterface]['subnet'] = '';
|
||||
$config['interfaces'][$wanInterface]['gateway'] = '';
|
||||
echo_write_log("Loopiong through gateways to remove the static WAN gateway...");
|
||||
foreach ($config['gateways']['gateway_item'] as $i => $gateway) {
|
||||
if ($gateway['name'] == $gatewayName) {
|
||||
echo_write_log("Removing the static WAN gateway: ". $gateway['name']);
|
||||
unset($config['gateways']['gateway_item'][$i]);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +132,6 @@ if ($carpStatus == "MASTER") {
|
||||
}
|
||||
|
||||
$wanInfo = null;
|
||||
|
||||
foreach ($iflist as $ifname => $ifcfg) {
|
||||
$class = null;
|
||||
|
||||
@@ -165,6 +167,7 @@ if ($carpStatus == "MASTER") {
|
||||
$config['interfaces'][$wanInterface]['gateway'] = $gatewayName;
|
||||
|
||||
# setup gateway
|
||||
echo_write_log("Adding static WAN gateway");
|
||||
$gwCount = count($config['gateways']['gateway_item']);
|
||||
$config['gateways']['gateway_item'][$gwCount]['gateway'] = $gatewayIP;
|
||||
$config['gateways']['gateway_item'][$gwCount]['interface'] = $wanInterface;
|
||||
@@ -174,16 +177,61 @@ if ($carpStatus == "MASTER") {
|
||||
$config['gateways']['gateway_item'][$gwCount]['defaultgw'] = 1;
|
||||
$config['gateways']['gateway_item'][$gwCount]['fargw'] = 1;
|
||||
|
||||
# Loop through outbound nat and update the wan ip
|
||||
# Loop through outbound NAT and update the wan ip
|
||||
echo_write_log("Loopiong through NAT outbound connections...");
|
||||
$interface_names= array();
|
||||
// add this hosts ips
|
||||
foreach ($config['interfaces'] as $intf => $intfdata) {
|
||||
if (isset($intfdata['ipaddr']) && $intfdata['ipaddr'] != 'dhcp') {
|
||||
$interface_names[$intfdata['ipaddr']] = sprintf(gettext('%s address'), !empty($intfdata['descr']) ? $intfdata['descr'] : $intf );
|
||||
}
|
||||
}
|
||||
foreach ($config['nat']['outbound']['rule'] as $i => $rule) {
|
||||
if ($rule['interface'] == $wanInterface ) {
|
||||
# NAT Source
|
||||
if (isset($rule['source']['network']) && is_alias($rule['source']['network'])) {
|
||||
$natSource = get_alias_description($natent['source']['network']);
|
||||
} elseif (is_specialnet($rule['source']['network'])) {
|
||||
$natSource = get_specialnets()[$rule['source']['network']];
|
||||
} else {
|
||||
$natSource = $rule['source']['network'] == "(self)" ? gettext("This Firewall") : $rule['source']['network'];
|
||||
}# NAT Address
|
||||
if (isset($rule['nonat'])) {
|
||||
$nat_address = '<I>NO NAT</I>';
|
||||
} elseif (empty($rule['target'])) {
|
||||
$nat_address = gettext("Interface address");
|
||||
} elseif (is_specialnet($rule['target'])) {
|
||||
$nat_address = htmlspecialchars(get_specialnets()[$rule['target']]);
|
||||
} elseif ($rule['target'] == "other-subnet") {
|
||||
$nat_address = $rule['targetip'] . '/' . $rule['targetip_subnet'];
|
||||
} else {
|
||||
$nat_address = htmlspecialchars($rule['target']);
|
||||
}
|
||||
# NAT Target
|
||||
if (isset($rule['target']) && is_alias($rule['target'])) {
|
||||
$natTarget = get_alias_description($rule['target']);
|
||||
} elseif (!empty($interface_names[$nat_address])){
|
||||
$natTarget = $interface_names[$nat_address];
|
||||
} else {
|
||||
$natTarget = $nat_address;
|
||||
}
|
||||
echo_write_log("Found NAT rule on the WAN interface");
|
||||
echo_write_log("Source: " . $natSource);
|
||||
echo_write_log("Description: " . $rule['descr']);
|
||||
echo_write_log("Current NAT rule target: " . $natTarget);
|
||||
echo_write_log("Setting NAT rule target to: " . $wanIP);
|
||||
$config['nat']['outbound']['rule'][$i]['target'] = $wanIP;
|
||||
}
|
||||
}
|
||||
|
||||
# loop through CARP addresses and update the wan ip address
|
||||
echo_write_log("Loopiong through VIP interfaces...");
|
||||
foreach ($config['virtualip']['vip'] as $i => $vip) {
|
||||
if ($vip['interface'] == $wanInterface) {
|
||||
echo_write_log("Updating VIP CARP WAN interface: ". $vip['interface']);
|
||||
echo_write_log("Updating VIP CARP WAN interface IP: ". $wanIP);
|
||||
echo_write_log("Updating VIP CARP WAN interface Subnit Bits: ". $wanSubnet);
|
||||
echo_write_log("Updating VIP CARP WAN interface Description: VIP WAN (GW: $gatewayIP)");
|
||||
$config['virtualip']['vip'][$i]['subnet_bits'] = $wanSubnet;
|
||||
$config['virtualip']['vip'][$i]['subnet'] = $wanIP;
|
||||
$config['virtualip']['vip'][$i]['descr'] = "VIP WAN (GW: $gatewayIP)";
|
||||
|
||||
Reference in New Issue
Block a user