mirror of
https://github.com/unraid/webgui.git
synced 2026-05-12 23:30:01 -05:00
Enhanced network settings
This commit is contained in:
@@ -175,7 +175,7 @@ if ($action) {
|
||||
$vnc = '';
|
||||
if ($vncport > 0) {
|
||||
$wsport = $lv->domain_get_ws_port($res);
|
||||
$vnc = '/plugins/dynamix.vm.manager/vnc.html?autoconnect=true&host=' . $var['IPADDR'] . '&port=' . $wsport;
|
||||
$vnc = '/plugins/dynamix.vm.manager/vnc.html?autoconnect=true&host=' . $eth0['IPADDR:0'] . '&port=' . $wsport;
|
||||
} else {
|
||||
$vncport = ($vncport < 0) ? "auto" : "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
Menu="NetworkSettings"
|
||||
Title="Interface eth0"
|
||||
Png="ethernet.png"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2015-2016, Lime Technology
|
||||
* Copyright 2015-2016, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$build = false;
|
||||
$template = '/usr/local/emhttp/webGui/EthX.page';
|
||||
$ini = '/var/local/emhttp/network.ini';
|
||||
$validIP = '(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])';
|
||||
|
||||
function normalize($name) {
|
||||
return ucfirst(trim($name));
|
||||
}
|
||||
|
||||
// get available ethernet ports (excluding eth0)
|
||||
exec("ip -br addr|grep -Po '^eth[1-9]+\s'",$ports);
|
||||
$ports = array_map('normalize', $ports);
|
||||
|
||||
// remove non-existing ethernet ports
|
||||
foreach (glob('/usr/local/emhttp/webGui/Eth[1-9]*.page',GLOB_NOSORT) as $port) {
|
||||
if (!in_array(basename($port,'.page'), $ports)) {
|
||||
@unlink($port);
|
||||
$build = true;
|
||||
}
|
||||
}
|
||||
// add new ethernet ports
|
||||
foreach ($ports as $port) {
|
||||
$file = "/usr/local/emhttp/webGui/$port.page";
|
||||
if (!file_exists($file)) {
|
||||
copy($template, $file);
|
||||
$eth = strtolower($port);
|
||||
exec("sed -i 's/x-settings/NetworkSettings/;s/ethX/$eth/g' $file");
|
||||
$build = true;
|
||||
}
|
||||
}
|
||||
// enable when array is stopped
|
||||
$disabled = exec("virsh list|grep -om1 running") ? 'disabled' : '';
|
||||
|
||||
// get VLAN interfaces
|
||||
$vlan_eth0 = [0];
|
||||
if (isset($eth0)) foreach ($eth0 as $key => $val) if (substr($key,0,6)=='VLANID') $vlan_eth0[] = substr($key,7);
|
||||
?>
|
||||
<style>
|
||||
span.pin{margin:0;padding:0;font-size:16px;cursor:pointer;}
|
||||
span.no-int{color:#E68A00;}
|
||||
div.shade-white{background-color:#F8F8F8;}
|
||||
div.shade-black{background-color:#0C0C0C;}
|
||||
</style>
|
||||
<script>
|
||||
<?if ($build):?>
|
||||
refresh(); // automatically include new ethernet ports
|
||||
<?endif;?>
|
||||
Array.prototype.dups = function(){return this.sort().filter(function(v,i,o){return i&&v===o[i-1]?v:0;}).length;}
|
||||
|
||||
function prepareSettings(form) {
|
||||
var bonding = form.BONDING !== undefined;
|
||||
if (bonding) {
|
||||
var member = '';
|
||||
for (var i=0,item; item=form.BONDNICS.options[i]; i++) {
|
||||
if (item.selected) {
|
||||
if (member.length) member += ',';
|
||||
member += item.value;
|
||||
item.selected = false;
|
||||
}
|
||||
}
|
||||
item = form.BONDNICS.options[0];
|
||||
item.value = member;
|
||||
item.selected = true;
|
||||
item.disabled = false;
|
||||
form.BONDNICS.disabled = false;
|
||||
if (form.BONDING.value=='yes') form.BRNICS.value = form.BONDNAME.value;
|
||||
}
|
||||
if (form.TYPE.value == 'access') {
|
||||
$(form).find('input[name^="VLANID:"]').prop('disabled',true);
|
||||
$(form).find('input[name^="DESCRIPTION:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="USE_DHCP:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('input[name^="IPADDR:"]').not('input[name$=":0"]').prop('disabled',true);
|
||||
$(form).find('select[name^="NETMASK:"]').not('select[name$=":0"]').prop('disabled',true);
|
||||
} else {
|
||||
var vlans = [];
|
||||
$(form).find('input[name^="VLANID:"]').each(function(){vlans.push($(this).val());});
|
||||
if (vlans.dups()) {
|
||||
swal('VLAN mismatch','List contains duplicate VLAN numbers','error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
form.BRNAME.value = 'br'+$(form).find('input[name="#section"]').val().substr(3);
|
||||
return true;
|
||||
}
|
||||
function checkNetworkSettings(form,index) {
|
||||
if (index == null) {
|
||||
$(form).find('select[name^="USE_DHCP:"]').each(function() {
|
||||
var i = $(this).attr('name').substr(9);
|
||||
var disabled = $(this).val()!='no';
|
||||
$(form).find('input[name="IPADDR:'+i+'"]').prop('disabled',disabled).prop('required',!disabled);
|
||||
var netmask = $(form).find('select[name="NETMASK:'+i+'"]');
|
||||
netmask.prop('disabled',disabled);
|
||||
if (disabled) netmask.append('<option value="none" selected="selected"></option>');
|
||||
if (i==0 && form.GATEWAY !== undefined) {form.GATEWAY.disabled = disabled; form.GATEWAY.required = !disabled;}
|
||||
});
|
||||
} else {
|
||||
var disabled = $(form).find('select[name="USE_DHCP:'+index+'"]').val()!='no';
|
||||
$(form).find('input[name="IPADDR:'+index+'"]').prop('disabled',disabled).prop('required',!disabled);
|
||||
var netmask = $(form).find('select[name="NETMASK:'+index+'"]');
|
||||
netmask.prop('disabled',disabled);
|
||||
if (!disabled) {
|
||||
var none = netmask.find('option[value="none"]');
|
||||
if (none.length) {netmask.val('255.255.255.0'); none.remove();}
|
||||
}
|
||||
if (form.GATEWAY !== undefined) {form.GATEWAY.disabled = disabled; form.GATEWAY.required = !disabled;}
|
||||
if (!disabled && form.DHCP_KEEPRESOLV !== undefined) {form.DHCP_KEEPRESOLV.value = 'yes'; checkDNSSettings(form);}
|
||||
}
|
||||
}
|
||||
function checkDNSSettings(form) {
|
||||
var disabled = form.DHCP_KEEPRESOLV.value=='no';
|
||||
form.DNS_SERVER1.disabled = disabled;
|
||||
form.DNS_SERVER1.required = !disabled;
|
||||
form.DNS_SERVER2.disabled = disabled;
|
||||
form.DNS_SERVER3.disabled = disabled;
|
||||
}
|
||||
function checkBondingSettings(form,ctrl) {
|
||||
var disabled = form.BONDING.value=='no';
|
||||
var mode = form.BONDING_MODE.value;
|
||||
if (ctrl) {
|
||||
form.BONDING_MODE.disabled = disabled;
|
||||
form.BONDNICS.disabled = disabled;
|
||||
$('#bond0').dropdownchecklist(disabled?'disable':'enable');
|
||||
}
|
||||
if (mode==1 || mode>4 || disabled) {$('#attention0').hide();} else {$('#attention0').show();}
|
||||
}
|
||||
function checkNetworkAccess(form,port) {
|
||||
if (form.TYPE.value=='access') {
|
||||
$('.access-'+port).hide();
|
||||
$(form).find('input[name^="VLANID:"]').prop('required',false);
|
||||
} else {
|
||||
$('.access-'+port).show();
|
||||
$(form).find('input[name^="VLANID:"]').prop('required',true);
|
||||
}
|
||||
}
|
||||
function addVLAN(port,disabled) {
|
||||
if (disabled) return;
|
||||
var index = 1;
|
||||
while ($('#index-'+port+'-'+index).length) index++;
|
||||
var template = $($('<div/>').loadTemplate($('#network-template-'+port)).html().replace(/INDEX/g,index));
|
||||
var element = $('[id^="index-'+port+'-"]').last();
|
||||
$(element).after(template);
|
||||
checkNetworkSettings($('form[name="'+$(element).parent().attr('name')+'"]'));
|
||||
$(element).find('input').first().trigger('change');
|
||||
}
|
||||
function removeVLAN(element,disabled) {
|
||||
if (disabled) return;
|
||||
var id = $(element).attr('id').split('-');
|
||||
$(element).remove();
|
||||
$('#index-'+id[1]+'-0').find('select').first().trigger('change');
|
||||
}
|
||||
function disableForm(form) {
|
||||
$(form).find('input,select').not('input[value="Done"]').prop('disabled',true);
|
||||
}
|
||||
var stopEvent = false;
|
||||
function exitCode(form,key) {
|
||||
if (stopEvent) {stopEvent = false; return;}
|
||||
var arg1 = $(form).find('input[name="#arg[1]"]');
|
||||
if (!key) {
|
||||
arg1.val($(form).find('input[name="#section"]').val());
|
||||
} else {
|
||||
if (arg1.val()=='') arg1.val('none');
|
||||
stopEvent = true;
|
||||
}
|
||||
}
|
||||
$(function() {
|
||||
<?if ($tabbed && !$disabled):?>
|
||||
$('#tab1').bind({click:function(){
|
||||
$('#bond0').dropdownchecklist('destroy').dropdownchecklist({emptyText:'None', width:130});
|
||||
checkBondingSettings(document.eth0_settings,true);
|
||||
}});
|
||||
<?endif;?>
|
||||
$('#bond0').dropdownchecklist({emptyText:'None', width:130});
|
||||
checkBondingSettings(document.eth0_settings,true);
|
||||
checkNetworkAccess(document.eth0_settings,'eth0');
|
||||
<?if ($disabled):?>
|
||||
disableForm(document.eth0_settings);
|
||||
$('#bond0').dropdownchecklist('disable');
|
||||
<?else:?>
|
||||
checkNetworkSettings(document.eth0_settings);
|
||||
checkDNSSettings(document.eth0_settings);
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
<form markdown="1" name="eth0_settings" method="POST" action="/update.php" target="progressFrame" onchange="exitCode(this,false)" onsubmit="return prepareSettings(this)">
|
||||
<input type="hidden" name="#file" value="<?=$ini?>">
|
||||
<input type="hidden" name="#include" value="/webGui/include/update.ethernet.php">
|
||||
<input type="hidden" name="#section" value="eth0">
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/netconfig">
|
||||
<input type="hidden" name="#arg[1]" value="">
|
||||
<input type="hidden" name="BONDNAME" value="bond0">
|
||||
<input type="hidden" name="BONDING_MIIMON" value="100">
|
||||
<input type="hidden" name="BRNAME" value="">
|
||||
<input type="hidden" name="BRNICS" value="eth0">
|
||||
<input type="hidden" name="BRSTP" value="no">
|
||||
<input type="hidden" name="BRFD" value="0">
|
||||
<?foreach ($vlan_eth0 as $i):?>
|
||||
<div id="index-eth0-<?=$i?>" markdown="1">
|
||||
<?if ($i==0):?>
|
||||
MAC address:
|
||||
: <?=strtoupper(exec("ip link show eth0|grep -Pom1 'ether \K\S+'"))?>
|
||||
|
||||
> This is the hardware address of the interface.
|
||||
> When tagging is enabled all VLANs on this interface will share the same hardware address.
|
||||
|
||||
Enable bonding:
|
||||
: <select name="BONDING" size="1" onchange="checkBondingSettings(this.form,true)">
|
||||
<?=mk_option($eth0['BONDING'], "no", "No");?>
|
||||
<?=mk_option($eth0['BONDING'], "yes", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Bonding is a feature that combines multiple physical Ethernet interfaces into a single *bonded* interface named **bond0**.
|
||||
> This can be used to improve the connection redundancy and/or throughput of the system.
|
||||
> Different bonding modes are supported (see below), but some modes require proper switch support.
|
||||
|
||||
Bonding mode:
|
||||
: <select name="BONDING_MODE" size="1" onchange="checkBondingSettings(this.form,false)">
|
||||
<?=mk_option($eth0['BONDING_MODE'], "0", "balance-rr (0)");?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "1", "active-backup (1)",isset($eth0['BONDING_MODE'])?'':'selected');?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "2", "balance-xor (2)");?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "3", "broadcast (3)");?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "4", "802.3ad (4)");?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "5", "balance-tlb (5)");?>
|
||||
<?=mk_option($eth0['BONDING_MODE'], "6", "balance-alb (6)");?>
|
||||
</select><span id="attention0" style="display:none"><b>Attention:</b> this mode requires a network switch with proper setup and support...</span>
|
||||
|
||||
> Mode 1 (active-backup) is the recommended default. Other modes allow you to set up a specific environment, but may require proper switch support.
|
||||
> Choosing a unsupported mode can result in a disrupted communication. Use with caution.
|
||||
|
||||
Bonding members:
|
||||
: <select id="bond0" name="BONDNICS" size="1" multiple="multiple" style="display:none">
|
||||
<?=mk_option($eth0['BONDNICS'],'eth0','Eth0','selected disabled')?>
|
||||
<?foreach ($ports as $port):?>
|
||||
<?=mk_option_check($eth0['BONDNICS'],strtolower($port),$port)?>
|
||||
<?endforeach;?>
|
||||
</select>
|
||||
|
||||
> Select which interfaces are member of the *bonded* interface. By default eth0 is a member, while other interfaces are optional.
|
||||
|
||||
Enable bridging:
|
||||
: <select name="BRIDGING" size="1">
|
||||
<?=mk_option($eth0['BRIDGING'], "no", "No");?>
|
||||
<?=mk_option($eth0['BRIDGING'], "yes", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Bridging is a feature which creates a virtual bridge and allows VMs to communicate directly with the physical Ethernet port.
|
||||
> Both bonding and bridging can be combined to let VMs communicate over a *bonded* interface.
|
||||
|
||||
Type of access:
|
||||
: <select name="TYPE" size="1" onchange="checkNetworkAccess(this.form,'eth0')">
|
||||
<?=mk_option($eth0['TYPE'], 'access', 'Untagged');?>
|
||||
<?=mk_option($eth0['TYPE'], 'trunk', 'Tagged');?>
|
||||
</select><span class="access-eth0 pin" title="Add VLAN" style="display:none" onclick="addVLAN('eth0',<?=$disabled?'true':'false'?>)"><i class="fa fa-plus-circle green"></i></span>
|
||||
<?else:?>
|
||||
<div class="access-eth0 shade-<?=$display['theme']?>" style="display:none" markdown="1">
|
||||
VLAN number:
|
||||
: <input type="number" name="VLANID:<?=$i?>" min="1" max="4095" value="<?=$eth0["VLANID:$i"]?>" class="narrow" required>
|
||||
<span class="pin" title="Remove VLAN" onclick="removeVLAN($('#index-eth0-<?=$i?>'),<?=$disabled?'true':'false'?>)"><i class="fa fa-minus-circle red"></i></span>
|
||||
<?endif;?>
|
||||
|
||||
Interface description:
|
||||
: <input type="text" name="DESCRIPTION:<?=$i?>" maxlength="40" value="<?=$eth0["DESCRIPTION:$i"]?>" onchange="exitCode(this.form,true)">
|
||||
|
||||
> Use this optional field to provide addditional information about the purpose of the connection.
|
||||
|
||||
IP address assignment:
|
||||
: <select name="USE_DHCP:<?=$i?>" size="1" onchange="checkNetworkSettings(this.form,<?=$i?>)">
|
||||
<?=mk_option($eth0["USE_DHCP:$i"], 'yes', 'Automatic');?>
|
||||
<?=mk_option($eth0["USE_DHCP:$i"], 'no', 'Static');?>
|
||||
<?if ($i>0):?>
|
||||
<?=mk_option($eth0["USE_DHCP:$i"], '', 'None');?>
|
||||
<?endif;?>
|
||||
</select>
|
||||
|
||||
> The following settings are possible:
|
||||
>
|
||||
> *Automatic* - the server will attempt to obtain its IP address from the local DHCP server<br>
|
||||
> *Static* - the IP address is manually set for this interface<br>
|
||||
> *None* - no IP address is assigned to the interface (only available for VLANs)
|
||||
|
||||
IP address:
|
||||
: <input type="text" name="IPADDR:<?=$i?>" maxlength="40" value="<?=$eth0["IPADDR:$i"]?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the IP address of the system.
|
||||
|
||||
Network mask:
|
||||
: <select name="NETMASK:<?=$i?>" size="1">
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.252.0", "255.255.252.0");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.254.0", "255.255.254.0");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.0", "255.255.255.0");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.128", "255.255.255.128");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.192", "255.255.255.192");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.224", "255.255.255.224");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.240", "255.255.255.240");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.248", "255.255.255.248");?>
|
||||
<?=mk_option($eth0["NETMASK:$i"], "255.255.255.252", "255.255.255.252");?>
|
||||
</select>
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the associated network mask, by default 255.255.255.0 is selected.
|
||||
|
||||
<?if ($i==0):?>
|
||||
Default gateway:
|
||||
: <input type="text" name="GATEWAY" maxlength="40" value="<?=$eth0['GATEWAY']?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the IP address of your router.
|
||||
|
||||
DNS server assignment:
|
||||
: <select name="DHCP_KEEPRESOLV" size="1" onchange="checkDNSSettings(this.form)">
|
||||
<?=mk_option($eth0['DHCP_KEEPRESOLV'], "no", "Automatic");?>
|
||||
<?=mk_option($eth0['DHCP_KEEPRESOLV'], "yes", "Static");?>
|
||||
</select>
|
||||
|
||||
> If set to *Automatic* the server will use DNS server IP address returned by the local DHCP server.<br>
|
||||
> If set to *Static* you may enter your own list.
|
||||
>
|
||||
> This is useful in Active Directory configurations where you need to set the first DNS Server entry to the IP address of your AD Domain server.
|
||||
|
||||
DNS server 1:
|
||||
: <input type="text" name="DNS_SERVER1" maxlength="80" value="<?=$eth0['DNS_SERVER1'];?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> This is the primary DNS server to use. Enter a FQDN or an IP address.
|
||||
>
|
||||
> Note: for *Active Directory* you **must** ensure this is set to the IP address of your AD Domain server.
|
||||
|
||||
DNS server 2:
|
||||
: <input type="text" name="DNS_SERVER2" maxlength="80" value="<?=$eth0['DNS_SERVER2'];?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> This is the DNS server to use when DNS Server 1 is down.
|
||||
|
||||
DNS server 3:
|
||||
: <input type="text" name="DNS_SERVER3" maxlength="80" value="<?=$eth0['DNS_SERVER3'];?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> This is the DNS server to use when DNS Servers 1 and 2 are both down.
|
||||
|
||||
Desired MTU:
|
||||
: <input type="number" name="MTU" min="68" max="9198" value="<?=$eth0['MTU']?>" class="narrow">
|
||||
|
||||
> This is the MTU size to use on the physical Ethernet interface.
|
||||
> If left blank, the MTU will automatically be determined (by default 1500 bytes).
|
||||
|
||||
<?else:?>
|
||||
</div>
|
||||
<?endif;?>
|
||||
</div>
|
||||
<?endforeach;?>
|
||||
|
||||
<script type="text/html" id="network-template-eth0" markdown="1">
|
||||
<div id="index-eth0-INDEX" class="access-eth0 shade-<?=$display['theme']?>" markdown="1">
|
||||
VLAN number:
|
||||
: <input type="number" name="VLANID:INDEX" min="1" max="4095" value="<?=$eth0["VLANID:INDEX"]?>" class="narrow" required><span class="pin" title="Remove VLAN" onclick="removeVLAN($('#index-eth0-INDEX'),false)"><i class="fa fa-minus-circle red"></i></span>
|
||||
|
||||
Interface description:
|
||||
: <input type="text" name="DESCRIPTION:INDEX" maxlength="40" value="<?=$eth0["DESCRIPTION:INDEX"]?>" onchange="exitCode(this.form,true)">
|
||||
|
||||
IP address assignment:
|
||||
: <select name="USE_DHCP:INDEX" size="1" onchange="checkNetworkSettings(this.form,INDEX)">
|
||||
<?=mk_option($eth0["USE_DHCP:INDEX"], 'yes', 'Automatic');?>
|
||||
<?=mk_option($eth0["USE_DHCP:INDEX"], 'no', 'Static');?>
|
||||
<?=mk_option($eth0["USE_DHCP:INDEX"], '', 'None');?>
|
||||
</select>
|
||||
|
||||
IP address:
|
||||
: <input type="text" name="IPADDR:INDEX" maxlength="40" value="<?=$eth0["IPADDR:INDEX"]?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
Network mask:
|
||||
: <select name="NETMASK:INDEX" size="1">
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.252.0", "255.255.252.0");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.254.0", "255.255.254.0");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.0", "255.255.255.0");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.128", "255.255.255.128");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.192", "255.255.255.192");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.224", "255.255.255.224");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.240", "255.255.255.240");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.248", "255.255.255.248");?>
|
||||
<?=mk_option($eth0["NETMASK:INDEX"], "255.255.255.252", "255.255.255.252");?>
|
||||
</select>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
: <input type="submit" value="Apply"><input type="button" value="Done" onclick="done()"><?=$disabled ? "VMs must be <b>Stopped</b> to change" : ""?>
|
||||
</form>
|
||||
@@ -0,0 +1,165 @@
|
||||
Menu="x-settings"
|
||||
Title="Interface ethX"
|
||||
Png="ethernet.png"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2015-2016, Lime Technology
|
||||
* Copyright 2015-2016, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
// get interface configuration state
|
||||
$down = strlen(exec("ip link show ethX|grep -om1 ',UP[,>]'"))==0;
|
||||
|
||||
// get VLAN interfaces
|
||||
$vlan_ethX = [0];
|
||||
if (isset($ethX)) foreach ($ethX as $key => $val) if (substr($key,0,6)=='VLANID') $vlan_ethX[] = substr($key,7);
|
||||
|
||||
// get bond membership
|
||||
$bond_ethX = isset($eth0['BONDNICS']) ? in_array('ethX',explode(',',$eth0['BONDNICS'])) : false;
|
||||
?>
|
||||
<script>
|
||||
$(function() {
|
||||
checkNetworkAccess(document.ethX_settings,'ethX');
|
||||
<?if ($disabled || $bond_ethX):?>
|
||||
disableForm(document.ethX_settings);
|
||||
<?else:?>
|
||||
checkNetworkSettings(document.ethX_settings);
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
<form markdown="1" name="ethX_settings" method="POST" action="/update.php" target="progressFrame" onchange="exitCode(this,false)" onsubmit="return prepareSettings(this)">
|
||||
<input type="hidden" name="#file" value="<?=$ini?>">
|
||||
<input type="hidden" name="#include" value="/webGui/include/update.ethernet.php">
|
||||
<input type="hidden" name="#section" value="ethX">
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/netconfig">
|
||||
<input type="hidden" name="#arg[1]" value="">
|
||||
<input type="hidden" name="BRNAME" value="">
|
||||
<input type="hidden" name="BRNICS" value="ethX">
|
||||
<input type="hidden" name="BRSTP" value="no">
|
||||
<input type="hidden" name="BRFD" value="0">
|
||||
<?foreach ($vlan_ethX as $i):?>
|
||||
<div id="index-ethX-<?=$i?>" markdown="1">
|
||||
<?if ($i==0):?>
|
||||
MAC address:
|
||||
: <?if ($down):?><span class="no-int"><?endif;?><?=strtoupper(exec("ip link show ethX|grep -Pom1 'ether \K\S+'"))?><?if ($down):?> - interface is not configured</span><?endif;?>
|
||||
|
||||
> This is the hardware address of the interface.
|
||||
> When tagging is enabled all VLANs on this interface will share the same hardware address.
|
||||
|
||||
Enable bridging:
|
||||
: <select name="BRIDGING" size="1">
|
||||
<?=mk_option($ethX['BRIDGING'], "no", "No");?>
|
||||
<?=mk_option($ethX['BRIDGING'], "yes", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Bridging is a feature which creates a virtual bridge and allows VMs to communicate directly with the physical Ethernet port.
|
||||
|
||||
Type of access:
|
||||
: <select name="TYPE" size="1" onchange="checkNetworkAccess(this.form,'ethX')">
|
||||
<?=mk_option($ethX['TYPE'], 'access', 'Untagged');?>
|
||||
<?=mk_option($ethX['TYPE'], 'trunk', 'Tagged');?>
|
||||
</select><span class="access-ethX pin" title="Add VLAN" style="display:none" onclick="addVLAN('ethX',<?=$disabled?'true':'false'?>)"><i class="fa fa-plus-circle green"></i></span>
|
||||
<?else:?>
|
||||
<div class="access-ethX shade-<?=$display['theme']?>" style="display:none" markdown="1">
|
||||
VLAN number:
|
||||
: <input type="number" name="VLANID:<?=$i?>" min="1" max="4095" value="<?=$ethX["VLANID:$i"]?>" class="narrow" required>
|
||||
<span class="pin" title="Remove VLAN" onclick="removeVLAN($('#index-ethX-<?=$i?>'),<?=$disabled?'true':'false'?>)"><i class="fa fa-minus-circle red"></i></span>
|
||||
<?endif;?>
|
||||
|
||||
Interface description:
|
||||
: <input type="text" name="DESCRIPTION:<?=$i?>" maxlength="40" value="<?=$ethX["DESCRIPTION:$i"]?>" onchange="exitCode(this.form,true)">
|
||||
|
||||
> Use this field to give addditional information about the purpose of the connection.
|
||||
|
||||
IP address assignment:
|
||||
: <select name="USE_DHCP:<?=$i?>" size="1" onchange="checkNetworkSettings(this.form,<?=$i?>)">
|
||||
<?=mk_option($ethX["USE_DHCP:$i"], 'yes', 'Automatic');?>
|
||||
<?=mk_option($ethX["USE_DHCP:$i"], 'no', 'Static');?>
|
||||
<?if ($i>0):?>
|
||||
<?=mk_option($ethX["USE_DHCP:$i"], '', 'None');?>
|
||||
<?endif;?>
|
||||
</select>
|
||||
|
||||
> The following settings are possible:
|
||||
>
|
||||
> *Automatic* - the server will attempt to obtain its IP address from the local DHCP server<br>
|
||||
> *Static* - the IP address is manually set for this interface<br>
|
||||
> *None* - no IP address is assigned to the interface (only available for VLANs)
|
||||
|
||||
IP address:
|
||||
: <input type="text" name="IPADDR:<?=$i?>" maxlength="40" value="<?=$ethX["IPADDR:$i"]?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the IP address of the interface.
|
||||
|
||||
Network mask:
|
||||
: <select name="NETMASK:<?=$i?>" size="1">
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.252.0", "255.255.252.0");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.254.0", "255.255.254.0");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.0", "255.255.255.0");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.128", "255.255.255.128");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.192", "255.255.255.192");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.224", "255.255.255.224");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.240", "255.255.255.240");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.248", "255.255.255.248");?>
|
||||
<?=mk_option($ethX["NETMASK:$i"], "255.255.255.252", "255.255.255.252");?>
|
||||
</select>
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the associated network mask, by default 255.255.255.0 is selected.
|
||||
|
||||
<?if ($i==0):?>
|
||||
Desired MTU:
|
||||
: <input type="number" name="MTU" min="68" max="9198" value="<?=$ethX['MTU']?>" class="narrow">
|
||||
|
||||
> This is the MTU size to use on the physical Ethernet interface.
|
||||
> If left blank, the MTU will automatically be determined (by default 1500 bytes).
|
||||
|
||||
<?else:;?>
|
||||
</div>
|
||||
<?endif;?>
|
||||
</div>
|
||||
<?endforeach;?>
|
||||
|
||||
<script type="text/html" id="network-template-ethX" markdown="1">
|
||||
<div id="index-ethX-INDEX" class="access-ethX shade-<?=$display['theme']?>" markdown="1">
|
||||
VLAN number:
|
||||
: <input type="number" name="VLANID:INDEX" min="1" max="4095" value="<?=$ethX["VLANID:INDEX"]?>" class="narrow" required><span class="pin" title="Remove VLAN" onclick="removeVLAN($('#index-ethX-INDEX'),false)"><i class="fa fa-minus-circle red"></i></span>
|
||||
|
||||
Interface description:
|
||||
: <input type="text" name="DESCRIPTION:INDEX" maxlength="40" value="<?=$ethX["DESCRIPTION:INDEX"]?>" onchange="exitCode(this.form,true)">
|
||||
|
||||
IP address assignment:
|
||||
: <select name="USE_DHCP:INDEX" size="1" onchange="checkNetworkSettings(this.form,INDEX)">
|
||||
<?=mk_option($ethX["USE_DHCP:INDEX"], 'yes', 'Automatic');?>
|
||||
<?=mk_option($ethX["USE_DHCP:INDEX"], 'no', 'Static');?>
|
||||
<?=mk_option($ethX["USE_DHCP:INDEX"], '', 'None');?>
|
||||
</select>
|
||||
|
||||
IP address:
|
||||
: <input type="text" name="IPADDR:INDEX" maxlength="40" value="<?=$ethX["IPADDR:INDEX"]?>" class="narrow" pattern="<?=$validIP?>" title="IP address A.B.C.D">
|
||||
|
||||
Network mask:
|
||||
: <select name="NETMASK:INDEX" size="1">
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.252.0", "255.255.252.0");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.254.0", "255.255.254.0");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.0", "255.255.255.0");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.128", "255.255.255.128");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.192", "255.255.255.192");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.224", "255.255.255.224");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.240", "255.255.255.240");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.248", "255.255.255.248");?>
|
||||
<?=mk_option($ethX["NETMASK:INDEX"], "255.255.255.252", "255.255.255.252");?>
|
||||
</select>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
||||
: <input type="submit" value="Apply"><input type="button" value="Done" onclick="done()"><?=$bond_ethX ? "Interface must be <b>Unbonded</b> to change" : ($disabled ? "VMs must be <b>Stopped</b> to change" : "")?>
|
||||
</form>
|
||||
@@ -1,179 +1,4 @@
|
||||
Menu="OtherSettings"
|
||||
Type="xmenu"
|
||||
Title="Network Settings"
|
||||
Icon="network-settings.png"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2015, Lime Technology
|
||||
* Copyright 2015, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<? $disabled = $var['fsState']!='Stopped' ? 'disabled' : ''; ?>
|
||||
<script>
|
||||
function checkNetworkSettings() {
|
||||
var form = document.network_settings;
|
||||
var disabled = "<?=$disabled?>".length != 0; //yes this is a hack
|
||||
form.BONDING.disabled = disabled;
|
||||
form.BONDING_MODE.disabled = (form.BONDING.value != "yes") || disabled;
|
||||
form.BRIDGING.disabled = disabled;
|
||||
form.BRNAME.disabled = (form.BRIDGING.value != "yes") || disabled;
|
||||
form.BRSTP.disabled = (form.BRIDGING.value != "yes") || disabled;
|
||||
form.BRFD.disabled = (form.BRIDGING.value != "yes") || disabled;
|
||||
form.USE_DHCP.disabled = disabled;
|
||||
form.IPADDR.disabled = (form.USE_DHCP.value == "yes") || disabled;
|
||||
form.NETMASK.disabled = (form.USE_DHCP.value == "yes") || disabled;
|
||||
form.GATEWAY.disabled = (form.USE_DHCP.value == "yes") || disabled;
|
||||
form.DHCP_KEEPRESOLV.disabled = (form.USE_DHCP.value != "yes") || disabled;
|
||||
if (form.USE_DHCP.value != "yes") form.DHCP_KEEPRESOLV.value = "yes";
|
||||
form.DNS_SERVER1.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.DNS_SERVER2.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.DNS_SERVER3.disabled = (form.DHCP_KEEPRESOLV.value != "yes") || disabled;
|
||||
form.MTU.disabled = disabled;
|
||||
}
|
||||
function checkBondingSettings() {
|
||||
var form = document.network_settings;
|
||||
var mode=form.BONDING_MODE.value;
|
||||
if (mode==1 || mode>4 || form.BONDING.value=="no") {$('#attention').hide();} else {$('#attention').show();}
|
||||
}
|
||||
$(checkNetworkSettings);
|
||||
$(checkBondingSettings);
|
||||
</script>
|
||||
<form markdown="1" name="network_settings" method="POST" action="/update.htm" target="progressFrame">
|
||||
|
||||
MAC address:
|
||||
: <?=$var['HWADDR'];?>
|
||||
|
||||
Enable bonding:
|
||||
: <select name="BONDING" size="1" onchange="checkNetworkSettings()">
|
||||
<?=mk_option($var['BONDING'], "no", "No");?>
|
||||
<?=mk_option($var['BONDING'], "yes", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Bonding is a feature that combines all of your physical Ethernet interfaces into a
|
||||
> single *bond* interface named **bond0**. This lets you connect
|
||||
> all of your ethernet ports to the same switch.
|
||||
|
||||
Bonding mode:
|
||||
: <select name="BONDING_MODE" size="1" onchange="checkBondingSettings()">
|
||||
<?=mk_option($var['BONDING_MODE'], "0", "balance-rr (0)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "1", "active-backup (1)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "2", "balance-xor (2)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "3", "broadcast (3)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "4", "802.3ad (4)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "5", "balance-tlb (5)");?>
|
||||
<?=mk_option($var['BONDING_MODE'], "6", "balance-alb (6)");?>
|
||||
</select><span id="attention" style="display:none;color:red"><b>Attention:</b> this mode requires a switch with proper setup and support...</span>
|
||||
|
||||
> Mode 1 (active-backup) is the recommended default. Other modes may require switch support.
|
||||
|
||||
Setup bridge:
|
||||
: <select name="BRIDGING" size="1" onchange="checkNetworkSettings()">
|
||||
<?=mk_option($var['BRIDGING'], "no", "No");?>
|
||||
<?=mk_option($var['BRIDGING'], "yes", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Bridging is a feature that combines all of your physical Ethernet interfaces into
|
||||
> a single logical network segment. If **bonding** is also enabled, the bridge sits
|
||||
> on top of the bond; this is useful for VM configurations.
|
||||
>
|
||||
> **Caution:** if bonding is also not enabled, do not connect two or more
|
||||
> ethernet ports to the same switch unless you have STP enabled *and* the switch supports STP
|
||||
> (most consumer switches **do not**).
|
||||
>
|
||||
> Doing so will cause an "ARP broadcast storm" and can bring down your
|
||||
> entire network (unplugging all server ethernet ports except one
|
||||
> typically will restore your network).
|
||||
|
||||
Bridge name:
|
||||
: <input type="text" name="BRNAME" maxlength="80" value="<?=$var['BRNAME']?>" class="narrow">
|
||||
|
||||
> This is the name of the bridge interface. If left blank, the name of the bridge will be **br0**.
|
||||
|
||||
Bridge enable STP:
|
||||
: <select name="BRSTP" size="1" onchange="checkNetworkSettings()">
|
||||
<?=mk_option($var['BRSTP'], "yes", "Yes");?>
|
||||
<?=mk_option($var['BRSTP'], "no", "No");?>
|
||||
</select>
|
||||
|
||||
> STP (Spanning Tree Protocol) prevents loops in multi-NIC bridges. This is enabled by default but
|
||||
> can cause delays upon network setup; in most configurations it would be safe to disable. If unsure
|
||||
> however, leave this set to **Yes**.
|
||||
|
||||
Bridge forward delay:
|
||||
: <input type="text" name="BRFD" maxlength="10" value="<?=$var['BRFD']?>" class="narrow">
|
||||
|
||||
> Defines the bridge **forward delay** in seconds.
|
||||
>
|
||||
> Forwarding delay time is the time spent in each of the Listening and Learning states before the
|
||||
> Forwarding state is entered. This delay is so that when a new bridge comes onto a busy network it
|
||||
> looks at some traffic before participating.
|
||||
>
|
||||
> If the bridge is being used standalone (no other bridges near by), then it is safe to turn the
|
||||
> forwarding delay off (set it to zero), before adding interface to a bridge.
|
||||
|
||||
Obtain IP address automatically:
|
||||
: <select name="USE_DHCP" size="1" onchange="checkNetworkSettings()">
|
||||
<?=mk_option($var['USE_DHCP'], "yes", "Yes");?>
|
||||
<?=mk_option($var['USE_DHCP'], "no", "No");?>
|
||||
</select>
|
||||
|
||||
> If set to 'Yes' the server will attempt to obtain its IP address from the local DHCP server.
|
||||
|
||||
IP address:
|
||||
: <input type="text" name="IPADDR" maxlength="40" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$" title="IPv4 address" value="<?=$var['IPADDR']?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the IP address of the system.
|
||||
|
||||
Network mask:
|
||||
: <input type="text" name="NETMASK" maxlength="40" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$" title="IPv4 address" value="<?=$var['NETMASK']?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the associated network mask, usually 255.255.255.0
|
||||
|
||||
Default gateway:
|
||||
: <input type="text" name="GATEWAY" maxlength="40" pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$" title="IPv4 address" value="<?=$var['GATEWAY']?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> Greyed out when using DHCP server. Otherwise specify here the IP address of your router.
|
||||
|
||||
Obtain DNS server address automatically:
|
||||
: <select name="DHCP_KEEPRESOLV" size="1" onchange="checkNetworkSettings()">
|
||||
<?=mk_option($var['DHCP_KEEPRESOLV'], "yes", "No");?>
|
||||
<?=mk_option($var['DHCP_KEEPRESOLV'], "no", "Yes");?>
|
||||
</select>
|
||||
|
||||
> If set to 'Yes' the server will use DNS server IP address returned by the local DHCP server.<br>
|
||||
> If set to 'No' you may enter your own list. This is useful in Active Directory configruations where
|
||||
> you need to set the first DNS Server entry to the IP address of your AD Domain server.
|
||||
|
||||
DNS server 1:
|
||||
: <input type="text" name="DNS_SERVER1" maxlength="80" value="<?=$var['DNS_SERVER1'];?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> This is the primary DNS server to use. Enter a FQDN or an IP address.
|
||||
> Note: for *Active Directory* you **must** ensure this is set to the IP address of your
|
||||
> AD Domain server.
|
||||
|
||||
DNS server 2:
|
||||
: <input type="text" name="DNS_SERVER2" maxlength="80" value="<?=$var['DNS_SERVER2'];?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> This is the DNS server to use when DNS Server 1 is down.
|
||||
|
||||
DNS server 3:
|
||||
: <input type="text" name="DNS_SERVER3" maxlength="80" value="<?=$var['DNS_SERVER3'];?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> This is the DNS server to use when DNS Servers 1 and 2 are both down.
|
||||
|
||||
Desired MTU:
|
||||
: <input type="text" name="MTU" maxlength="5" value="<?=$var['MTU'];?>" class="narrow" onchange="checkNetworkSettings()">
|
||||
|
||||
> This is the MTU size to use on all physical Ethernet interfaces participating in the network stack.
|
||||
> If left blank, the MTU will automatically be determined (most likely 1500).
|
||||
|
||||
|
||||
: <input type="submit" name="changeNetwork" value="Apply" <?=$disabled?>><input type="button" value="Done" onclick="done()"><?=$disabled ? "Array must be <strong>Stopped</strong> to change" : ""?>
|
||||
|
||||
</form>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 569 B |
@@ -0,0 +1,15 @@
|
||||
<?PHP
|
||||
/* Copyright 2015-2016, Lime Technology
|
||||
* Copyright 2015-2016, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
if ($_POST['#arg'][1] != 'none') unset($keys[$_POST['#section']]); // do nothing when only description has changed
|
||||
?>
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2016, Bergware International.
|
||||
* Copyright 2016, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$set = $ifname = $argv[1];
|
||||
$run = $set != 'none';
|
||||
$ini = parse_ini_file('/var/local/emhttp/network.ini',true); ksort($ini,SORT_NATURAL);
|
||||
$cfg = '/boot/config/network.cfg';
|
||||
|
||||
if ($run && file_exists($cfg)) {
|
||||
$old = parse_ini_file($cfg);
|
||||
$i = preg_replace('/[^\d]/','',$set);
|
||||
if (isset($old['SYSNICS'])) {
|
||||
// new syntax
|
||||
$ifname = isset($old['IFNAME'][$i]) ? $old['IFNAME'][$i] : $set;
|
||||
} else {
|
||||
// legacy syntax
|
||||
if ($i==0) $ifname = $old['BRIDGING']=='yes' ? $old['BRNAME'] : ($old['BONDING']=='yes' ? $old['BONDNAME'] : $set);
|
||||
}
|
||||
}
|
||||
|
||||
// stop interface with existing (old) configuration
|
||||
// don't execute when only interface description has changed
|
||||
if ($run) exec("/etc/rc.d/rc.inet1 {$ifname}_stop >/dev/null");
|
||||
|
||||
if ($bonding = isset($ini['eth0']) && $ini['eth0']['BONDING']=='yes') {
|
||||
$ini['eth0']['BONDNICS'] = str_replace(',',' ',$ini['eth0']['BONDNICS']);
|
||||
$members = explode(' ',trim(str_replace('eth0','',$ini['eth0']['BONDNICS'])));
|
||||
}
|
||||
|
||||
// create configuration file for all available interfaces
|
||||
$index = 0;
|
||||
$new = []; $new[] = "# Generated settings:";
|
||||
foreach ($ini as $name => $port) {
|
||||
if ($bonding && in_array($name,$members)) continue;
|
||||
$bridging = $port['BRIDGING']=='yes';
|
||||
$trunk = $port['TYPE']=='trunk';
|
||||
$i = 0; $id0 = 0;
|
||||
$iface = $bridging ? $port['BRNAME'] : ($bonding && $name=='eth0' ? $port['BONDNAME'] : $name);
|
||||
$new[] = "IFNAME[$index]=\"$iface\"";
|
||||
if ($set==$name) $ifname = $iface;
|
||||
foreach ($port as $key => $val) {
|
||||
if (preg_match('/^(TYPE|BONDING$|BRIDGING)/',$key)) continue;
|
||||
if (!$bonding && preg_match('/^(BONDING_MODE|BONDING_MIIMON|BONDNICS|BONDNAME)/',$key)) continue;
|
||||
if (!$bridging && preg_match('/^(BRSTP|BRFD|BRNICS|BRNAME)/',$key)) continue;
|
||||
list($item,$id) = explode(':',$key,2);
|
||||
if ($trunk && $id>0 && preg_match('/^(VLANID|USE_DHCP|IPADDR|NETMASK|DESCRIPTION)/',$key)) {
|
||||
if ($id0 != $id) {$id0 = $id; $i++;}
|
||||
$vlan = ",$i]";
|
||||
} else $vlan = '';
|
||||
if (!$vlan && preg_match('/^VLANID/',$key)) continue;
|
||||
$new[] = $item.(preg_match('/^(GATEWAY|DNS_SERVER|DHCP_KEEPRESOLV)/',$key)?'':'['.$index.($vlan?'':']')).$vlan."=\"$val\"";
|
||||
}
|
||||
if ($trunk) $new[] = "VLANS[$index]=\"".($i+1)."\"";
|
||||
$index++;
|
||||
}
|
||||
$new[] = "SYSNICS=\"$index\"";
|
||||
|
||||
file_put_contents($cfg,implode("\r\n",$new)."\r\n");
|
||||
// start interface with updated (new) configuration
|
||||
// don't execute when only interface description has changed
|
||||
if ($run) exec("/etc/rc.d/rc.inet1 {$ifname}_start >/dev/null &");
|
||||
exit(0);
|
||||
?>
|
||||
@@ -39,6 +39,9 @@ $shares = parse_ini_file('state/shares.ini',true);
|
||||
$sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
|
||||
$sec_afp = parse_ini_file('state/sec_afp.ini',true);
|
||||
|
||||
// Read network settings
|
||||
extract(parse_ini_file('state/network.ini',true));
|
||||
|
||||
// Merge SMART settings
|
||||
require_once 'include/CustomMerge.php';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user