Пример #1
0
function find_ip_interface($ip, $bits = null)
{
    if (!is_ipaddr($ip)) {
        return false;
    }
    $isv6ip = is_ipaddrv6($ip);
    /* if list */
    $ifdescrs = get_configured_interface_list();
    foreach ($ifdescrs as $ifdescr => $ifname) {
        $ifip = $isv6ip ? get_interface_ipv6($ifname) : get_interface_ip($ifname);
        if (is_null($ifip)) {
            continue;
        }
        if (is_null($bits)) {
            if ($ip == $ifip) {
                $int = get_real_interface($ifname);
                return $int;
            }
        } else {
            if (ip_in_subnet($ifip, $ip . "/" . $bits)) {
                $int = get_real_interface($ifname);
                return $int;
            }
        }
    }
    return false;
}
Пример #2
0
     }
 }
 if ($a_vip[$_GET['id']]['mode'] == "ipalias") {
     $subnet = gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']) . "/" . $a_vip[$_GET['id']]['subnet_bits'];
     $found_if = false;
     $found_carp = false;
     $found_other_alias = false;
     if ($subnet == $if_subnet) {
         $found_if = true;
     }
     $vipiface = $a_vip[$_GET['id']]['interface'];
     foreach ($a_vip as $vip_id => $vip) {
         if ($vip_id == $_GET['id']) {
             continue;
         }
         if ($vip['interface'] == $vipiface && ip_in_subnet($vip['subnet'], $subnet)) {
             if ($vip['mode'] == "carp") {
                 $found_carp = true;
             } else {
                 if ($vip['mode'] == "ipalias") {
                     $found_other_alias = true;
                 }
             }
         }
     }
     if ($found_carp === true && $found_other_alias === false && $found_if === false) {
         $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by a CARP IP with the description") . " {$vip['descr']}.";
     }
 }
 if (!$input_errors) {
     if (session_status() == PHP_SESSION_NONE) {
Пример #3
0
 } else {
     $pconfig = $_POST;
     unset($input_errors);
     if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) {
         if ($pconfig['port'] == $config['dnsmasq']['port']) {
             $input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder.");
         }
     }
     // forwarding mode requires having valid DNS servers
     if (isset($pconfig['forwarding'])) {
         $founddns = false;
         if (isset($config['system']['dnsallowoverride'])) {
             $dns_servers = get_dns_servers();
             if (is_array($dns_servers)) {
                 foreach ($dns_servers as $dns_server) {
                     if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
                         $founddns = true;
                     }
                 }
             }
         }
         if (is_array($config['system']['dnsserver'])) {
             foreach ($config['system']['dnsserver'] as $dnsserver) {
                 if (is_ipaddr($dnsserver)) {
                     $founddns = true;
                 }
             }
         }
         if ($founddns == false) {
             $input_errors[] = gettext("At least one DNS server must be specified under System>General Setup to enable Forwarding mode.");
         }
Пример #4
0
             if (empty($parent_ip) || empty($parent_sn)) {
                 $input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
             } elseif (!isset($_POST["nonlocalgateway"])) {
                 $subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
                 $vips = link_interface_to_vips($_POST['interface']);
                 if (is_array($vips)) {
                     foreach ($vips as $vip) {
                         if (!is_ipaddrv6($vip['subnet'])) {
                             continue;
                         }
                         $subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
                     }
                 }
                 $found = false;
                 foreach ($subnets as $subnet) {
                     if (ip_in_subnet($_POST['gateway'], $subnet)) {
                         $found = true;
                         break;
                     }
                 }
                 if ($found === false) {
                     $input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
                 }
             }
         }
     }
 }
 if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
     if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic")) {
         $input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
     }
Пример #5
0
                        }
                    }
                }
            }
        }
    }
}
$_grb = exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 {$sort_method} {$ratesubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", \$1,  \$2,  \$4,  \$6,  \$8 }'", $listedIPs);
$someinfo = false;
for ($x = 2; $x < 12; $x++) {
    $bandwidthinfo = $listedIPs[$x];
    // echo $bandwidthinfo;
    $emptyinfocounter = 1;
    if ($bandwidthinfo != "") {
        $infoarray = explode(":", $bandwidthinfo);
        if ($filter == "all" || $filter == "local" && ip_in_subnet($infoarray[0], $intsubnet) || $filter == "remote" && !ip_in_subnet($infoarray[0], $intsubnet)) {
            if ($hostipformat == "") {
                // pass back just the raw IP address
                $addrdata = $infoarray[0];
            } else {
                // $hostipformat is one of "hostname", "descr" or "fqdn" - we want a text representation if we can get it.
                if ($iplookup[$infoarray[0]] != "") {
                    // We have a local entry, so use it.
                    $addrdata = $iplookup[$infoarray[0]];
                } else {
                    // Try to reverse lookup the IP address.
                    $addrdata = gethostbyaddr($infoarray[0]);
                    if ($addrdata != $infoarray[0]) {
                        // Reverse lookup returned something other than the IP address (FQDN, we hope!)
                        if ($hostipformat != "fqdn") {
                            // The user does not want the whole FQDN, so only pass back the first part of the name.
Пример #6
0
         if (empty($parent_ip) || empty($parent_sn)) {
             $input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
         } else {
             $subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
             $vips = link_interface_to_vips($pconfig['interface']);
             if (is_array($vips)) {
                 foreach ($vips as $vip) {
                     if (!is_ipaddrv6($vip['subnet'])) {
                         continue;
                     }
                     $subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
                 }
             }
             $found = false;
             foreach ($subnets as $subnet) {
                 if (ip_in_subnet($pconfig['gateway'], $subnet)) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $pconfig['gateway']);
             }
         }
     }
 }
 if (!empty($config['interfaces'][$pconfig['interface']]['ipaddr'])) {
     if (is_ipaddr($config['interfaces'][$pconfig['interface']]['ipaddr']) && (empty($pconfig['gateway']) || $pconfig['gateway'] == "dynamic")) {
         $input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
     }
 }
     // Input validation
     $reqdfields = explode(" ", "startadr endadr leasecount");
     $reqdfieldsn = array(gettext("DHCP range - start"), gettext("DHCP range - end"), gettext("How leases allow"));
     $reqdfieldst = explode(" ", "ipaddr ipaddr numeric");
     do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
     do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors);
     $subnet = $config['interfaces']['lan']['ipaddr'] . "/" . $config['interfaces']['lan']['subnet'];
     if (is_ipaddr($_POST['startadr'])) {
         if (false == ($cnif = ip_in_subnet($_POST['startadr'], $subnet))) {
             $input_errors[] = "Value \"DHCP range - start\" is not belongs to the subnet LAN";
             goto out;
         } else {
         }
     }
     if (is_ipaddr($_POST['endadr'])) {
         if (false == ($cnif = ip_in_subnet($_POST['endadr'], $subnet))) {
             $input_errors[] = "Value \"DHCP range - end\" is not belongs to the subnet LAN";
             goto out;
         } else {
         }
     }
 }
 if (empty($input_errors)) {
     if (isset($_POST['startadr']) && $_POST['endadr']) {
         $config['dnsmasq']['startadr'] = $_POST['startadr'];
         $config['dnsmasq']['endadr'] = $_POST['endadr'];
         $config['dnsmasq']['leasecount'] = $_POST['leasecount'];
     } else {
     }
     if (isset($_POST['enabletftp'])) {
         $config['dnsmasq']['enabletftp'] = TRUE;
Пример #8
0
         }
         foreach ($staticroutes as $route_subnet) {
             list($network, $subnet) = explode("/", $route_subnet);
             if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
                 $input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
                 break;
             }
             unset($network, $subnet);
         }
     }
 }
 if ($_POST['ipaddrv6']) {
     if (!is_ipaddrv6($_POST['ipaddrv6'])) {
         $input_errors[] = gettext("A valid IPv6 address must be specified.");
     } else {
         if (ip_in_subnet($_POST['ipaddrv6'], "fe80::/10")) {
             $input_errors[] = gettext("IPv6 link local addresses cannot be configured as an interface IP.");
         }
         $where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
         if (count($where_ipaddr_configured)) {
             $subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
             foreach ($where_ipaddr_configured as $subnet_conflict) {
                 $subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
             }
             $input_errors[] = $subnet_conflict_text;
         }
         foreach ($staticroutes as $route_subnet) {
             list($network, $subnet) = explode("/", $route_subnet);
             if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
                 $input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
                 break;
     $input_errors[] = "Geçerli bir aralıkta tanımlanmalıdır.";
 }
 if ($_POST['range_to'] && !is_ipaddr($_POST['range_to'])) {
     $input_errors[] = "Geçerli bir aralıkta tanımlanmalıdır.";
 }
 if ($_POST['gateway'] && !is_ipaddr($_POST['gateway'])) {
     $input_errors[] = "Geçerli bir IP gateway IP adresi tanımlanmaldır.";
 }
 /* make sure the range lies within the bridged subnet */
 if ($_POST['bridge']) {
     if ($_POST['method'] == "ovpn") {
         $ipaddr = $config['interfaces'][$_POST['bridge']]['ipaddr'];
         $subnet = $config['interfaces'][$_POST['bridge']]['subnet'];
         $subnet_start = ip2long($ipaddr) & gen_subnet_mask_long($subnet);
         $subnet_end = ip2long($ipaddr) | ~gen_subnet_mask_long($subnet);
         if (!ip_in_subnet($_POST['gateway'], gen_subnet($ipaddr, $subnet) . "/" . $subnet)) {
             $input_errors[] = "The specified gateway lies outside of the bridged subnet.";
         }
         if (ip2long($_POST['range_from']) < $subnet_start || ip2long($_POST['range_from']) > $subnet_end || ip2long($_POST['range_to']) < $subnet_start || ip2long($_POST['range_to']) > $subnet_end) {
             $input_errors[] = "The specified range lies outside of the bridged subnet.";
         }
         if (ip2long($_POST['range_from']) > ip2long($_POST['range_to'])) {
             $input_errors[] = "The range is invalid (first element higher than second element).";
         }
     }
 }
 /* valid Port */
 if (empty($_POST['port'])) {
     $input_errors[] = "You must provide a server in between 1 and 65535.";
 } else {
     if (!is_port($_POST['port'])) {
Пример #10
0
 /* make sure no inbound NAT mappings reference this entry */
 if (is_array($config['nat']['rule'])) {
     foreach ($config['nat']['rule'] as $rule) {
         if ($rule['destination']['address'] != "") {
             if ($rule['destination']['address'] == $a_vip[$_GET['id']]['subnet']) {
                 $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one NAT mapping.");
                 break;
             }
         }
     }
 }
 if ($a_vip[$_GET['id']]['mode'] == "ipalias") {
     $vipiface = $a_vip[$_GET['id']]['interface'];
     foreach ($a_vip as $vip) {
         if ($vip['interface'] == $vipiface && $vip['mode'] == "carp") {
             if (ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']) . "/" . $a_vip[$_GET['id']]['subnet_bits'])) {
                 $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by CARP") . " {$vip['descr']}.";
             }
         }
     }
 } else {
     if ($a_vip[$_GET['id']]['mode'] == "carp") {
         $vipiface = "{$a_vip[$_GET['id']]['interface']}_vip{$a_vip[$_GET['id']]['vhid']}";
         foreach ($a_vip as $vip) {
             if ($vipiface == $vip['interface'] && $vip['mode'] == "ipalias") {
                 $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by ip alias entry") . " {$vip['descr']}.";
             }
         }
     }
 }
 if (!$input_errors) {
Пример #11
0
/**
 * delete virtual ip
 */
function deleteVIPEntry($id)
{
    global $config;
    $input_errors = array();
    $a_vip =& $config['virtualip']['vip'];
    /* make sure no inbound NAT mappings reference this entry */
    if (isset($config['nat']['rule'])) {
        foreach ($config['nat']['rule'] as $rule) {
            if (!empty($rule['destination']['address'])) {
                if ($rule['destination']['address'] == $a_vip[$id]['subnet']) {
                    $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one NAT mapping.");
                    break;
                }
            }
        }
    }
    if (is_ipaddrv6($a_vip[$id]['subnet'])) {
        $is_ipv6 = true;
        $subnet = gen_subnetv6($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
        $if_subnet_bits = get_interface_subnetv6($a_vip[$id]['interface']);
        $if_subnet = gen_subnetv6(get_interface_ipv6($a_vip[$id]['interface']), $if_subnet_bits);
    } else {
        $is_ipv6 = false;
        $subnet = gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
        $if_subnet_bits = get_interface_subnet($a_vip[$id]['interface']);
        $if_subnet = gen_subnet(get_interface_ip($a_vip[$id]['interface']), $if_subnet_bits);
    }
    $subnet .= "/" . $a_vip[$id]['subnet_bits'];
    $if_subnet .= "/" . $if_subnet_bits;
    if (isset($config['gateways']['gateway_item'])) {
        foreach ($config['gateways']['gateway_item'] as $gateway) {
            if ($a_vip[$id]['interface'] != $gateway['interface']) {
                continue;
            }
            if ($is_ipv6 && $gateway['ipprotocol'] == 'inet') {
                continue;
            }
            if (!$is_ipv6 && $gateway['ipprotocol'] == 'inet6') {
                continue;
            }
            if (ip_in_subnet($gateway['gateway'], $if_subnet)) {
                continue;
            }
            if (ip_in_subnet($gateway['gateway'], $subnet)) {
                $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one Gateway.");
                break;
            }
        }
    }
    if ($a_vip[$id]['mode'] == "ipalias") {
        $subnet = gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']) . "/" . $a_vip[$id]['subnet_bits'];
        $found_if = false;
        $found_carp = false;
        $found_other_alias = false;
        if ($subnet == $if_subnet) {
            $found_if = true;
        }
        $vipiface = $a_vip[$id]['interface'];
        foreach ($a_vip as $vip_id => $vip) {
            if ($vip_id != $id) {
                if ($vip['interface'] == $vipiface && ip_in_subnet($vip['subnet'], $subnet)) {
                    if ($vip['mode'] == "carp") {
                        $found_carp = true;
                    } else {
                        if ($vip['mode'] == "ipalias") {
                            $found_other_alias = true;
                        }
                    }
                }
            }
        }
        if ($found_carp === true && $found_other_alias === false && $found_if === false) {
            $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by a CARP IP with the description") . " {$vip['descr']}.";
        }
    }
    if (count($input_errors) == 0) {
        // Special case since every proxyarp vip is handled by the same daemon.
        if ($a_vip[$id]['mode'] == "proxyarp") {
            $viface = $a_vip[$id]['interface'];
            unset($a_vip[$id]);
            interface_proxyarp_configure($viface);
        } else {
            interface_vip_bring_down($a_vip[$id]);
            unset($a_vip[$id]);
        }
        if (count($config['virtualip']['vip']) == 0) {
            unset($config['virtualip']['vip']);
        }
    }
    return $input_errors;
}
     if ($_POST['mode'] == "new") {
         if (is_macaddr($_POST['macaddr'])) {
             if (is_array($a_hosts)) {
                 $index = array_search_ex($_POST['macaddr'], $a_hosts, "macaddr");
                 if (FALSE !== ($index = array_search_ex($_POST['macaddr'], $a_hosts, "macaddr"))) {
                     $input_errors[] = "MAC adress exist. It must be unique";
                     goto out;
                 } else {
                 }
             } else {
             }
         }
     }
     $subnet = $config['interfaces']['lan']['ipaddr'] . "/" . $config['interfaces']['lan']['subnet'];
     if (is_ipaddr($_POST['ipadress'])) {
         if (false == ($cnif = ip_in_subnet($_POST['ipadress'], $subnet))) {
             $input_errors[] = "Value \"IP address\" is not belongs to the subnet LAN";
             goto out;
         } else {
         }
     }
 } elseif (empty($_POST['macaddr']) && empty($_POST['ipadress']) && !empty($_POST['hostname'])) {
     if (FALSE == is_hostname($_POST['hostname'])) {
         $input_errors[] = "Wrong Host name.";
         goto out;
     } else {
         $pconfig['leasetime'] = "60";
         $nas4frehosts =& $config['system']['hosts'];
         if (false !== ($cnin = array_search_ex($_POST['hostname'], $nas4frehosts, "name"))) {
             $warning_mess = "Host defined on <a href=system_hosts.php>/etc/hosts</a>";
         } else {
     }
     $reqdfields = explode(" ", "server");
     $reqdfieldsn = explode(",", "Hedef Sunucu");
     do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
     if ($_POST['server'] && !is_ipaddr($_POST['server'])) {
         $input_errors[] = "Geçerli bir hedef IP adresi tanımlanmalıdır.";
     }
     if (!$input_errors) {
         /* make sure that the DHCP server isn't enabled on this interface */
         if (isset($config['dhcpd'][$if]['enable'])) {
             $input_errors[] = "You must disable the DHCP server on the {$iflist[$if]} interface before enabling the DHCP Relay.";
         }
         /* make sure that the DHCP server isn't running on any of the implied interfaces */
         foreach ($config['interfaces'] as $ifname => $ifcfg) {
             $subnet = $ifcfg['ipaddr'] . "/" . $ifcfg['subnet'];
             if (ip_in_subnet($_POST['server'], $subnet)) {
                 $destif = $ifname;
             }
         }
         if (!isset($destif)) {
             $destif = "wan";
         }
         if (isset($config['dhcpd'][$destif]['enable'])) {
             $input_errors[] = "You must disable the DHCP server on the {$destif} interface before enabling the DHCP Relay.";
         }
         /* if proxydhcp is selected, make sure DHCP is enabled on WAN */
         if (isset($config['dhcrelay']['proxydhcp']) && $config['interfaces']['wan']['ipaddr'] != "dhcp") {
             $input_errors[] = "You must have DHCP active on the WAN interface before enabling the DHCP proxy option.";
         }
     }
 }
         }
     }
     if ($_POST['password'] == "") {
         $input_errors[] = "VHID üyeleri arasında bir şifre paylaşımı tanımı yapılmalıdır.";
     }
     $can_post = true;
     $found = false;
     $subnet_ip = return_first_two_octets($_POST['subnet']);
     $iflist = array("lan", "wan");
     for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
         $iflist['opt' . $i] = 'opt' . $i;
     }
     foreach ($iflist as $if) {
         $ww_subnet_ip = $config['interfaces'][$if]['ipaddr'];
         $ww_subnet_bits = $config['interfaces'][$if]['subnet'];
         if (ip_in_subnet($_POST['subnet'], gen_subnet($ww_subnet_ip, $ww_subnet_bits) . "/" . $ww_subnet_bits)) {
             $found = true;
         }
     }
     if ($found == false) {
         $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'];
         $can_post = false;
     }
     if ($can_post == false) {
         $input_errors[] = " (\$ cannot_find) için eşleşen bir alt ağ ile arayüz bulunamadı. Lütfen bu alt için gerçek bir arabirime bir IP ekleyin.";
     }
 }
 if (!$input_errors) {
     $vipent = array();
     $vipent['mode'] = $_POST['mode'];
     $vipent['interface'] = $_POST['interface'];
Пример #15
0
     }
     break;
 case 'ipalias':
     if (strstr($_POST['interface'], "_vip")) {
         if (is_ipaddrv4($_POST['subnet'])) {
             $parent_ip = get_interface_ip($_POST['interface']);
             $parent_sn = get_interface_subnet($_POST['interface']);
             $subnet = gen_subnet($parent_ip, $parent_sn);
         } else {
             if (is_ipaddrv6($_POST['subnet'])) {
                 $parent_ip = get_interface_ipv6($_POST['interface']);
                 $parent_sn = get_interface_subnetv6($_POST['interface']);
                 $subnet = gen_subnetv6($parent_ip, $parent_sn);
             }
         }
         if (isset($parent_ip) && !ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet(link_carp_interface_to_parent($_POST['interface']), $_POST['subnet'])) {
             $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'];
             $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s.  Please add an IP alias in this subnet on this interface."), $cannot_find);
         }
         unset($parent_ip, $parent_sn, $subnet);
     }
     break;
 default:
     if ($_POST['interface'] == 'lo0') {
         $input_errors[] = gettext("For this type of vip localhost is not allowed.");
     } else {
         if (strpos($_POST['interface'], '_vip')) {
             $input_errors[] = gettext("A CARP parent interface can only be used with IP Alias type Virtual IPs.");
         }
     }
     break;
Пример #16
0
                 $ignore_posted_dnsgw[$dnsgwname] = true;
             }
         }
     }
 }
 if (count(array_filter($dnslist)) != count(array_unique(array_filter($dnslist)))) {
     $input_errors[] = gettext('Each configured DNS server must have a unique IP address. Remove the duplicated IP.');
 }
 $direct_networks_list = explode(" ", filter_get_direct_networks_list());
 for ($dnscounter = 1; $dnscounter < 5; $dnscounter++) {
     $dnsitem = "dns{$dnscounter}";
     $dnsgwitem = "dns{$dnscounter}gw";
     if ($_POST[$dnsgwitem]) {
         if (interface_has_gateway($_POST[$dnsgwitem])) {
             foreach ($direct_networks_list as $direct_network) {
                 if (ip_in_subnet($_POST[$dnsitem], $direct_network)) {
                     $input_errors[] = sprintf(gettext("A gateway can not be assigned to DNS '%s' server which is on a directly connected network."), $_POST[$dnsitem]);
                 }
             }
         }
     }
 }
 # it's easy to have a little too much whitespace in the field, clean it up for the user before processing.
 $_POST['timeservers'] = preg_replace('/[[:blank:]]+/', ' ', $_POST['timeservers']);
 $_POST['timeservers'] = trim($_POST['timeservers']);
 foreach (explode(' ', $_POST['timeservers']) as $ts) {
     if (!is_domain($ts)) {
         $input_errors[] = gettext("A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.");
     }
 }
 if (!$input_errors) {
     }
     if (empty($pconfig['password'])) {
         $input_errors[] = gettext("You must specify a CARP password that is shared between the two VHID members.");
     }
     if (is_ipaddrv4($pconfig['subnet'])) {
         $parent_ip = get_interface_ip($pconfig['interface']);
         $parent_sn = get_interface_subnet($pconfig['interface']);
         $subnet = gen_subnet($parent_ip, $parent_sn);
     } else {
         if (is_ipaddrv6($pconfig['subnet'])) {
             $parent_ip = get_interface_ipv6($pconfig['interface']);
             $parent_sn = get_interface_subnetv6($pconfig['interface']);
             $subnet = gen_subnetv6($parent_ip, $parent_sn);
         }
     }
     if (isset($parent_ip) && !ip_in_subnet($pconfig['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet($pconfig['interface'], $pconfig['subnet'])) {
         $cannot_find = $pconfig['subnet'] . "/" . $pconfig['subnet_bits'];
         $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s.  Please add an IP alias in this subnet on this interface."), $cannot_find);
     }
     if ($pconfig['interface'] == "lo0") {
         $input_errors[] = gettext("For this type of vip localhost is not allowed.");
     }
 } else {
     if ($pconfig['mode'] != 'ipalias' && $pconfig['interface'] == "lo0") {
         $input_errors[] = gettext("For this type of vip localhost is not allowed.");
     }
 }
 if (count($input_errors) == 0) {
     $vipent = array();
     // defaults
     $vipent['type'] = "single";
Пример #18
0
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s network address."), $ifcfgdescr);
     }
     if ($ipaddr_int == $lansubnet_end) {
         $input_errors[] = sprintf(gettext("The IP address cannot be the %s broadcast address."), $ifcfgdescr);
     }
 }
 if ($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the gateway.");
 }
 if ($_POST['wins1'] && !is_ipaddrv4($_POST['wins1']) || $_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])) {
     $input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
 }
 $parent_ip = get_interface_ip($POST['if']);
 if (is_ipaddrv4($parent_ip) && $_POST['gateway']) {
     $parent_sn = get_interface_subnet($_POST['if']);
     if (!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway'])) {
         $input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
     }
 }
 if ($_POST['dns1'] && !is_ipaddrv4($_POST['dns1']) || $_POST['dns2'] && !is_ipaddrv4($_POST['dns2']) || $_POST['dns3'] && !is_ipaddrv4($_POST['dns3']) || $_POST['dns4'] && !is_ipaddrv4($_POST['dns4'])) {
     $input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
 }
 if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || $_POST['deftime'] < 60)) {
     $input_errors[] = gettext("The default lease time must be at least 60 seconds.");
 }
 if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || $_POST['maxtime'] < 60 || $_POST['maxtime'] <= $_POST['deftime'])) {
     $input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
 }
 if ($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])) {
     $input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
 }
function ip_in_pfb_localsub($subnet)
{
    global $pfb_localsub;
    if (!empty($pfb_localsub)) {
        foreach ($pfb_localsub as $line) {
            if (ip_in_subnet($subnet, $line)) {
                return true;
            }
        }
    }
    return false;
}