From 4978c1a0ff27a8223613bbf181379f29d75efe4a Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 9 May 2016 20:47:57 +0200 Subject: [PATCH] Enhanced network settings --- plugins/dynamix.vm.manager/VMMachines.page | 2 +- plugins/dynamix/Eth0.page | 398 ++++++++++++++++++++ plugins/dynamix/EthX.page | 165 ++++++++ plugins/dynamix/NetworkSettings.page | 177 +-------- plugins/dynamix/icons/ethernet.png | Bin 0 -> 569 bytes plugins/dynamix/include/update.ethernet.php | 15 + plugins/dynamix/scripts/netconfig | 74 ++++ plugins/dynamix/template.php | 3 + 8 files changed, 657 insertions(+), 177 deletions(-) create mode 100644 plugins/dynamix/Eth0.page create mode 100644 plugins/dynamix/EthX.page create mode 100644 plugins/dynamix/icons/ethernet.png create mode 100644 plugins/dynamix/include/update.ethernet.php create mode 100644 plugins/dynamix/scripts/netconfig diff --git a/plugins/dynamix.vm.manager/VMMachines.page b/plugins/dynamix.vm.manager/VMMachines.page index 5a5f2e3d5..6c757ec89 100644 --- a/plugins/dynamix.vm.manager/VMMachines.page +++ b/plugins/dynamix.vm.manager/VMMachines.page @@ -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" : ""; } diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page new file mode 100644 index 000000000..1172b0914 --- /dev/null +++ b/plugins/dynamix/Eth0.page @@ -0,0 +1,398 @@ +Menu="NetworkSettings" +Title="Interface eth0" +Png="ethernet.png" +--- + + $val) if (substr($key,0,6)=='VLANID') $vlan_eth0[] = substr($key,7); +?> + + +
+ + + + + + + + + + + + +
+ +MAC address: +: + +> 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: +: + +> 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: +: + +> 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 which interfaces are member of the *bonded* interface. By default eth0 is a member, while other interfaces are optional. + +Enable bridging: +: + +> 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: +: + + + +
+ + + + +  +: Stopped to change" : ""?> +
diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page new file mode 100644 index 000000000..f8b61c5d9 --- /dev/null +++ b/plugins/dynamix/EthX.page @@ -0,0 +1,165 @@ +Menu="x-settings" +Title="Interface ethX" +Png="ethernet.png" +--- + +]'"))==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; +?> + +
+ + + + + + + + + + +
+ +MAC address: +: - interface is not configured + +> 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: +: + +> Bridging is a feature which creates a virtual bridge and allows VMs to communicate directly with the physical Ethernet port. + +Type of access: +: + + + +
+ + + + +  +: Unbonded to change" : ($disabled ? "VMs must be Stopped to change" : "")?> +
diff --git a/plugins/dynamix/NetworkSettings.page b/plugins/dynamix/NetworkSettings.page index be6616932..4e6b18aa0 100644 --- a/plugins/dynamix/NetworkSettings.page +++ b/plugins/dynamix/NetworkSettings.page @@ -1,179 +1,4 @@ Menu="OtherSettings" +Type="xmenu" Title="Network Settings" Icon="network-settings.png" ---- - - - -
- -MAC address: -: - -Enable bonding: -: - -> 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: -: - -> Mode 1 (active-backup) is the recommended default. Other modes may require switch support. - -Setup bridge: -: - -> 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: -: - -> This is the name of the bridge interface. If left blank, the name of the bridge will be **br0**. - -Bridge enable STP: -: - -> 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: -: - -> 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: -: - -> If set to 'Yes' the server will attempt to obtain its IP address from the local DHCP server. - -IP address: -: - -> Greyed out when using DHCP server. Otherwise specify here the IP address of the system. - -Network mask: -: - -> Greyed out when using DHCP server. Otherwise specify here the associated network mask, usually 255.255.255.0 - -Default gateway: -: - -> Greyed out when using DHCP server. Otherwise specify here the IP address of your router. - -Obtain DNS server address automatically: -: - -> If set to 'Yes' the server will use DNS server IP address returned by the local DHCP server.
-> 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: -: - -> 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: -: - -> This is the DNS server to use when DNS Server 1 is down. - -DNS server 3: -: - -> This is the DNS server to use when DNS Servers 1 and 2 are both down. - -Desired MTU: -: - -> 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). - -  -: >Stopped to change" : ""?> - -
diff --git a/plugins/dynamix/icons/ethernet.png b/plugins/dynamix/icons/ethernet.png new file mode 100644 index 0000000000000000000000000000000000000000..e9984870a8ed9bbe2f8862fec6626dbb3ed46204 GIT binary patch literal 569 zcmV-90>=G`P)1>y(LWG1st;%51q!LP*KrpUU1mn(yA%&ZO3JVTPGDz0v zbo!votnTzX8)x7#v$HdAXJXQV?WD=Ak`3P92QYqm)*nN%C>9tR@R4SDf0@-mK5ai)- z2wm3^4u`SxCNAt{&3?99t(J)AJW+vb2!c>3gg_vGpTBPqjYfT%W83X}K`{Sktmt?g=ytmtx=Jt@4CVxpNCdH1?9m3wvP@G@K{ieS7eWtFBCs7jjK{fe;d;w3>txr@DT``bT0e&^Ur@B6NOLHI+s zl|(S06ATx+n96bR0H*X7jp;eQ^h@5)c#?!Rp+^-A{|PVv_$uJafkv%f00000NkvXX Hu0mjfBY6Ye literal 0 HcmV?d00001 diff --git a/plugins/dynamix/include/update.ethernet.php b/plugins/dynamix/include/update.ethernet.php new file mode 100644 index 000000000..0c2439b07 --- /dev/null +++ b/plugins/dynamix/include/update.ethernet.php @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/plugins/dynamix/scripts/netconfig b/plugins/dynamix/scripts/netconfig new file mode 100644 index 000000000..303fc7655 --- /dev/null +++ b/plugins/dynamix/scripts/netconfig @@ -0,0 +1,74 @@ +#!/usr/bin/php -q + +/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); +?> diff --git a/plugins/dynamix/template.php b/plugins/dynamix/template.php index 2d2fc78a3..68f8d2cec 100644 --- a/plugins/dynamix/template.php +++ b/plugins/dynamix/template.php @@ -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';