Skip to content

Instantly share code, notes, and snippets.

@alex-eri
Created June 11, 2019 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-eri/9e4869ae45937dae23346975ac46a0db to your computer and use it in GitHub Desktop.
Save alex-eri/9e4869ae45937dae23346975ac46a0db to your computer and use it in GitHub Desktop.
switch0_cpu=6
switch0_vlan1="0"
switch0_vlan1_id=1
switch0_vlan2="1 2"
switch0_vlan2_id=2
switch0_vlan3="3 4"
switch0_vlan3_id=317
switch0_port0_pvid=${switch0_vlan1_id}
switch0_port1_pvid=${switch0_vlan2_id}
switch0_port2_pvid=${switch0_vlan2_id}
switch0_port3_pvid=${switch0_vlan3_id}
switch0_port4_pvid=${switch0_vlan3_id}
ip link set eth0 down
swconfig dev switch0 set reset
swconfig dev switch0 set enable_vlan 1
swconfig dev switch0 port 0 set disable 0
swconfig dev switch0 port 0 set pvid ${switch0_port0_pvid}
swconfig dev switch0 port 0 set untag 1
swconfig dev switch0 port 1 set disable 0
swconfig dev switch0 port 1 set pvid ${switch0_port1_pvid}
swconfig dev switch0 port 1 set untag 1
swconfig dev switch0 port 2 set disable 0
swconfig dev switch0 port 2 set pvid ${switch0_port2_pvid}
swconfig dev switch0 port 2 set untag 1
swconfig dev switch0 port 3 set disable 0
swconfig dev switch0 port 3 set pvid ${switch0_port3_pvid}
swconfig dev switch0 port 3 set untag 1
swconfig dev switch0 port 4 set disable 0
swconfig dev switch0 port 4 set pvid ${switch0_port4_pvid}
swconfig dev switch0 port 4 set untag 1
swconfig dev switch0 vlan ${switch0_vlan1_id} set ports "${switch0_vlan1} ${switch0_cpu}t"
swconfig dev switch0 vlan ${switch0_vlan2_id} set ports "${switch0_vlan2} ${switch0_cpu}t"
swconfig dev switch0 vlan ${switch0_vlan3_id} set ports "${switch0_vlan3} ${switch0_cpu}t"
swconfig dev switch0 set apply
swconfig dev switch0 show
ip link add link eth0 name eth-wan type vlan id ${switch0_vlan1_id}
ip link add link eth0 name eth-lan type vlan id ${switch0_vlan2_id}
ip link add link eth0 name eth-guest type vlan id ${switch0_vlan3_id}
ip link add name lan type bridge
ip link add name guest type bridge
echo 1 > /sys/devices/virtual/net/lan/bridge/multicast_querier
echo 1 > /sys/devices/virtual/net/guest/bridge/multicast_querier
ip link set eth-lan master lan
ip link set eth-guest master guest
ip link set lan up
ip link set guest up
ip link set eth0 up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment