^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) DSA switch configuration from userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) The DSA switch configuration is not integrated into the main userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) network configuration suites by now and has to be performed manualy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) .. _dsa-config-showcases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Configuration showcases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) To configure a DSA switch a couple of commands need to be executed. In this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) documentation some common configuration scenarios are handled as showcases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *single port*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) Every switch port acts as a different configurable Ethernet port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *bridge*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Every switch port is part of one configurable Ethernet bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *gateway*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) Every switch port except one upstream port is part of a configurable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Ethernet bridge.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) The upstream port acts as different configurable Ethernet port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) All configurations are performed with tools from iproute2, which is available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) at https://www.kernel.org/pub/linux/utils/net/iproute2/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Through DSA every port of a switch is handled like a normal linux Ethernet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) interface. The CPU port is the switch port connected to an Ethernet MAC chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) The corresponding linux Ethernet interface is called the master interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) All other corresponding linux interfaces are called slave interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) The slave interfaces depend on the master interface. They can only brought up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) when the master interface is up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) In this documentation the following Ethernet interfaces are used:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *eth0*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) the master interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *lan1*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) a slave interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *lan2*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) another slave interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) *lan3*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) a third slave interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *wan*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) A slave interface dedicated for upstream traffic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Further Ethernet interfaces can be configured similar.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) The configured IPs and networks are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *single port*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * lan1: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * lan2: 192.0.2.5/30 (192.0.2.4 - 192.0.2.7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * lan3: 192.0.2.9/30 (192.0.2.8 - 192.0.2.11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *bridge*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) *gateway*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * wan: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .. _dsa-tagged-configuration:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) Configuration with tagging support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) The tagging based configuration is desired and supported by the majority of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) DSA switches. These switches are capable to tag incoming and outgoing traffic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) without using a VLAN based configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) single port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) # configure each interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ip addr add 192.0.2.1/30 dev lan1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ip addr add 192.0.2.5/30 dev lan2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ip addr add 192.0.2.9/30 dev lan3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ip link set lan3 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ip link set lan3 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) # create bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ip link add name br0 type bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) # add ports to bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ip link set dev lan1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ip link set dev lan2 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ip link set dev lan3 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) # configure the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ip addr add 192.0.2.129/25 dev br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # bring up the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ip link set dev br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) gateway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) ip link set wan up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) # configure the upstream port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ip addr add 192.0.2.1/30 dev wan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) # create bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) ip link add name br0 type bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) # add ports to bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ip link set dev lan1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ip link set dev lan2 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) # configure the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) ip addr add 192.0.2.129/25 dev br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) # bring up the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ip link set dev br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .. _dsa-vlan-configuration:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) Configuration without tagging support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) -------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) A minority of switches are not capable to use a taging protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) (DSA_TAG_PROTO_NONE). These switches can be configured by a VLAN based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) single port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) The configuration can only be set up via VLAN tagging and bridge setup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) # tag traffic on CPU port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) ip link add link eth0 name eth0.1 type vlan id 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ip link add link eth0 name eth0.2 type vlan id 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ip link add link eth0 name eth0.3 type vlan id 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ip link set eth0.1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ip link set eth0.2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) ip link set eth0.3 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ip link set lan3 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) # create bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) ip link add name br0 type bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) # activate VLAN filtering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) ip link set dev br0 type bridge vlan_filtering 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) # add ports to bridges
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ip link set dev lan1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ip link set dev lan2 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ip link set dev lan3 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) # tag traffic on ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) bridge vlan add dev lan1 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) bridge vlan add dev lan2 vid 2 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) bridge vlan add dev lan3 vid 3 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) # configure the VLANs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) ip addr add 192.0.2.1/30 dev eth0.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ip addr add 192.0.2.5/30 dev eth0.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ip addr add 192.0.2.9/30 dev eth0.3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) # bring up the bridge devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ip link set br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) # tag traffic on CPU port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ip link add link eth0 name eth0.1 type vlan id 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ip link set eth0.1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ip link set lan3 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) # create bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ip link add name br0 type bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) # activate VLAN filtering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ip link set dev br0 type bridge vlan_filtering 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) # add ports to bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ip link set dev lan1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ip link set dev lan2 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) ip link set dev lan3 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ip link set eth0.1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) # tag traffic on ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) bridge vlan add dev lan1 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) bridge vlan add dev lan2 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) bridge vlan add dev lan3 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) # configure the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ip addr add 192.0.2.129/25 dev br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) # bring up the bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) ip link set dev br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) gateway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) ~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .. code-block:: sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) # tag traffic on CPU port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ip link add link eth0 name eth0.1 type vlan id 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ip link add link eth0 name eth0.2 type vlan id 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) # The master interface needs to be brought up before the slave ports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) ip link set eth0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) ip link set eth0.1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ip link set eth0.2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) # bring up the slave interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ip link set wan up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ip link set lan1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) ip link set lan2 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) # create bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ip link add name br0 type bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) # activate VLAN filtering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ip link set dev br0 type bridge vlan_filtering 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) # add ports to bridges
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ip link set dev wan master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) ip link set eth0.1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ip link set dev lan1 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) ip link set dev lan2 master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) # tag traffic on ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) bridge vlan add dev lan1 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) bridge vlan add dev lan2 vid 1 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) bridge vlan add dev wan vid 2 pvid untagged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) # configure the VLANs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ip addr add 192.0.2.1/30 dev eth0.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ip addr add 192.0.2.129/25 dev br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) # bring up the bridge devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ip link set br0 up