mirror of
https://github.com/unraid/webgui.git
synced 2026-05-07 21:01:19 -05:00
b4a4b1bf9f
- Added a span around the checkbox for the MTU setting to enhance layout clarity. - Wrapped the service message in a span for better visual structure. This change aligns with ongoing efforts to refine input guidance and visual structure across the plugin.
976 lines
41 KiB
Plaintext
976 lines
41 KiB
Plaintext
Menu="NetworkSettings:100"
|
|
Title="_(Interface)_ eth0"
|
|
Tag="icon-ethernet"
|
|
---
|
|
<?php
|
|
/* Copyright 2005-2025, Lime Technology
|
|
* Copyright 2012-2025, 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.
|
|
*/
|
|
?>
|
|
<?php
|
|
$members = parse_ini_file('state/network.ini', true);
|
|
$build = false;
|
|
$template = "$docroot/webGui/EthX.page";
|
|
$ini = '/var/local/emhttp/network.ini';
|
|
$validIP4 = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}";
|
|
$validIP6 = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(:|([0-9a-fA-F]{1,4}:)+):(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)";
|
|
$enable = _('Enable default gateway');
|
|
$metric = _('metric value, a lower value is more preferred');
|
|
$jumbo = _('Enable jumbo frames');
|
|
$jumbo_1 = _('Allows the use of ethernet frames larger than 1500 bytes');
|
|
$jumbo_2 = _('Connectivity issues may occur when other devices do not support this feature');
|
|
$jumbo_3 = _('Or if they are improperly configured, use this feature with care');
|
|
$masks = [
|
|
'255.0.0.0' => '8', '255.255.0.0' => '16', '255.255.128.0' => '17', '255.255.192.0' => '18',
|
|
'255.255.224.0' => '19', '255.255.240.0' => '20', '255.255.248.0' => '21', '255.255.252.0' => '22',
|
|
'255.255.254.0' => '23', '255.255.255.0' => '24', '255.255.255.128' => '25', '255.255.255.192' => '26',
|
|
'255.255.255.224' => '27', '255.255.255.240' => '28', '255.255.255.248' => '29', '255.255.255.252' => '30'
|
|
];
|
|
|
|
// get available ethernet ports (excluding eth0)
|
|
exec("ls --indicator-style=none /sys/class/net|grep -P '^eth[1-9][0-9]*$'", $ports);
|
|
|
|
function locked($source, $port)
|
|
{
|
|
global $members;
|
|
foreach ($members as $member => $value) {
|
|
if ($member == $source) {
|
|
continue;
|
|
}
|
|
if ($value['BONDING'] == 'yes' && in_array($port, explode(',', $value['BONDNICS']))) {
|
|
return $value['BONDNAME'].' '.$member;
|
|
}
|
|
if ($value['BRIDGING'] == 'yes' && in_array($port, explode(',', $value['BRNICS']))) {
|
|
return $value['BRNAME'].' '.$member;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function vlanID($cfg)
|
|
{
|
|
return array_filter($cfg, function ($key) {return strpos($key, 'VLANID:') === 0;}, ARRAY_FILTER_USE_KEY);
|
|
}
|
|
|
|
function index($key)
|
|
{
|
|
return filter_var($key, FILTER_SANITIZE_NUMBER_INT);
|
|
}
|
|
|
|
function metric($eth, $prot, $index)
|
|
{
|
|
$system = '/sys/class/net';
|
|
$bridge = str_replace('eth', 'br', $eth);
|
|
$bond = str_replace('eth', 'bond', $eth);
|
|
$port = file_exists("$system/$bridge") ? $bridge : (file_exists("$system/$bond") ? $bond : $eth);
|
|
$metric = exec("ip -$prot route show default dev $port 2>/dev/null | grep -Pom1 ' metric \K\d+'");
|
|
if ($metric) {
|
|
return $metric + $index;
|
|
}
|
|
exec("ip -$prot route show default 2>/dev/null | grep -Po ' metric \K\d+'", $metrics);
|
|
return (count($metrics) ? max($metrics) : 0) + $index + 1;
|
|
}
|
|
|
|
// remove non-existing ethernet ports
|
|
foreach (glob("$docroot/webGui/Eth[1-9]*.page", GLOB_NOSORT) as $port) {
|
|
if (!in_array(strtolower(basename($port, '.page')), $ports)) {
|
|
@unlink($port);
|
|
$build = true;
|
|
}
|
|
}
|
|
|
|
// add new ethernet ports
|
|
foreach ($ports as $ethX) {
|
|
$file = "$docroot/webGui/".ucfirst($ethX).".page";
|
|
if (!file_exists($file)) {
|
|
$X = filter_var($ethX, FILTER_SANITIZE_NUMBER_INT);
|
|
file_put_contents($file, str_replace(['parentname:nnn','tabX','bondX','brX','ethX'], ['NetworkSettings:'.($X + 100),'tab'.($X + 1),'bond'.$X,'br'.$X,$ethX], file_get_contents($template)));
|
|
$build = true;
|
|
}
|
|
}
|
|
// enable interface only when VMs and Docker are stopped
|
|
$service = exec('pgrep --ns $$ libvirt') ? _('VM manager') : '';
|
|
$service .= exec('pgrep --ns $$ docker') ? ($service ? ' '._('and').' ' : '')._('Docker service') : '';
|
|
|
|
// eth0 port status
|
|
$no_eth0 = exec("ip -br link show eth0 | awk '{print \$2;exit}'") == 'DOWN';
|
|
|
|
// get VLAN interfaces
|
|
$vlan_eth0 = $sort_eth0 = [];
|
|
if (isset($eth0)) {
|
|
foreach (vlanID($eth0) as $key => $val) {
|
|
$vlan_eth0[] = index($key);
|
|
$sort_eth0[] = (int)$val;
|
|
}
|
|
}
|
|
array_multisort($sort_eth0, $vlan_eth0);
|
|
?>
|
|
|
|
<script>
|
|
<?if ($build):?>
|
|
refresh(); // automatically include new ethernet ports
|
|
<?endif;?>
|
|
Array.prototype.same = function(){return this.sort().filter(function(v,i,o){return i&&v===o[i-1]?v:0;}).length;}
|
|
|
|
const arg1 = {};
|
|
const run = {};
|
|
const eth0 = document.eth0_settings;
|
|
arg1.eth0 = 'none';
|
|
|
|
function presetRun(form) {
|
|
var port = form.name.replace('_settings','');
|
|
$(form).find('input[name^="DESCRIPTION:"]').each(function(){
|
|
var name = $(this).prop('name').replace(':','');
|
|
run[port+name] = $(this).val();
|
|
});
|
|
}
|
|
|
|
function signalRun(form, id) {
|
|
switch (id) {
|
|
case 1:
|
|
if (arg1.eth0 == 'none') arg1.eth0 = 'renew';
|
|
break;
|
|
case 2:
|
|
var port = form.name.replace('_settings','');
|
|
$(form).find('input[name^="DESCRIPTION:"]').each(function(){
|
|
var name = $(this).prop('name').replace(':','');
|
|
var data = $(this).val();
|
|
if (run[port+name] != data) {
|
|
run[port+name] = data;
|
|
port = 'none';
|
|
}
|
|
});
|
|
if (port != 'none') arg1[port] = port;
|
|
break;
|
|
}
|
|
}
|
|
|
|
function prepareSettings(form) {
|
|
var dns = document.dns_settings;
|
|
var port = form.name.replace('_settings','');
|
|
var bondnics = [], brnics = [];
|
|
for (var i=0,nic; nic=form.BONDNICS.options[i]; i++) {
|
|
if (nic.selected) {
|
|
bondnics.push(nic.value);
|
|
nic.selected = false;
|
|
}
|
|
}
|
|
nic = form.BONDNICS.options[0];
|
|
nic.value = bondnics.join(',');
|
|
nic.selected = true;
|
|
nic.disabled = false;
|
|
for (var i=0,nic; nic=form.BRNICS.options[i]; i++) {
|
|
if (nic.selected) {
|
|
brnics.push(nic.value);
|
|
nic.selected = false;
|
|
}
|
|
}
|
|
nic = form.BRNICS.options[0];
|
|
nic.value = form.BONDING.value=='yes' ? form.BONDNAME.value : brnics.join(',');
|
|
nic.selected = true;
|
|
nic.disabled = false;
|
|
if (brnics.length > 1) form.BRSTP.value = 'yes';
|
|
if ($(form).find('input[name="#arg[1]"]').val() == 'none') return true;
|
|
|
|
// enable form items for submission
|
|
$(form).find('input,select').prop('disabled',false);
|
|
if (form.TYPE.value == 'access') {
|
|
$(form).find('input[name^="VLANID:"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="DESCRIPTION:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="PROTOCOL:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="USE_DHCP:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="USE_DHCP6:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="IPADDR:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="IPADDR6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="NETMASK:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="NETMASK6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="GATEWAY:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="GATEWAY6:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('input[name^="METRIC:"]').not('input[name$=":0"]').prop('disabled',false).val('');
|
|
$(form).find('select[name^="PRIVACY6:"]').not('select[name$=":0"]').prop('disabled',false).val('');
|
|
} else {
|
|
var vlans = [];
|
|
$(form).find('input[name^="VLANID:"]').each(function(){vlans.push($(this).val());});
|
|
if (vlans.same()) {
|
|
swal({title:"_(VLAN assignment mismatch)_",text:"_(List of VLANs contains duplicate VLAN numbers)_",animation:'none',type:'error',html:true,confirmButtonText:"_(Ok)_"});
|
|
return false;
|
|
}
|
|
}
|
|
$(form).find('select[name^="PROTOCOL:"]').each(function() {
|
|
var protocol = $(this).val() || 'ipv4';
|
|
var i = $(this).prop('name').split(':')[1];
|
|
if (protocol == 'ipv6') {
|
|
$(form).find('input[name="IPADDR:'+i+'"]').val('');
|
|
$(form).find('select[name="NETMASK:'+i+'"]').val('');
|
|
$(form).find('input[name="GATEWAY:'+i+'"]').val('');
|
|
$(form).find('input[name="METRIC:'+i+'"]').val('');
|
|
}
|
|
if (protocol == 'ipv4') {
|
|
$(form).find('input[name="IPADDR6:'+i+'"]').val('');
|
|
$(form).find('input[name="NETMASK6:'+i+'"]').val('');
|
|
$(form).find('input[name="GATEWAY6:'+i+'"]').val('');
|
|
$(form).find('input[name="METRIC6:'+i+'"]').val('');
|
|
$(form).find('select[name="PRIVACY6:'+i+'"]').val('');
|
|
}
|
|
});
|
|
$(form).find('select[name^="USE_DHCP:"]').each(function() {
|
|
var i = $(this).prop('name').split(':')[1];
|
|
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
|
var gw4 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW4:'+i+'"]').prop('checked');
|
|
if (protocol != 'ipv6' && $(this).val() != 'no') {
|
|
$(form).find('input[name="IPADDR:'+i+'"]').val('');
|
|
$(form).find('input[name="GATEWAY:'+i+'"]').val('');
|
|
$(form).find('input[name="METRIC:'+i+'"]').val(gw4?'':'0');
|
|
}
|
|
});
|
|
$(form).find('select[name^="USE_DHCP6:"]').each(function() {
|
|
var i = $(this).prop('name').split(':')[1];
|
|
var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4';
|
|
var gw6 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW6:'+i+'"]').prop('checked');
|
|
if (protocol != 'ipv4' && $(this).val() != 'no') {
|
|
$(form).find('input[name="IPADDR6:'+i+'"]').val('');
|
|
$(form).find('input[name="GATEWAY6:'+i+'"]').val('');
|
|
$(form).find('input[name="METRIC6:'+i+'"]').val(gw6?'':'0');
|
|
}
|
|
if ($(this).val() != 'yes') $(form).find('input[name="PRIVACY6:'+i+'"]').val('');
|
|
});
|
|
if (port == 'eth0') {
|
|
$(dns).find('select,input').each(function(){
|
|
var name = $(this).prop('name');
|
|
var data = $(this).val();
|
|
$(form).find('input[name="'+name+'"]').val(data);
|
|
});
|
|
}
|
|
var metrics = [], metrics6 = [];
|
|
$(form).find('input[name^="METRIC:"]').each(function(){if($(this).val() > 0) metrics.push($(this).val());});
|
|
$(form).find('input[name^="METRIC6:"]').each(function(){if($(this).val() > 0) metrics6.push($(this).val());});
|
|
if (metrics.same() || metrics6.same()) {
|
|
swal({title:"_(Duplicate metrics)_", text:"_(List of default gateways contains duplicate metric values)_", animation:'none', type:'error', html:true, confirmButtonText:"_(Ok)_"});
|
|
return false;
|
|
}
|
|
// force default MTU if jumbo frames are not enabled
|
|
if ($(form).find('input[name="USE_MTU"]').prop('checked') == false) $(form).find('input[name="MTU"]').val('');
|
|
$(form).find('input[name="#arg[1]"]').val(arg1[port]);
|
|
setTimeout(refresh, 25000);
|
|
return true;
|
|
}
|
|
|
|
function selectProtocol(form, index, step) {
|
|
var port = form.name.replace('_settings','');
|
|
if (index == null) {
|
|
$(form).find('select[name^="PROTOCOL:"]').each(function() {
|
|
var protocol = $(this).val() || 'ipv4';
|
|
var i = $(this).prop('name').split(':')[1];
|
|
var net4 = $('.'+'ipv4-'+port+'-'+i);
|
|
var net6 = $('.'+'ipv6-'+port+'-'+i);
|
|
var more4 = $('.'+'more-ipv4-'+port+'-'+i);
|
|
var more6 = $('.'+'more-ipv6-'+port+'-'+i);
|
|
var priv6 = $('.'+'priv-ipv6-'+port+'-'+i);
|
|
var gw4 = $('.'+'gw4-'+port+'-'+i);
|
|
var gw6 = $('.'+'gw6-'+port+'-'+i);
|
|
switch (protocol) {
|
|
case 'ipv4': net4.show(); net6.hide(); break;
|
|
case 'ipv6': net4.hide(); net6.show(); break;
|
|
case 'ipv4+ipv6': net4.show(); net6.show(); break;
|
|
}
|
|
<?if ($service):?>
|
|
more4.hide();
|
|
more6.hide();
|
|
priv6.hide();
|
|
<?else:?>
|
|
var dhcp4 = $(form).find('select[name="USE_DHCP:'+i+'"]').val();
|
|
var dhcp6 = $(form).find('select[name="USE_DHCP6:'+i+'"]').val();
|
|
if (dhcp4 == 'no') {
|
|
more4.show();
|
|
gw4.show();
|
|
} else if (dhcp4 == 'yes') {
|
|
more4.hide();
|
|
gw4.show();
|
|
} else {
|
|
more4.hide();
|
|
gw4.hide();
|
|
}
|
|
if (dhcp6 == 'no') {
|
|
more6.show();
|
|
priv6.hide();
|
|
gw6.show();
|
|
} else if (dhcp6 == 'yes') {
|
|
more6.hide();
|
|
priv6.show();
|
|
gw6.show();
|
|
} else {
|
|
more6.hide();
|
|
priv6.hide();
|
|
gw6.hide();
|
|
}
|
|
<?endif;?>
|
|
checkNetworkSettings(form, i);
|
|
});
|
|
} else {
|
|
var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4';
|
|
var net4 = $('.'+'ipv4-'+port+'-'+index);
|
|
var net6 = $('.'+'ipv6-'+port+'-'+index);
|
|
var more4 = $('.'+'more-ipv4-'+port+'-'+index);
|
|
var more6 = $('.'+'more-ipv6-'+port+'-'+index);
|
|
var priv6 = $('.'+'priv-ipv6-'+port+'-'+index);
|
|
var gw4 = $('.'+'gw4-'+port+'-'+index);
|
|
var gw6 = $('.'+'gw6-'+port+'-'+index);
|
|
switch (protocol) {
|
|
case 'ipv4': net4.show(step); net6.hide(step); if (port=='eth0') {$('#dns4').show(step); $('#dns6').hide(step);} break;
|
|
case 'ipv6': net4.hide(step); net6.show(step); if (port=='eth0') {$('#dns4').hide(step); $('#dns6').show(step);} break;
|
|
case 'ipv4+ipv6': net4.show(step); net6.show(step); if (port=='eth0') {$('#dns4').show(step); $('#dns6').show(step);} break;
|
|
}
|
|
var dhcp4 = $(form).find('select[name="USE_DHCP:'+index+'"]').val();
|
|
var dhcp6 = $(form).find('select[name="USE_DHCP6:'+index+'"]').val();
|
|
if (dhcp4 == 'no') {
|
|
more4.show(step);
|
|
gw4.show();
|
|
} else if (dhcp4 == 'yes') {
|
|
more4.hide(step);
|
|
gw4.show();
|
|
} else {
|
|
more4.hide(step);
|
|
gw4.hide();
|
|
}
|
|
if (dhcp6 == 'no') {
|
|
more6.show(step);
|
|
priv6.hide(step);
|
|
gw6.show();
|
|
} else if (dhcp6 == 'yes') {
|
|
more6.hide(step);
|
|
priv6.show(step);
|
|
gw6.show();
|
|
} else {
|
|
more6.hide(step);
|
|
priv6.hide(step);
|
|
gw6.hide();
|
|
}
|
|
checkNetworkSettings(form, index);
|
|
}
|
|
}
|
|
|
|
function selectGW(form, prot, index, step) {
|
|
var port = form.name.replace('_settings','');
|
|
if (prot == null) {
|
|
$(form).find('input[name^="USE_GW4:"]').each(function(){
|
|
var i = $(this).prop('name').split(':')[1];
|
|
var state = $(this).prop('checked');
|
|
var gw = $('.more-gw4-'+port+'-'+i);
|
|
if (state) gw.show(); else gw.hide();
|
|
});
|
|
$(form).find('input[name^="USE_GW6"]').each(function(){
|
|
var i = $(this).prop('name').split(':')[1];
|
|
var state = $(this).prop('checked');
|
|
var gw = $('.more-gw6-'+port+'-'+i);
|
|
if (state) gw.show(); else gw.hide();
|
|
});
|
|
} else {
|
|
var state = $(form).find('input[name="USE_GW'+prot+':'+index+'"]').prop('checked');
|
|
var gw = $('.more-gw'+prot+'-'+port+'-'+index);
|
|
if (state) gw.show(step); else gw.hide(step);
|
|
}
|
|
}
|
|
|
|
function selectMTU(form) {
|
|
let jumbo = $(form).find('input[name="USE_MTU"]').prop('checked');
|
|
$(form).find('input[name="MTU"]').prop('disabled',!jumbo);
|
|
}
|
|
|
|
function checkNetworkSettings(form, index) {
|
|
var disabled4 = $(form).find('select[name="USE_DHCP:'+index+'"]').val()!='no';
|
|
var disabled6 = $(form).find('select[name="USE_DHCP6:'+index+'"]').val()!='no';
|
|
var protocol = $(form).find('select[name="PROTOCOL:'+index+'"]').val() || 'ipv4';
|
|
if (protocol != 'ipv6') {
|
|
$(form).find('input[name="IPADDR:'+index+'"]').prop('disabled',disabled4).prop('required',!disabled4);
|
|
$(form).find('select[name="NETMASK:'+index+'"]').prop('disabled',disabled4);
|
|
$(form).find('input[name="GATEWAY:'+index+'"]').prop('disabled',disabled4);
|
|
}
|
|
if (protocol != 'ipv4') {
|
|
$(form).find('input[name="IPADDR6:'+index+'"]').prop('disabled',disabled6).prop('required',!disabled6);
|
|
$(form).find('input[name="NETMASK6:'+index+'"]').prop('disabled',disabled6).prop('required',!disabled6);
|
|
$(form).find('input[name="GATEWAY6:'+index+'"]').prop('disabled',disabled6);
|
|
var privacy = $(form).find('select[name="PRIVACY6:'+index+'"]');
|
|
privacy.prop('disabled',!disabled6);
|
|
}
|
|
if (form.name=='eth0_settings' && index==0) {
|
|
checkDNSsettings(form);
|
|
checkDNS6settings(form);
|
|
}
|
|
}
|
|
|
|
function checkDNSsettings(form, step) {
|
|
var dns = document.dns_settings;
|
|
if ($(form).find('select[name="USE_DHCP:0"]').val()=='no') {
|
|
dns.DHCP_KEEPRESOLV.value = 'yes';
|
|
dns.DHCP_KEEPRESOLV.disabled = true;
|
|
} else {
|
|
dns.DHCP_KEEPRESOLV.disabled = false;
|
|
}
|
|
var disabled = dns.DHCP_KEEPRESOLV.value=='no';
|
|
var protocol = $(form).find('select[name="PROTOCOL:0"]').val() || 'ipv4';
|
|
if (disabled) $('#dns4server').hide(step); else $('#dns4server').show(step);
|
|
if (protocol != 'ipv6') {
|
|
dns.DNS_SERVER1.required = !disabled;
|
|
$('#dns4').show();
|
|
}
|
|
}
|
|
|
|
function checkDNS6settings(form, step) {
|
|
var dns = document.dns_settings;
|
|
if ($(form).find('select[name="USE_DHCP6:0"]').val()=='no') {
|
|
dns.DHCP6_KEEPRESOLV.value = 'yes';
|
|
dns.DHCP6_KEEPRESOLV.disabled = true;
|
|
} else {
|
|
dns.DHCP6_KEEPRESOLV.disabled = false;
|
|
}
|
|
var disabled = dns.DHCP6_KEEPRESOLV.value=='no';
|
|
var protocol = $(form).find('select[name="PROTOCOL:0"]').val() || 'ipv4';
|
|
if (disabled) $('#dns6server').hide(step); else $('#dns6server').show(step);
|
|
if (protocol != 'ipv4') {
|
|
dns.DNS6_SERVER1.required = !disabled;
|
|
$('#dns6').show();
|
|
}
|
|
}
|
|
|
|
function checkBondingSettings(form, ctrl) {
|
|
var disabled = form.BONDING.value=='no';
|
|
var mode = form.BONDING_MODE.value;
|
|
var port = form.name.replace('_settings','');
|
|
if (ctrl>=0) {
|
|
var step = ctrl==0 ? null : 'slow';
|
|
if (disabled) {
|
|
$('#bond-members-'+port).hide(step);
|
|
} else {
|
|
$('#bond-members-'+port).show(step);
|
|
$('#bond-'+port).dropdownchecklist('destroy').dropdownchecklist({emptyText:'None', width:166});
|
|
}
|
|
if (ctrl==1) checkBridgingSettings(form,1);
|
|
}
|
|
if (mode==1 || mode>4 || disabled) {$('#attention0').hide();} else {$('#attention0').show();}
|
|
}
|
|
|
|
function checkBridgingSettings(form, ctrl) {
|
|
var port = form.name.replace('_settings','');
|
|
var step = ctrl==0 ? null : 'slow';
|
|
var i = 0;
|
|
if (form.BRIDGING.value=='yes' && form.BONDING.value=='no') {
|
|
$('#bridge-members-'+port).show(step);
|
|
$('#bridge-'+port).dropdownchecklist('destroy').dropdownchecklist({emptyText:'None', width:166});
|
|
} else {
|
|
$('#bridge-members-'+port).hide(step);
|
|
}
|
|
}
|
|
|
|
function checkNetworkAccess(form) {
|
|
var port = form.name.replace('_settings','');
|
|
if (form.TYPE.value=='access') {
|
|
$('.access-'+port).hide();
|
|
$('#button-vlan-'+port).hide();
|
|
$('#button-add-'+port).hide();
|
|
$(form).find('input[name^="VLANID:"]').prop('required',false);
|
|
} else {
|
|
$('.access-'+port).show();
|
|
if ($(form).find('input[name^="VLANID:"]').length>0) {$('#button-vlan-'+port).show();$('#button-add-'+port).hide();} else $('#button-add-'+port).show();
|
|
$(form).find('input[name^="VLANID:"]').prop('required',true);
|
|
}
|
|
}
|
|
|
|
function addVLAN(port) {
|
|
$('input[value="<?=_("Apply")?>"],input[value="Apply"]').prop('disabled',false);
|
|
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);
|
|
$('form[name="'+$(element).parent().parent().prop('name')+'"]').find('select').first().trigger('change');
|
|
}
|
|
|
|
function removeVLAN(element) {
|
|
var id = $(element).prop('id').split('-');
|
|
$(element).remove();
|
|
$('#view-'+id[1]).find('select').first().trigger('change');
|
|
}
|
|
|
|
function showVLAN(port) {
|
|
var button1 = $('#button-vlan-'+port);
|
|
var button2 = $('#button-add-'+port).hide();
|
|
var list = $('#vlan-list-'+port);
|
|
var show = "_(Show)_";
|
|
var hide = "_(Hide)_";
|
|
if (list.is(':hidden')) {
|
|
button1.val(hide);
|
|
button2.show();
|
|
list.show('slow');
|
|
} else {
|
|
button1.val(show);
|
|
button2.hide();
|
|
list.hide('slow');
|
|
}
|
|
}
|
|
|
|
function disableForm(form) {
|
|
$(form).find('input,select').not('input[value="_(Done)_"],input.form').prop('disabled',true);
|
|
$(form).find('input[name^="DESCRIPTION"],input[name^="#"]').prop('disabled',false);
|
|
}
|
|
|
|
function portcheck(port) {
|
|
$.post('/webGui/include/CheckPort.php',{port:port},function(msg) {
|
|
var html = $('#user-notice').html();
|
|
if (!html || html.indexOf(port)>0) showNotice(msg);
|
|
setTimeout(function(){portcheck(port);},5000);
|
|
});
|
|
}
|
|
|
|
function portToggle(port, cmd) {
|
|
$.post('/webGui/include/PortToggle.php',{port:port,cmd:cmd},function(){refresh();});
|
|
}
|
|
|
|
$(function() {
|
|
const ctrl = "<span id='wait_eth0' class='status red-text hide' style='font-size:1.2rem;font-style:italic'><i class='fa fa-spinner fa-spin'></i> _(Please wait)_... _(configuring interface)_</span>";
|
|
const form = document.eth0_settings;
|
|
const dns = document.dns_settings;
|
|
<?if (!$service):?>
|
|
$('#tab1').bind({click:function(){
|
|
$('#bond-eth0').dropdownchecklist('destroy').dropdownchecklist({emptyText:"_(None)_", width:166});
|
|
$('#bridge-eth0').dropdownchecklist('destroy').dropdownchecklist({emptyText:"_(None)_", width:166});
|
|
}});
|
|
<?endif;?>
|
|
$('#bond-eth0').dropdownchecklist({emptyText:"_(None)_", width:166});
|
|
$('#bridge-eth0').dropdownchecklist({emptyText:"_(None)_", width:166});
|
|
checkBondingSettings(form,0);
|
|
checkBridgingSettings(form,0);
|
|
checkNetworkAccess(form);
|
|
selectProtocol(form);
|
|
selectGW(form);
|
|
selectMTU(form);
|
|
<?if ($service):?>
|
|
disableForm(form);
|
|
$('#bond-eth0').dropdownchecklist('disable');
|
|
$('#bridge-eth0').dropdownchecklist('disable');
|
|
<?endif;?>
|
|
checkDNSsettings(form);
|
|
checkDNS6settings(form);
|
|
$('.tabs').append(ctrl);
|
|
portcheck('eth0');
|
|
presetRun(form);
|
|
$(dns).find('select,input').each(function(){$(this).on('input change',function() {
|
|
$(form).find('input[value="<?=_("Apply")?>"],input[value="Apply"]').prop('disabled',false);
|
|
$(form).find('input[value="<?=_("Done")?>"],input[value="Done"]').val("<?=_('Reset')?>").prop('onclick',null).off('click').click(function(){refresh($(form).offset().top);});
|
|
});});
|
|
});
|
|
|
|
function networkInfo(port, vlan) {
|
|
$.post('/webGui/include/NetworkInfo.php',{port:port,vlan:vlan},function(text) {
|
|
swal({title:"_(Network Info)_",text:text,animation:'none',html:true,confirmButtonText:"_(Ok)_"});
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<div class="shade">
|
|
<form name="dns_settings" onchange="signalRun(this,1)">
|
|
<div markdown="1" id="dns4" class="hide">
|
|
_(IPv4 DNS server assignment)_:
|
|
: <select name="DHCP_KEEPRESOLV" onchange="checkDNSsettings(eth0,'slow')">
|
|
<?=mk_option(_var($eth0, 'DHCP_KEEPRESOLV'), "no", _("Automatic"))?>
|
|
<?=mk_option(_var($eth0, 'DHCP_KEEPRESOLV'), "yes", _("Static"))?>
|
|
</select>
|
|
|
|
:eth_ipv4_dns_server_assignment_help:
|
|
|
|
<div markdown="1" id="dns4server" class="hide">
|
|
_(IPv4 DNS server)_ 1:
|
|
: <input type="text" name="DNS_SERVER1" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS_SERVER1')?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
|
|
:eth_ipv4_dns_server_help:
|
|
|
|
_(IPv4 DNS server)_ 2:
|
|
: <input type="text" name="DNS_SERVER2" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS_SERVER2')?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
|
|
:eth_ipv4_dns_server2_help:
|
|
|
|
_(IPv4 DNS server)_ 3:
|
|
: <input type="text" name="DNS_SERVER3" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS_SERVER3')?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
|
|
:eth_ipv4_dns_server3_help:
|
|
|
|
</div>
|
|
</div>
|
|
<div markdown="1" id="dns6" class="hide">
|
|
_(IPv6 DNS server assignment)_:
|
|
: <select name="DHCP6_KEEPRESOLV" onchange="checkDNS6settings(eth0,'slow')">
|
|
<?=mk_option(_var($eth0, 'DHCP6_KEEPRESOLV'), "no", _("Automatic"))?>
|
|
<?=mk_option(_var($eth0, 'DHCP6_KEEPRESOLV'), "yes", _("Static"))?>
|
|
</select>
|
|
|
|
:eth_ipv6_dns_server_assignment_help:
|
|
|
|
<div markdown="1" id="dns6server" class="hide">
|
|
_(IPv6 DNS server)_ 1:
|
|
: <input type="text" name="DNS6_SERVER1" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS6_SERVER1')?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
|
|
:eth_ipv6_dns_server_help:
|
|
|
|
_(IPv6 DNS server)_ 2:
|
|
: <input type="text" name="DNS6_SERVER2" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS6_SERVER2')?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
|
|
:eth_ipv6_dns_server2_help:
|
|
|
|
_(IPv6 DNS server)_ 3:
|
|
: <input type="text" name="DNS6_SERVER3" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'DNS6_SERVER3')?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
|
|
:eth_ipv6_dns_server3_help:
|
|
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<form markdown="1" name="eth0_settings" method="POST" action="/update.php" target="progressFrame" onchange="signalRun(this,2)" 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="br0">
|
|
<input type="hidden" name="BRSTP" value="no">
|
|
<input type="hidden" name="BRFD" value="0">
|
|
<input type="hidden" name="DHCP_KEEPRESOLV" value="">
|
|
<input type="hidden" name="DNS_SERVER1" value="">
|
|
<input type="hidden" name="DNS_SERVER2" value="">
|
|
<input type="hidden" name="DNS_SERVER3" value="">
|
|
<input type="hidden" name="DHCP6_KEEPRESOLV" value="">
|
|
<input type="hidden" name="DNS6_SERVER1" value="">
|
|
<input type="hidden" name="DNS6_SERVER2" value="">
|
|
<input type="hidden" name="DNS6_SERVER3" value="">
|
|
|
|
_(Interface description)_:
|
|
: <input type="text" name="DESCRIPTION:0" maxlength="80" autocomplete="off" spellcheck="false" value="<?=htmlspecialchars(_var($eth0, "DESCRIPTION:0"))?>">
|
|
<input type="button" class="form" value="_(Info)_" onclick="networkInfo('eth0')">
|
|
|
|
:eth_interface_description_help:
|
|
|
|
_(MAC address)_:
|
|
: <?=strtoupper(exec("ip link show eth0|grep -Pom1 'ether \K\S+'"))?>
|
|
|
|
:eth_mac_address_help:
|
|
|
|
_(Enable bonding)_:
|
|
: <select name="BONDING" onchange="checkBondingSettings(this.form,1)">
|
|
<?=mk_option(_var($eth0, 'BONDING'), "no", _("No"))?>
|
|
<?=mk_option(_var($eth0, 'BONDING'), "yes", _("Yes"))?>
|
|
</select>
|
|
|
|
:eth_enable_bonding_help:
|
|
|
|
<div markdown="1" id="bond-members-eth0" class="'hide">
|
|
_(Bonding mode)_:
|
|
: <select name="BONDING_MODE" onchange="checkBondingSettings(this.form,-1)">
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "0", _("balance-rr")." (0)")?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "1", _("active-backup")." (1)", isset($eth0['BONDING_MODE']) ? '' : 'selected')?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "2", _("balance-xor")." (2)")?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "3", _("broadcast")." (3)")?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "4", _("802.3ad")." (4)")?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "5", _("balance-tlb")." (5)")?>
|
|
<?=mk_option(_var($eth0, 'BONDING_MODE'), "6", _("balance-alb")." (6)")?>
|
|
</select>
|
|
<span id="attention0" class="hide">**_(Attention)_:** _(this mode requires a network switch with proper setup and support)_...</span>
|
|
|
|
:eth_bonding_mode_help:
|
|
|
|
_(Bonding members of)_ bond0:
|
|
: <select id="bond-eth0" name="BONDNICS" multiple="multiple" class="'hide">
|
|
<?=mk_option(_var($eth0, 'BONDNICS'), 'eth0', 'eth0', 'selected disabled')?>
|
|
<?foreach ($ports as $port):?>
|
|
<?if (!locked('eth0',$port)) echo mk_option_check(_var($eth0,'BONDNICS'),$port,$port)?>
|
|
<?endforeach;?>
|
|
</select>
|
|
|
|
:eth_bonding_members_help:
|
|
|
|
</div>
|
|
_(Enable bridging)_:
|
|
: <select name="BRIDGING" onchange="checkBridgingSettings(this.form,1)">
|
|
<?=mk_option(_var($eth0, 'BRIDGING'), "no", _("No"))?>
|
|
<?=mk_option(_var($eth0, 'BRIDGING'), "yes", _("Yes"))?>
|
|
</select>
|
|
|
|
:eth_enable_bridging_help:
|
|
|
|
<div markdown="1" id="bridge-members-eth0" class="'hide">
|
|
_(Bridging members of)_ br0:
|
|
: <select id="bridge-eth0" name="BRNICS" multiple="multiple" class="'hide">
|
|
<?=mk_option(_var($eth0, 'BRNICS'), 'eth0', 'eth0', 'selected disabled')?>
|
|
<?foreach ($ports as $port):?>
|
|
<?if (!locked('eth0',$port)) echo mk_option_check(_var($eth0,'BRNICS'),$port,$port)?>
|
|
<?endforeach;?>
|
|
</select>
|
|
|
|
:eth_bridging_members_help:
|
|
|
|
</div>
|
|
_(Network protocol)_:
|
|
: <select name="PROTOCOL:0" onchange="selectProtocol(this.form,0,'slow')">
|
|
<?=mk_option(_var($eth0, "PROTOCOL:0"), 'ipv4', _('IPv4 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:0"), 'ipv6', _('IPv6 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:0"), 'ipv4+ipv6', _('IPv4 + IPv6'))?>
|
|
</select>
|
|
|
|
:eth_network_protocol_help:
|
|
|
|
<div markdown="1" class="ipv4-eth0-0 hide">
|
|
_(IPv4 address assignment)_:
|
|
: <select name="USE_DHCP:0" onchange="selectProtocol(this.form,0,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP:0"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP:0"), 'no', _('Static'))?>
|
|
</select>
|
|
|
|
:eth_ipv4_address_assignment_help:
|
|
|
|
<div markdown="1" class="more-ipv4-eth0-0 hide">
|
|
_(IPv4 address)_:
|
|
: <input type="text" name="IPADDR:0" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "IPADDR:0")?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">/<select name="NETMASK:0" class="slim">
|
|
<?foreach ($masks as $mask => $prefix) echo mk_option(_var($eth0,"NETMASK:0"), $mask, $prefix, _var($eth0,"NETMASK:0")=='' && $prefix=='24'?'selected':'');?>
|
|
</select>
|
|
|
|
:eth_ipv4_address_help:
|
|
|
|
_(IPv4 default gateway)_:
|
|
: <input type="text" name="GATEWAY:0" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "GATEWAY:0")?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
<input type="text" name="METRIC:0" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "METRIC:0") ?: metric('eth0', 4, 0)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
:eth_ipv4_default_gateway_help:
|
|
|
|
</div>
|
|
</div>
|
|
<div markdown="1" class="ipv6-eth0-0 hide">
|
|
_(IPv6 address assignment)_:
|
|
: <select name="USE_DHCP6:0" onchange="selectProtocol(this.form,0,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:0"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:0"), 'no', _('Static'))?>
|
|
</select>
|
|
|
|
:eth_ipv6_address_assignment_help:
|
|
|
|
<div markdown="1" class="more-ipv6-eth0-0 hide">
|
|
_(IPv6 address)_:
|
|
: <input type="text" name="IPADDR6:0" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "IPADDR6:0")?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">/<input type="number" name="NETMASK6:0" min="7" max="128" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "NETMASK6:0", "64")?>" class="slim">
|
|
|
|
:eth_ipv6_address_help:
|
|
|
|
_(IPv6 default gateway)_:
|
|
: <input type="text" name="GATEWAY6:0" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "GATEWAY6:0")?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
<input type="text" name="METRIC6:0" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "METRIC6:0") ?: metric('eth0', 6, 0)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
:eth_ipv6_default_gateway_help:
|
|
|
|
</div>
|
|
<div markdown="1" class="priv-ipv6-eth0-0 hide">
|
|
_(IPv6 privacy extensions)_:
|
|
: <select name="PRIVACY6:0">
|
|
<?=mk_option(_var($eth0, "PRIVACY6:0"), "0", _("Disabled"))?>
|
|
<?=mk_option(_var($eth0, "PRIVACY6:0"), "2", _("Enabled"))?>
|
|
</select>
|
|
|
|
:eth_ipv6_privacy_extensions_help:
|
|
|
|
</div>
|
|
</div>
|
|
_(Desired MTU)_:
|
|
: <input type="number" name="MTU" min="68" max="9198" autocomplete="off" spellcheck="false" value="<?=_var($eth0, 'MTU')?>" class="narrow" placeholder="1500" <?=(_var($eth0, 'MTU') != '' || _var($eth0, 'USE_MTU')) ? '' : 'disabled'?>>
|
|
<span><input type="checkbox" name="USE_MTU" onchange="selectMTU(this.form)" <?=_var($eth0, 'USE_MTU') ? 'checked' : ''?>><?=$jumbo?> <i class="fa fa-info-circle blue-text hand" title="<?=$jumbo_1?>. <?=$jumbo_2?>. <?=$jumbo_3?>!"></i></span>
|
|
|
|
:eth_desired_mtu_help:
|
|
|
|
_(Enable VLANs)_:
|
|
: <select name="TYPE" onchange="checkNetworkAccess(this.form)">
|
|
<?=mk_option(_var($eth0, 'TYPE'), 'access', _('No'))?>
|
|
<?=mk_option(_var($eth0, 'TYPE'), 'trunk', _('Yes'))?>
|
|
</select>
|
|
<input type="button" id="button-vlan-eth0" class="form hide" value="_(Show)_" onclick="showVLAN('eth0')">
|
|
|
|
:eth_enable_vlans_help:
|
|
|
|
<div id="index-eth0-0"></div>
|
|
<div id="vlan-list-eth0" class="hide">
|
|
<?foreach ($vlan_eth0 as $i):?>
|
|
<div markdown="1" id="index-eth0-<?=$i?>" class="access-eth0 shade hide">
|
|
_(Interface description)_:
|
|
: <input type="text" name="DESCRIPTION:<?=$i?>" maxlength="80" autocomplete="off" spellcheck="false" value="<?=htmlspecialchars(_var($eth0, "DESCRIPTION:$i"))?>">
|
|
<input type="button" class="form" value="_(Info)_" onclick="networkInfo('eth0',<?=_var($eth0, "VLANID:$i")?>)">
|
|
|
|
:eth_interface_description_help:
|
|
|
|
_(VLAN number)_:
|
|
: <input type="number" name="VLANID:<?=$i?>" min="1" max="4095" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "VLANID:$i")?>" class="narrow gap" required>
|
|
<?if (!$service):?><input type="button" class="form" value="_(Delete VLAN)_" onclick="removeVLAN($('#index-eth0-<?=$i?>'))"><?endif;?>
|
|
|
|
:eth_vlan_number_help:
|
|
|
|
_(Network protocol)_:
|
|
: <select name="PROTOCOL:<?=$i?>" onchange="selectProtocol(this.form,<?=$i?>,'slow')">
|
|
<?=mk_option(_var($eth0, "PROTOCOL:$i"), 'ipv4', _('IPv4 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:$i"), 'ipv6', _('IPv6 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:$i"), 'ipv4+ipv6', _('IPv4 + IPv6'))?>
|
|
</select>
|
|
|
|
:eth_network_protocol_help:
|
|
|
|
<div markdown="1" class="ipv4-eth0-<?=$i?> hide">
|
|
_(IPv4 address assignment)_:
|
|
: <select name="USE_DHCP:<?=$i?>" class="ctrl" onchange="selectProtocol(this.form,<?=$i?>,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP:$i"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP:$i"), 'no', _('Static'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP:$i"), '', _('None'))?>
|
|
</select>
|
|
<span class="gw4-eth0-<?=$i?> hide"><input type="checkbox" name="USE_GW4:<?=$i?>" onchange="selectGW(this.form,4,<?=$i?>,'slow')" <?=_var($eth0, "USE_GW:$i") ? 'checked' : ''?>><?=$enable?></span>
|
|
|
|
:eth_ipv4_address_assignment_help:
|
|
|
|
<div markdown="1" class="more-ipv4-eth0-<?=$i?> hide">
|
|
_(IPv4 address)_:
|
|
: <input type="text" name="IPADDR:<?=$i?>" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "IPADDR:$i")?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">/<select name="NETMASK:<?=$i?>" class="slim">
|
|
<?foreach ($masks as $mask => $prefix) echo mk_option(_var($eth0,"NETMASK:$i"), $mask, $prefix, _var($eth0,"NETMASK:$i")=='' && $prefix=='24'?'selected':'');?>
|
|
</select>
|
|
|
|
:eth_ipv4_address_help:
|
|
|
|
<div markdown="1" class="more-gw4-eth0-<?=$i?> hide">
|
|
_(IPv4 default gateway)_:
|
|
: <input type="text" name="GATEWAY:<?=$i?>" maxlength="15" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "GATEWAY:$i")?>" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
<input type="text" name="METRIC:<?=$i?>" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "METRIC:$i") ?: metric('eth0.<?=_var($eth0,"VLANID:$i")?>', 4, $i)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
:eth_ipv4_default_gateway_help:
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div markdown="1" class="ipv6-eth0-<?=$i?> hide">
|
|
_(IPv6 address assignment)_:
|
|
: <select name="USE_DHCP6:<?=$i?>" class="ctrl" onchange="selectProtocol(this.form,<?=$i?>,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:$i"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:$i"), 'no', _('Static'))?>
|
|
<?if ($i>0):?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:$i"), '', _('None'))?>
|
|
<?endif;?>
|
|
</select>
|
|
<span class="gw6-eth0-<?=$i?> hide"><input type="checkbox" name="USE_GW6:<?=$i?>" onchange="selectGW(this.form,6,<?=$i?>,'slow')" <?=_var($eth0, "USE_GW6:$i") ? 'checked' : ''?>><?=$enable?></span>
|
|
|
|
:eth_ipv6_address_assignment_help:
|
|
|
|
<div markdown="1" class="more-ipv6-eth0-<?=$i?> hide">
|
|
_(IPv6 address)_:
|
|
: <input type="text" name="IPADDR6:<?=$i?>" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "IPADDR6:$i")?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">/<input type="number" name="NETMASK6:<?=$i?>" min="7" max="128" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "NETMASK6:$i", "64")?>" class="slim">
|
|
|
|
:eth_ipv6_address_help:
|
|
|
|
<div markdown="1" class="more-gw6-eth0-<?=$i?> hide">
|
|
_(IPv6 default gateway)_:
|
|
: <input type="text" name="GATEWAY6:<?=$i?>" maxlength="39" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "GATEWAY6:$i")?>" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
<input type="text" name="METRIC6:<?=$i?>" min="0" max="9999" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "METRIC6:$i") ?: metric('eth0.<?=_var($eth0,"VLANID:$i")?>', 6, $i)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
:eth_ipv6_default_gateway_help:
|
|
|
|
</div>
|
|
</div>
|
|
<div markdown="1" class="priv-ipv6-eth0-<?=$i?> hide">
|
|
_(IPv6 privacy extensions)_:
|
|
: <select name="PRIVACY6:<?=$i?>">
|
|
<?=mk_option(_var($eth0, "PRIVACY6:$i"), "0", _("Disabled"))?>
|
|
<?=mk_option(_var($eth0, "PRIVACY6:$i"), "2", _("Enabled"))?>
|
|
</select>
|
|
|
|
:eth_ipv6_privacy_extensions_help:
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?endforeach;?>
|
|
</div>
|
|
|
|
|
|
: <input type="submit" value="_(Apply)_" onclick="$('#wait_eth0').show()" disabled><input type="button" value="_(Done)_" onclick="done()">
|
|
<?if (!$service):?>
|
|
<input type="button" id="button-add-eth0" class="hide" value="_(Add VLAN)_" onclick="addVLAN('eth0')">
|
|
<?else:?><span><?=sprintf(_('Stop **%s** to make changes, see'), $service).' (<a href="/Settings">'._('Settings').'</a>)'?></span><?endif;?>
|
|
</form>
|
|
|
|
<script markdown="1" type="text/html" id="network-template-eth0">
|
|
<div markdown="1" id="index-eth0-INDEX" class="access-eth0 shade">
|
|
_(Interface description)_:
|
|
: <input type="text" name="DESCRIPTION:INDEX" maxlength="80" autocomplete="off" spellcheck="false" value="<?=htmlspecialchars(_var($eth0, "DESCRIPTION:INDEX"))?>">
|
|
|
|
_(VLAN number)_:
|
|
: <input type="number" name="VLANID:INDEX" min="1" max="4095" autocomplete="off" spellcheck="false" value="<?=_var($eth0, "VLANID:INDEX")?>" class="narrow gap" required>
|
|
<input type="button" class="form" value="_(Delete VLAN)_" onclick="removeVLAN($('#index-eth0-INDEX'))">
|
|
|
|
_(Network protocol)_:
|
|
: <select name="PROTOCOL:INDEX" onchange="selectProtocol(this.form,INDEX,'slow')">
|
|
<?=mk_option(_var($eth0, "PROTOCOL:INDEX"), 'ipv4', _('IPv4 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:INDEX"), 'ipv6', _('IPv6 only'))?>
|
|
<?=mk_option(_var($eth0, "PROTOCOL:INDEX"), 'ipv4+ipv6', _('IPv4 + IPv6'))?>
|
|
</select>
|
|
|
|
<div markdown="1" class="ipv4-eth0-INDEX">
|
|
_(IPv4 address assignment)_:
|
|
: <select name="USE_DHCP:INDEX" class="ctrl" onchange="selectProtocol(this.form,INDEX,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP:INDEX"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP:INDEX"), 'no', _('Static'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP:INDEX"), '', _('None'))?>
|
|
</select>
|
|
<span class="gw4-eth0-INDEX hide"><input type="checkbox" name="USE_GW4:INDEX" onchange="selectGW(this.form,4,INDEX,'slow')"><?=$enable?></span>
|
|
|
|
<div markdown="1" class="more-ipv4-eth0-INDEX hide">
|
|
_(IPv4 address)_:
|
|
: <input type="text" name="IPADDR:INDEX" maxlength="15" autocomplete="off" spellcheck="false" value="" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">/<select name="NETMASK:INDEX" class="slim">
|
|
<?foreach ($masks as $mask => $prefix) echo mk_option(0, $mask, $prefix, $prefix=='24'?'selected':'');?>
|
|
</select>
|
|
|
|
<div markdown="1" class="more-gw4-eth0-INDEX hide">
|
|
_(IPv4 default gateway)_:
|
|
: <input type="text" name="GATEWAY:INDEX" maxlength="15" autocomplete="off" spellcheck="false" value="" class="narrow" pattern="<?=$validIP4?>" title="_(IPv4 address A.B.C.D)_">
|
|
<input type="text" name="METRIC:INDEX" min="1" max="9999" autocomplete="off" spellcheck="false" value="<?=metric('eth0.INDEX', 4, $i + 1)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div markdown="1" class="ipv6-eth0-INDEX hide">
|
|
_(IPv6 address assignment)_:
|
|
: <select name="USE_DHCP6:INDEX" class="ctrl" onchange="selectProtocol(this.form,INDEX,'slow')">
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:INDEX"), 'yes', _('Automatic'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:INDEX"), 'no', _('Static'))?>
|
|
<?=mk_option(_var($eth0, "USE_DHCP6:INDEX"), '', _('None'))?>
|
|
</select>
|
|
<span class="gw6-eth0-INDEX hide"><input type="checkbox" name="USE_GW6:INDEX" onchange="selectGW(this.form,6,INDEX,'slow')"><?=$enable?></span>
|
|
|
|
<div markdown="1" class="more-ipv6-eth0-INDEX hide">
|
|
_(IPv6 address)_:
|
|
: <input type="text" name="IPADDR6:INDEX" maxlength="39" autocomplete="off" spellcheck="false" value="" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">/<input type="number" name="NETMASK6:INDEX" min="7" max="128" autocomplete="off" spellcheck="false" value="64" class="slim">
|
|
|
|
<div markdown="1" class="more-gw6-eth0-INDEX hide">
|
|
_(IPv6 default gateway)_:
|
|
: <input type="text" name="GATEWAY6:INDEX" maxlength="39" autocomplete="off" spellcheck="false" value="" pattern="<?=$validIP6?>" title="_(IPv6 address nnnn:xxxx::yyyy)_">
|
|
<input type="text" name="METRIC6:INDEX" min="1" max="9999" autocomplete="off" spellcheck="false" value="<?=metric('eth0.INDEX', 6, $i + 1)?>" class="slim"><i class="fa fa-sort-numeric-asc"></i> *<?=$metric?>*
|
|
|
|
</div>
|
|
</div>
|
|
<div markdown="1" class="priv-ipv6-eth0-INDEX hide">
|
|
_(IPv6 privacy extensions)_:
|
|
: <select name="PRIVACY6:INDEX">
|
|
<?=mk_option(_var($eth0, 'PRIVACY6:INDEX'), "0", _("Disabled"))?>
|
|
<?=mk_option(_var($eth0, 'PRIVACY6:INDEX'), "2", _("Enabled"))?>
|
|
</select>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</script>
|