joe scian
Very Senior Member
Many thanks to you and your brilliant coding skillsGlad it works on your RT-AC5300 , and many thanks for the feedback.
Many thanks to you and your brilliant coding skillsGlad it works on your RT-AC5300 , and many thanks for the feedback.
Thank you SIR. You have been a tremendous help.However, I suggest you create a separate script such as my 'GS108E.sh' ... perhaps you could call it 'Cisco2960X.sh' as it makes it more convenient to manually manage ALL of the VLANs i.e. check the status/stats in one command:
Thank you SIR. You have been a tremendous help.
Another stupid question.
Do I call this script from firewall-start?
I bet you now regret posting that!Many thanks to you and your brilliant coding skills
I ran WIFIVPN with commands wifivpn.sh wl0.1 novpn vlan1 autodnsmasq and this is what it produced:-
(wifivpn.sh): 32267 v1.05 © 2016-2018 Martineau, Guest WiFi Bridge request.....[wl0.1 novpn vlan1 autodnsmasq]
(wifivpn.sh): 32267 ***Warning Bridge 'br1' not defined in '/etc/dnsmasq.conf' - auto updating '/jffs/configs/dnsmasq.conf.add' with 'br1' statements.....
ifconfig: SIOCSIFFLAGS: Network is down
ifconfig: bad address '.1'
Sorry, rule does not exist.
Sorry, rule does not exist.
iptables v1.4.15: Invalid rule number `3
4'
Try `iptables -h' or 'iptables --help' for more information.
(wifivpn.sh): 32267 WiFi (wl0.1) 2.4GHz Guest 1 ASUS_Guest1 (.0/24) via bridge:br1
<snip>
PS - I cant join ASUS_Guest1 - keeps coming up with wrong password even though its correct
wifivpn.sh wl0.1 novpn autodnsmasq
iptables v1.4.15: Invalid rule number 3' 4'
./VLANSwitch.sh 10 bridge notag
./WiFiVPN.sh wl0.1 novpn vlan1 notag autodnsmasq
(WiFiVPN.sh): 678 v1.05 © 2016-2018 Martineau, Guest WiFi Bridge request.....[wl0.1 novpn vlan1 autodnsmasq]
(WiFiVPN.sh): 678 WiFi (wl0.1) 2.4GHz Guest 1 G241 (192.168.101.0/24) via bridge:br1
robocfg show
Switch: enabled
<snip>
VLANs: BCM5301x enabled mac_check mac_hash
1: vlan1: 0 2 3 5t
2: vlan2: 4 5
10: vlan10: 1 5t
56: vlan56: 0 1t 4t 5 7
57: vlan57: 1 2t 3 4t 5t
58: vlan58: 4 5 7t
59: vlan59: 3 4t 7 8t
60: vlan60: 1 2 3t 5t 8u
61: vlan61: 3 5t
62: vlan62: 0 3 7t 8u
brctl show
bridge name bridge id STP enabled interfaces
br0 8000.acxxxxxxx yes vlan1
eth1
eth2
br1 8000.aczzzzzzzz no wl0.1
vlan10
I bet you now regret posting that!
Always the way with lazy programming, in this case trying to make (VPN specific) code address a non-VPN problem it wasn't originally designed for.
So if you remove the invalid dross from '/jffs/configs/dnsmasq.conf.add', and run
Code:wifivpn.sh wl0.1 novpn autodnsmasq
Hopefully the script should now work - albeit without the additional Port 1 VLAN10 mapped to to WiFi 2.4Ghz Guest #1.
The error
implies that there are duplicate conflicting rules so the script fails to insert its rule in the appropriate place and fails.Code:iptables v1.4.15: Invalid rule number 3' 4'
I suspect perhaps you didn't delete VLAN10 having already used:
and WiFIVPN.sh didn't expect it? ,so I may decide to revert back to my original design and modify VLANSwitch.sh to bind to either a WiFi VPN bridge (as originally designed) , or add a new option (say 'bind=br10') to allow binding to the non-VPN bridge.Code:./VLANSwitch.sh 10 bridge notag
EDIT: Just tested on RT-AC56U (no previous VLANs) and script didn't fail with any errors....Code:./WiFiVPN.sh wl0.1 novpn vlan1 notag autodnsmasq (WiFiVPN.sh): 678 v1.05 © 2016-2018 Martineau, Guest WiFi Bridge request.....[wl0.1 novpn vlan1 autodnsmasq] (WiFiVPN.sh): 678 WiFi (wl0.1) 2.4GHz Guest 1 G241 (192.168.101.0/24) via bridge:br1 robocfg show Switch: enabled <snip> VLANs: BCM5301x enabled mac_check mac_hash 1: vlan1: 0 2 3 5t 2: vlan2: 4 5 10: vlan10: 1 5t 56: vlan56: 0 1t 4t 5 7 57: vlan57: 1 2t 3 4t 5t 58: vlan58: 4 5 7t 59: vlan59: 3 4t 7 8t 60: vlan60: 1 2 3t 5t 8u 61: vlan61: 3 5t 62: vlan62: 0 3 7t 8u brctl show bridge name bridge id STP enabled interfaces br0 8000.acxxxxxxx yes vlan1 eth1 eth2 br1 8000.aczzzzzzzz no wl0.1 vlan10
Good to hear...yet again proof (if proof were needed) that a 'factory reset' works wondersSo, I'm back again, alive and kicking! And I'm happy to say that my router seems to be back in its full glory after a factory reset
Unfortunately the command remains the same...the one that apparently causes your router to crashI'm interested in creating a spearate subnet connected through an unmanaged switch to my router's LAN port 4.
What command (if any) should I run to acheive this
./VLANSwitch.sh 40 bridge notag
(VLANSwitch.sh): 20747 ***ERROR Bridge brbridge0 (vlan144) via Switch Port 4 not defined in '/etc/dnsmasq.conf' - (see 'VLANSwitch.sh' help)
pid-file=/var/run/dnsmasq.pid
user=nobody
bind-dynamic
interface=br0
interface=pptp*
no-dhcp-interface=pptp*
no-resolv
no-poll
no-negcache
cache-size=1500
min-port=4096
bogus-priv
domain-needed
dhcp-range=lan,192.168.1.230,192.168.1.250,255.255.255.0,86400s
dhcp-option=lan,3,192.168.1.1
dhcp-option=lan,252,"\n"
dhcp-authoritative
interface=tun21
interface=tun22
trust-anchor=.,19036,8,2,XXXXXXX
trust-anchor=.,20326,8,2,XXXXXX
dnssec
dhcp-name-match=set:wpad-ignore,wpad
dhcp-ignore-names=tag:wpad-ignore
server=127.0.0.1#65053
# start of Diversion directives #
addn-hosts=/opt/share/diversion/list/blacklist
addn-hosts=/opt/share/diversion/list/blockinglist
log-async
log-queries
log-facility=/opt/var/log/dnsmasq.log
# end of Diversion directives #
Switch: enabled
Port 0: 1000FD enabled stp: none vlan: 2 jumbo: off mac: XXX
Port 1: 1000FD enabled stp: none vlan: 1 jumbo: off mac: XXX
Port 2: 1000FD enabled stp: none vlan: 1 jumbo: off mac: XXX
Port 3: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
Port 4: 1000FD enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
Port 5: 1000FD enabled stp: none vlan: 2 jumbo: off mac: XXX
Port 7: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
Port 8: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
VLANs: BCM5301x enabled mac_check mac_hash
1: vlan1: 1 2 3 4 5t
2: vlan2: 0 5
bridge name bridge id STP enabled interfaces
br0 8000.XXX yes vlan1
eth1
eth2
wl0.1
(VLANSwitch.sh): 1608 ***ERROR Invalid Switch Port 'brdige' - range 1-4 ONLY! RT-AC68U (RT-AC87U range 2-4!!!)
Code:(VLANSwitch.sh): 1608 ***ERROR Invalid Switch Port 'brdige' - range 1-4 ONLY! RT-AC68U (RT-AC87U range 2-4!!!)
(By the way, is it a typo in the error message, 'brdige' instead of 'bridge'?)
./VLANSwitch.sh 40 bridge notag autodnsmasq
OK folks,I finally got the script working. Basically, I had two issues:
- My router had ended up in a confused state. The reason for that is unknown at the moment. It could have been my own trial'n'error, the script or something else that caused it to behave strange.
- I can't type a simple command without a typo
So, this what I did to get it to work:
So, since the script now works I would say that the script itself is/was NOT the cause of my initial problems. They were probably related to me doing stuff on the router that I didn't understood what they were doing. So, if you got the impression from my earlier posts/problems that script might cause your router to crash, it won't unless there's somethings already messed up.
- Did a factory reset on my router
- Got feeback on my typing and thus entered the command correctly (through copy-paste)
I have learned my lesson: Don't try stuff that you don't know what it's doing without taking in to consideration that a factory reset may be necessary to make all things good again. As for the typo, I won't comment it further , just use copy-paste.
So the command I entered was:
Code:./VLANSwitch.sh 40 bridge notag autodnsmasq
One issue that occured was that I got a DNS-leak on the .144-net. I'm using DNSCrypt on my router and its address were sent as DNS through the DHCP, but a openDNS and google-DNS address were also sent. This, I learned (from the guru himself, aka @Martineau), can be changed by editing the file '/jffs/configs/dnsmasq.conf.add'. Haven't tried it yet, but it should easily be fixed. (EDIT: I can now confirmed that it works!)
- This created a VLAN 144 on my router port 4. To that port I am now able to connect an unmanaged switch where I have a laptop connected which is now getting an ip-address through DHCP for the 192.168.144.x-net.
- The .144-net is isolated from the .1-net (private-net)
- I'm able to reach the .144-net from the .1-net
So that's where I stand now. I still need to read up on a few things (iptables and more) to complete my desired configuration, but I think I'll just pause for a while and enjoy the moment for now .
A big thanks to @Martineau for the script itself and the support and guidance through my VLAN-journey. Great work and thanks a million!
Sorry I havent provide any feedback. I have familj issue to take care of at then moment. SorryMany thanks for your comprehensive (and admirably honest 'confessional' ) feedback - it puts to shame those that can't be bothered to provide any at all.
Thank you! I have a feeling I might need it .Many thanks for your comprehensive (and admirably honest 'confessional' ) feedback - it puts to shame those that can't be bothered to provide any at all.
Without your testing, I would have still remained ignorant of the timing issue. The weird thing is that apart from the now enforced 2-second delay (and added support for the non-RT-AC68U routers) the script has remained unchanged and working in my environments for at least a year but since DNS leaks/DNSSEC was not a concern/available when I originally wrote the script, restarting dnsmasq apparently now takes longer. Clearly the 2-second delay is dumb overkill, so I will probably try and reduce the enforced wait....or as you suggested, issue a 'please wait/be patient/the router isn't crashing' message!
Given your future 'advanced' design/topology requirements (once you have 'relaxed!)), then you may be better served by using a VLAN tagging capable downstream switch where additional ACL restriction may be applied to enforce client isolation within the new VLAN.
Good luck.
********@RT-AC66U_B1:/jffs/scripts# ./nat-start
***ERROR Cannot display status; VLAN 20 (or Bridge br20) not found
********@RT-AC66U_B1:/jffs/scripts# ./Cisco2960X.sh
***ERROR Cannot display status; VLAN 20 (or Bridge br20) not found
#!/bin/sh
/jffs/scripts/Cisco2960X.sh
#!/bin/sh
VER="v1.01"
#======================================================================================================= © 2016-2018 Martineau, v1.01
#
# Manage the VLANs (call this script from appropriate system script e.g. init-start/nat-start/services-start)
#
# Validate the request
OPTION=
if [ "$1" == "del" ]; then
OPTION="del"
fi
# Allow use of abbreviated 'status verbose'
if [ "$1" == "verbose" ]; then
OPTION="status verbose"
fi
# Allow use of abbreviated 'status diag'
if [ "$1" == "diag" ]; then
OPTION="status diag"
fi
# Set 'status' as the Default action if no args
if [ -z "$1" ] || [ "$(echo $@ | grep -cw "status")" -gt 0 ];then
OPTION="status"
if [ "$2" == "verbose" ];then
OPTION=$OPTION" "$2
fi
fi
# Multiple VLANs on Port 4 (Tagged Trunk) for downstream VLAN capable switches
#
# Cisco 2960X
#
/jffs/scripts/VLANSwitch.sh 20 autodnsmasq $OPTION "alias=Guest" # VLAN20
#/jffs/scripts/VLANSwitch.sh 30 $OPTION "alias=IoT" # VLAN30
#/jffs/scripts/VLANSwitch.sh 40 $OPTION "alias=Internet" # VLAN40
#/jffs/scripts/VLANSwitch.sh 50 $OPTION "vpn1" "vlanfw" "alias=VPN" # VLAN50 force via VPN Client bridge (br1) and use explicit vlan50 Firewall rules
#/jffs/scripts/VLANSwitch.sh 200 $OPTION # VLAN200 for testing
# VLAN on Port 1 (UnTagged)
#/jffs/scripts/VLANSwitch.sh 70 $OPTION "1 bridge notag alias=CCTV" # VLAN70 (Artificially exclude 60!)
if [ "$1" == "del" ] || [ "$1" == "status" ];then
# Perform any additional post-deletion or status activities here
exit 0
fi
# Perform any additional post-creation activities here
exit 0
@Martineau
I have tried to use your GS108e.sh to auto run the VLANSwitch.sh but not having any luck.
Code:********@RT-AC66U_B1:/jffs/scripts# ./nat-start ***ERROR Cannot display status; VLAN 20 (or Bridge br20) not found ********@RT-AC66U_B1:/jffs/scripts# ./Cisco2960X.sh ***ERROR Cannot display status; VLAN 20 (or Bridge br20) not found
this is my nat-start
Code:#!/bin/sh /jffs/scripts/Cisco2960X.sh
#!bin/sh
/jffs/scripts/Cisco2960X.sh init
/jffs/scripts/VLANSwitch.sh 20 autodnsmasq $OPTION "alias=Guest" # VLAN20
to
/jffs/scripts/VLANSwitch.sh 20 $OPTION autodnsmasq "alias=Guest" # VLAN20
Try changing nat-start to
Code:#!bin/sh /jffs/scripts/Cisco2960X.sh init
Also it might be best if you keep the order of the positional args
e.g. Change
Code:/jffs/scripts/VLANSwitch.sh 20 autodnsmasq $OPTION "alias=Guest" # VLAN20 to /jffs/scripts/VLANSwitch.sh 20 $OPTION autodnsmasq "alias=Guest" # VLAN20
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!