Now people started using it also with "HAP ac lite". The main difference is that the former has 5 ports and the later only 4.
As the people using the configuration are only "consuming" it I was wondering if the difference could be somehow automated away so that they don't have to care
The original code in question is:
Code: Select all
/interface vlan
add interface=ether2 name=vlan7_ether2 vlan-id=7
add interface=ether3 name=vlan7_ether3 vlan-id=7
add interface=ether4 name=vlan7_ether4 vlan-id=7
add interface=ether5 name=vlan7_ether5 vlan-id=7
/interface bridge
add name=bridge_pppoe arp=proxy-arp
port add bridge=bridge_pppoe interface=vlan7_ether2
port add bridge=bridge_pppoe interface=vlan7_ether3
port add bridge=bridge_pppoe interface=vlan7_ether4
port add bridge=bridge_pppoe interface=vlan7_ether5
I've seen some usages of :foreach loops but am really just starting. After some fiddling I came up with:
Code: Select all
/interface bridge
add name=bridge_pppoe arp=proxy-arp
{
:local interfaces [/interface print as-value where name~"ether" and name!="ether1"];
:foreach interface in=$interfaces do={
:local ifName ($interface->"name");
:local vlanName ("vlan7_" . $ifName);
/interface vlan add interface=$ifName name=$vlanName vlan-id=7
/interface bridge port add bridge=bridge_pppoe interface=$vlanName
}
}