Martineau
Part of the Furniture
@Martineau
I got to play with the script using a rt-ac68u.
My requirement is the following.
1) vlan 1 (default) untagged on all ports except lan port 2
2) vlan 3 tagged on ports 1, 3, 4
3) vlan 3 untagged on port 2
4) dhcp/dns services for vlan 3
The following would establish vlan 3 and set up dhcp/dns services
Code:vlanswitch.sh 3 1 autodnsmasq
However, it removes vlan 1 untagged from port 1.
So, I used the following to bring it back.
Code:./vlanswitch.sh 3 1 autodnsmasq robocfg vlan 1 ports "1 3 4 5t" robocfg vlan 3 ports "1t 2 3t 4t 5t"
This works, but, devices which get an ip on vlan1 before vlan configures subsequently don't get an ip on vlan3. A work around this was to set the router's main dhcp server to 120s time out. Not the best solution.
Any suggestions for implementing what I want in a more robust way?
The script was originally written to assign multiple VLANs to a single switch port to support multiple downstream VLAN-aware switches.
I never needed/considered mapping a VLAN across several switch ports.
Clearly there are three options:
1. Don't use my script! - it's rubbish anyway!
2. Hack my script to statically define the VLANs for your environment.
3. Wait until v1.30 if I decide to allow the script to include this (complex) optional feature.
2. Hack my script to statically define the VLANs for your environment.
3. Wait until v1.30 if I decide to allow the script to include this (complex) optional feature.
For Option 2, you can try and hack the section of code in the script where the new VLAN is created and VLAN1 is modified:
LINES 1348-1384
Code:
ROBO_PORT=$SWITCH_PORT
#if [ "$HARDWARE_MODEL" == "RT-AC56U" ];then
#ROBO_PORT=$((SWITCH_PORT-1))
#fi
# The physical Switch port may be mapped to a different robocfg port
# e.g. RT-AC56U uses robocfg ports '0 1 2 3 5t' so physical Switch port '3' is robocfg port '2'
I=1
<snip>
else
if [ "$(echo $@ | grep -cw 'utag')" -eq 0 ];then
Edit_VLAN1 "Delete" $ROBO_PORT # set robocfg vlan 1 ports "1 2 3 4 5t" -> "1 3 4 5t"
robocfg vlan $VLAN_ID ports "${ROBO_PORT} ${WAN_ROBOCFG_PORT}"
else
Edit_VLAN1 "Tag" $ROBO_PORT "u" # set robocfg vlan 1 ports "1 2 3 4 5t" -> "1 2 3 4u 5t"
robocfg vlan $VLAN_ID ports "${ROBO_PORT}u ${WAN_ROBOCFG_PORT}"
fi
fi
e.g.
Code:
case $VLAN in
vlan3) robocfg vlan 1 ports "1 3 4 5t"
robocfg vlan 3 ports "1t 2 3t 4t 5t"
;;
esac
EDIT: @gpz1100 Updated v1.30 script;so please see PM download link if you wish to test it.
I decided to simply allow you to manually specify the switch ports you wish to use for VLAN1 and the new VLAN. (No user input validation is performed on the syntax!)
NOTE: It is recommended you stay away from single digit VLANs as some are reserved by Asus.
e.g. Using VLAN 80 rather than VLAN 3, I supplied your desired VLAN ports
NOTE: Because I'm lazy, you must specify a valid port number as a 'dummy' place-holder when using the 'robocfg=' directive :-(
Code:
./VLANSwitch.sh 80 4 autodnsmasq robocfg="1 3 4 5t,1t 2 3t 4t 5t"
(VLANSwitch.sh): 7255 v1.30 © 2016-2019 Martineau. VLAN configuration utility.
(VLANSwitch.sh): 7255 VLAN 'vlan80' alias 'None80' (10.88.80.0/24) via Switch Ports ( 1t 2 3t 4t ) created
robocfg show
Switch: enabled
<snip>
VLANs: BCM5301x enabled mac_check mac_hash
0: vlan0: 1 3 4 5t
1: vlan1: 1 3 4 5t
2: vlan2: 0 5
20: vlan20: 4t 5t
30: vlan30: 4t 5t
40: vlan40: 4t 5t
56: vlan56: 0 3 7t 8t
57: vlan57: 0t 1 2t 4t 5t 8u
58: vlan58: 1t 3t 5 7
59: vlan59: 0 3t 5 8u
60: vlan60: 0t 2 7t
61: vlan61: 0 1 2t 5t 7t
62: vlan62: 0 2
80: vlan80: 1t 2 3t 4t 5t
200: vlan200: 4t 5t
For the VLAN 80 delete, optionally,you only need to supply the VLAN 1 ports that you wish to restore, if not supplied, then they remain as-is.
e.g. in my case, port 4 is my main VLAN trunk port
Code:
./VLANSwitch.sh 80 del robocfg="1 2 3 4t 5t"
(VLANSwitch.sh): 8146 v1.30 © 2016-2019 Martineau. VLAN configuration utility.
(VLANSwitch.sh): 8146 VLAN 'vlan80' (alias 'None80') 10.88.80.0/24 via Switch Ports ( 1t 2 3t 4t ) DELETED.
robocfg show
Switch: enabled
<snip>
VLANs: BCM5301x enabled mac_check mac_hash
0: vlan0: 1 3 4 5t
1: vlan1: 1 2 3 4t 5t
2: vlan2: 0 5
20: vlan20: 4t 5t
30: vlan30: 4t 5t
40: vlan40: 4t 5t
56: vlan56: 0 3 7t 8t
57: vlan57: 0t 1 2t 4t 5t 8u
58: vlan58: 1t 3t 5 7
59: vlan59: 0 3t 5 8u
60: vlan60: 0t 2 7t
61: vlan61: 0 1 2t 5t 7t
62: vlan62: 0 2
200: vlan200: 4t 5t
Last edited: