diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-02-20 16:50:54 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-02-20 16:50:54 -0300 |
commit | 9a15b8d2e9590cd3062abeb1c14903b465859cc7 (patch) | |
tree | 19038f4d616aebd02a662cb9b3c17819eee6821a /etc/rc.initial.setlanip | |
parent | b82e46967a74c41620ce7025a81df3bff76b3d76 (diff) | |
download | pfsense-9a15b8d2e9590cd3062abeb1c14903b465859cc7.zip pfsense-9a15b8d2e9590cd3062abeb1c14903b465859cc7.tar.gz |
Fix issues on "Set interface(s) IP address" option
- Avoid duplicate gateway entries
- Fix checking if a default gw already exists
- Set IPv6 to none when user choose it
- Set gateway on interface
Diffstat (limited to 'etc/rc.initial.setlanip')
-rwxr-xr-x | etc/rc.initial.setlanip | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip index 6bebf86..5b60132 100755 --- a/etc/rc.initial.setlanip +++ b/etc/rc.initial.setlanip @@ -197,28 +197,35 @@ function add_gateway_to_config($interface, $gatewayip, $inet_type) { if ($dry_run) { print_r($a_gateways); } - $new_name = next_unused_gateway_name($interface); + $new_name = ''; $is_default = true; foreach ($a_gateways as $item) { if ($item['ipprotocol'] === $inet_type) { - $is_default = false; - break; + if (isset($item['defaultgw'])) + $is_default = false; + if (($item['interface'] === $interface) && ($item['gateway'] === $gatewayip)) + $new_name = $item['name']; } } - $item = array( - "interface" => $interface, - "gateway" => $gatewayip, - "name" => $new_name, - "weight" => 1, - "ipprotocol" => $inet_type, - "interval" => true, - "descr" => "Interface $interface Gateway", - "defaultgw" => $is_default - ); - if ($dry_run) { - print_r($item); + if ($new_name == '') { + $new_name = next_unused_gateway_name($interface); + $item = array( + "interface" => $interface, + "gateway" => $gatewayip, + "name" => $new_name, + "weight" => 1, + "ipprotocol" => $inet_type, + "interval" => true, + "descr" => "Interface $interface Gateway", + "defaultgw" => $is_default + ); + if ($dry_run) { + print_r($item); + } + $a_gateways[] = $item; } - $a_gateways[] = $item; + + return $new_name; } function console_configure_ip_address($version) { @@ -296,7 +303,7 @@ function console_configure_ip_address($version) { if ($gwip != '') { $inet_type = ($version === 6) ? "inet6" : "inet"; - add_gateway_to_config($interface, $gwip, $inet_type); + $gwname = add_gateway_to_config($interface, $gwip, $inet_type); } } $ifppp = console_get_interface_from_ppp(get_real_interface($interface)); @@ -304,21 +311,21 @@ function console_configure_ip_address($version) { $ifaceassigned = $ifppp; } - return array($intip, $intbits, $gwip); + return array($intip, $intbits, $gwname); } -list($intip, $intbits, $gwip) = console_configure_ip_address(4); -list($intip6, $intbits6, $gwip6) = console_configure_ip_address(6); +list($intip, $intbits, $gwname) = console_configure_ip_address(4); +list($intip6, $intbits6, $gwname6) = console_configure_ip_address(6); if (!empty($ifaceassigned)) $config['interfaces'][$interface]['if'] = $ifaceassigned; -$config['interfaces'][$interface]['ipaddr'] = $intip; -$config['interfaces'][$interface]['subnet'] = $intbits; -if ($intip6) { - $config['interfaces'][$interface]['ipaddrv6'] = $intip6; - $config['interfaces'][$interface]['subnetv6'] = $intbits6; -} -$config['interfaces'][$interface]['enable'] = true; +$config['interfaces'][$interface]['ipaddr'] = $intip; +$config['interfaces'][$interface]['subnet'] = $intbits; +$config['interfaces'][$interface]['gateway'] = $gwname; +$config['interfaces'][$interface]['ipaddrv6'] = $intip6; +$config['interfaces'][$interface]['subnetv6'] = $intbits6; +$config['interfaces'][$interface]['gatewayv6'] = $gwname6; +$config['interfaces'][$interface]['enable'] = true; function console_configure_dhcpd($version = 4) { global $g, $config, $restart_dhcpd, $fp, $interface, $dry_run; |