# Network Deployment Scenarios using TR-181 Data Model

The purpose of this document is to explain the different deployment scenarios supported by our devices and how to configure each scenario using TR-181 data model.

## Deployment scenarios

### 1. Transparent Bridge

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1

obuspa -c set Device.Bridging.Bridge.1.Port.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.4.Enable 1

obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.4.ManagementPort 0

obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.1.Port.4.LowerLayers Device.Ethernet.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdec:6076:a3d3::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface1'
        option proto 'dhcp'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1'
        list ports 'eth3'
        list ports 'eth4'
        option macaddr '44:D4:37:71:B5:53'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3,Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.1.Port.4.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
```

### 2. One VLAN per Service (Bridge mode)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c add Device.Bridging.Bridge.2.VLAN.
obuspa -c add Device.Bridging.Bridge.2.VLANPort.
obuspa -c add Device.Bridging.Bridge.2.VLANPort.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.3.Enable 1

obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.IP.Interface.3.LowerLayers Device.Ethernet.Link.3

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.3

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1
obuspa -c set Device.Ethernet.Link.2.LowerLayers Device.Bridging.Bridge.2.Port.1
obuspa -c set Device.Ethernet.Link.3.LowerLayers Device.Ethernet.Interface.3

obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Enable 1

obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.VLAN Device.Bridging.Bridge.1.VLAN.1

obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Port Device.Bridging.Bridge.1.Port.2
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Port Device.Bridging.Bridge.1.Port.3

obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.3

obuspa -c set Device.Bridging.Bridge.1.VLAN.1.VLANID 100

obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0

obuspa -c set Device.Bridging.Bridge.1.Port.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1

obuspa -c set Device.Bridging.Bridge.2.Port.1.ManagementPort 1
obuspa -c set Device.Bridging.Bridge.2.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.3.ManagementPort 0

obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.VLAN Device.Bridging.Bridge.2.VLAN.1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.VLAN Device.Bridging.Bridge.2.VLAN.1

obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Port Device.Bridging.Bridge.2.Port.2
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.Port Device.Bridging.Bridge.2.Port.3

obuspa -c set Device.Bridging.Bridge.2.VLAN.1.VLANID 200

obuspa -c set Device.Bridging.Bridge.2.Port.1.Enable 1
obuspa -c set Device.Bridging.Bridge.2.Port.2.Enable 1
obuspa -c set Device.Bridging.Bridge.2.Port.3.Enable 1

obuspa -c set Device.Bridging.Bridge.2.Port.2.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.2.Port.3.LowerLayers Device.Ethernet.Interface.3

obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.Enable 1
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fddd:90b7:d9ec::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:55'

config interface 'iface1'
        option proto 'none'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'none'
        option disabled '0'
        option device 'br-dev2'
        option macaddr '44:D4:37:71:B5:54'

config interface 'iface3'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4'
        option macaddr '44:D4:37:71:B5:55'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        option macaddr '44:D4:37:71:B5:53'
        list ports 'eth1.100'
        list ports 'eth4.100'

config device 'dev_br2'
        option name 'br-dev2'
        option type 'bridge'
        option bridge_empty '1'
        option macaddr '44:D4:37:71:B5:54'
        list ports 'eth3.200'
        list ports 'eth4.200'

config device 'br_1_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth1'
        option name 'eth1.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_2'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_2_port_1'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth3'
        option name 'eth3.200'
        option macaddr '44:D4:37:71:B5:54'

config device 'br_2_port_2'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth4'
        option name 'eth4.200'
        option macaddr '44:D4:37:71:B5:54'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
Device.IP.Interface.3.LowerLayers => Device.Ethernet.Link.3
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Bridging.Bridge.2.Port.1
Device.Ethernet.Link.3.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.3
Device.Bridging.Bridge.2.Port.1.LowerLayers => Device.Bridging.Bridge.2.Port.2,Device.Bridging.Bridge.2.Port.3
Device.Bridging.Bridge.2.Port.2.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.2.Port.3.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.1.VLANPort.1.Enable => 1
Device.Bridging.Bridge.1.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLANPort.1.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.1.Port => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.2.Enable => 1
Device.Bridging.Bridge.1.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.1.VLANPort.2.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.2.Port => Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.VLANPort.2.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.1.Enable => 1
Device.Bridging.Bridge.2.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLANPort.1.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.1.Port => Device.Bridging.Bridge.2.Port.2
Device.Bridging.Bridge.2.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.2.Enable => 1
Device.Bridging.Bridge.2.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.2.VLANPort.2.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.2.Port => Device.Bridging.Bridge.2.Port.3
Device.Bridging.Bridge.2.VLANPort.2.Untagged => 0
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.1.VLAN.1.Enable => 1
Device.Bridging.Bridge.1.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLAN.1.Name => br_1_vlan_1
Device.Bridging.Bridge.1.VLAN.1.VLANID => 100
Device.Bridging.Bridge.2.VLAN.1.Enable => 1
Device.Bridging.Bridge.2.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLAN.1.Name => br_2_vlan_1
Device.Bridging.Bridge.2.VLAN.1.VLANID => 200
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.3
```

### 3. One VLAN per Service (Route mode)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.VLANTermination.
obuspa -c add Device.Ethernet.VLANTermination.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.3.Enable 1
obuspa -c set Device.IP.Interface.4.Enable 1

obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.VLANTermination.1
obuspa -c set Device.IP.Interface.3.LowerLayers Device.Ethernet.VLANTermination.2
obuspa -c set Device.IP.Interface.4.LowerLayers Device.Ethernet.Link.2

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.4

obuspa -c set Device.Ethernet.VLANTermination.1.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.Ethernet.VLANTermination.2.LowerLayers Device.Ethernet.Link.2

obuspa -c set Device.Ethernet.VLANTermination.1.VLANID 100
obuspa -c set Device.Ethernet.VLANTermination.2.VLANID 200

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1
obuspa -c set Device.Ethernet.Link.2.LowerLayers Device.Ethernet.Interface.3

obuspa -c set Device.Bridging.Bridge.1.Port.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1

obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0

obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.2
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd9b:03aa:df0a::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:56'

config interface 'iface1'
        option proto 'none'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'none'
        option disabled '0'
        option device 'eth4.100'
        option macaddr '44:D4:37:71:B5:54'

config interface 'iface3'
        option proto 'none'
        option disabled '0'
        option device 'eth4.200'
        option macaddr '44:D4:37:71:B5:55'

config interface 'iface4'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4'
        option macaddr '44:D4:37:71:B5:56'

config device 'vlan_ter_1'
        option type '8021q'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:54'

config device 'vlan_ter_2'
        option type '8021q'
        option vid '200'
        option ifname 'eth4'
        option name 'eth4.200'
        option macaddr '44:D4:37:71:B5:55'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        option macaddr '44:D4:37:71:B5:53'
        list ports 'eth1'
        list ports 'eth3'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.VLANTermination.1
Device.IP.Interface.3.LowerLayers => Device.Ethernet.VLANTermination.2
Device.IP.Interface.4.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
Device.Ethernet.VLANTermination.1.LowerLayers => Device.Ethernet.Link.2
Device.Ethernet.VLANTermination.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.2
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.4
```

### 4. VLAN Trunking

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.Bridging.Bridge.

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.4.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.4.LowerLayers Device.Ethernet.Interface.3
obuspa -c set Device.Bridging.Bridge.1.Port.4.Enable 1

obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c set Device.Bridging.Bridge.1.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Port Device.Bridging.Bridge.1.Port.2

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Port Device.Bridging.Bridge.1.Port.3

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Port Device.Bridging.Bridge.1.Port.4

obuspa -c add Device.Bridging.Bridge.

obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.1.ManagementPort 1

obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.2.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.3.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.3.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.2.Port.3.Enable 1

obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.4.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.4.LowerLayers Device.Ethernet.Interface.3
obuspa -c set Device.Bridging.Bridge.2.Port.4.Enable 1

obuspa -c add Device.Bridging.Bridge.2.VLAN.
obuspa -c set Device.Bridging.Bridge.2.VLAN.1.VLANID 200

obuspa -c add Device.Bridging.Bridge.2.VLANPort.
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.VLAN Device.Bridging.Bridge.2.VLAN.1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Port Device.Bridging.Bridge.2.Port.2

obuspa -c add Device.Bridging.Bridge.2.VLANPort.
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.Enable 1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.VLAN Device.Bridging.Bridge.2.VLAN.1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.2.Port Device.Bridging.Bridge.2.Port.3

obuspa -c add Device.Bridging.Bridge.2.VLANPort.
obuspa -c set Device.Bridging.Bridge.2.VLANPort.3.Enable 1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.3.VLAN Device.Bridging.Bridge.2.VLAN.1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.3.Port Device.Bridging.Bridge.2.Port.4

obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1

obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.2.LowerLayers Device.Bridging.Bridge.2.Port.1

obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.3.LowerLayers Device.Ethernet.Interface.3

obuspa -c add Device.Ethernet.VLANTermination
obuspa -c set Device.Ethernet.VLANTermination.1.VLANID 300
obuspa -c set Device.Ethernet.VLANTermination.1.LowerLayers Device.Ethernet.Link.3

obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1

obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2

obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.3.Enable 1
obuspa -c set Device.IP.Interface.3.LowerLayers Device.Ethernet.VLANTermination.1

obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdd6:db34:8106::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1.100'
        list ports 'eth3.100'
        list ports 'eth4.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth1'
        option name 'eth1.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_2'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth3'
        option name 'eth3.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_3'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_br2'
        option name 'br-dev2'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1.200'
        list ports 'eth3.200'
        list ports 'eth4.200'
        option macaddr '44:D4:37:71:B5:54'

config device 'br_2_port_1'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth1'
        option name 'eth1.200'
        option macaddr '44:D4:37:71:B5:54'

config device 'br_2_port_2'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth3'
        option name 'eth3.200'
        option macaddr '44:D4:37:71:B5:54'

config device 'br_2_port_3'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth4'
        option name 'eth4.200'
        option macaddr '44:D4:37:71:B5:54'

config device 'vlan_ter_1'
        option type '8021q'
        option vid '300'
        option ifname 'eth4'
        option name 'eth4.300'
        option macaddr '44:D4:37:71:B5:55'

config interface 'iface1'
        option proto 'none'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'none'
        option disabled '0'
        option device 'br-dev2'
        option macaddr '44:D4:37:71:B5:54'

config interface 'iface3'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4.300'
        option macaddr '44:D4:37:71:B5:55'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
Device.IP.Interface.3.LowerLayers => Device.Ethernet.VLANTermination.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
Device.Ethernet.VLANTermination.1.LowerLayers => Device.Ethernet.Link.3
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Bridging.Bridge.2.Port.1
Device.Ethernet.Link.3.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3,Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.1.Port.4.LowerLayers => Device.Ethernet.Interface.3
Device.Bridging.Bridge.2.Port.1.LowerLayers => Device.Bridging.Bridge.2.Port.2,Device.Bridging.Bridge.2.Port.3,Device.Bridging.Bridge.2.Port.4
Device.Bridging.Bridge.2.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.2.Port.3.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.2.Port.4.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.1.VLANPort.1.Enable => 1
Device.Bridging.Bridge.1.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLANPort.1.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.1.Port => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.2.Enable => 1
Device.Bridging.Bridge.1.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.1.VLANPort.2.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.2.Port => Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.VLANPort.2.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.3.Enable => 1
Device.Bridging.Bridge.1.VLANPort.3.Alias => cpe-3
Device.Bridging.Bridge.1.VLANPort.3.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.3.Port => Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.VLANPort.3.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.1.Enable => 1
Device.Bridging.Bridge.2.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLANPort.1.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.1.Port => Device.Bridging.Bridge.2.Port.2
Device.Bridging.Bridge.2.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.2.Enable => 1
Device.Bridging.Bridge.2.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.2.VLANPort.2.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.2.Port => Device.Bridging.Bridge.2.Port.3
Device.Bridging.Bridge.2.VLANPort.2.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.3.Enable => 1
Device.Bridging.Bridge.2.VLANPort.3.Alias => cpe-3
Device.Bridging.Bridge.2.VLANPort.3.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.3.Port => Device.Bridging.Bridge.2.Port.4
Device.Bridging.Bridge.2.VLANPort.3.Untagged => 0
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.1.VLAN.1.Enable => 1
Device.Bridging.Bridge.1.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLAN.1.Name => br_1_vlan_1
Device.Bridging.Bridge.1.VLAN.1.VLANID => 100
Device.Bridging.Bridge.2.VLAN.1.Enable => 1
Device.Bridging.Bridge.2.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLAN.1.Name => br_2_vlan_1
Device.Bridging.Bridge.2.VLAN.1.VLANID => 200
```

### 5. One VLAN per Customer(MACVLAN over tagged interface)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.X_IOWRT_EU_MACVLAN.
obuspa -c add Device.Ethernet.X_IOWRT_EU_MACVLAN.
obuspa -c add Device.Ethernet.VLANTermination.
obuspa -c add Device.Ethernet.Link.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.Enable 1

obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.X_IOWRT_EU_MACVLAN.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.X_IOWRT_EU_MACVLAN.2

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.2.Enable 1

obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1
obuspa -c set Device.DHCPv4.Client.2.Interface Device.IP.Interface.2

obuspa -c set Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers Device.Ethernet.VLANTermination.1
obuspa -c set Device.Ethernet.X_IOWRT_EU_MACVLAN.2.LowerLayers Device.Ethernet.VLANTermination.1

obuspa -c set Device.Ethernet.VLANTermination.1.VLANID 100
obuspa -c set Device.Ethernet.VLANTermination.1.LowerLayers Device.Ethernet.Link.1

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fde7:715b:fb50::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface1'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4_1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4_2'
        option macaddr '44:D4:37:71:B5:54'

config device 'mac_vlan_1'
        option type 'macvlan'
        option ifname 'eth4.100'
        option name 'eth4_1'
        option macaddr '44:D4:37:71:B5:53'

config device 'mac_vlan_2'
        option type 'macvlan'
        option ifname 'eth4.100'
        option name 'eth4_2'
        option macaddr '44:D4:37:71:B5:54'

config device 'vlan_ter_1'
        option type '8021q'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.X_IOWRT_EU_MACVLAN.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.X_IOWRT_EU_MACVLAN.2
$ obuspa -c get Device.Ethernet.X_IOWRT_EU_MACVLAN.*.LowerLayers
Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers => Device.Ethernet.VLANTermination.1
Device.Ethernet.X_IOWRT_EU_MACVLAN.2.LowerLayers => Device.Ethernet.VLANTermination.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
Device.Ethernet.VLANTermination.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
Device.DHCPv4.Client.2.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
```

### 6. One VLAN per Customer(MACVLAN over untagged interface)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.Ethernet.X_IOWRT_EU_MACVLAN.
obuspa -c add Device.Ethernet.X_IOWRT_EU_MACVLAN.
obuspa -c add Device.Ethernet.Link.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.Enable 1

obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.X_IOWRT_EU_MACVLAN.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.X_IOWRT_EU_MACVLAN.2

obuspa -c set Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers Device.Ethernet.Link.1
obuspa -c set Device.Ethernet.X_IOWRT_EU_MACVLAN.2.LowerLayers Device.Ethernet.Link.1

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3

obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1

obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.2.Enable 1
obuspa -c set Device.DHCPv4.Client.2.Interface Device.IP.Interface.2
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd75:d87a:791b::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface1'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4_1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4_2'
        option macaddr '44:D4:37:71:B5:54'

config device 'mac_vlan_1'
        option type 'macvlan'
        option ifname 'eth4'
        option name 'eth4_1'
        option macaddr '44:D4:37:71:B5:53'

config device 'mac_vlan_2'
        option type 'macvlan'
        option ifname 'eth4'
        option name 'eth4_2'
        option macaddr '44:D4:37:71:B5:54'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.X_IOWRT_EU_MACVLAN.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.X_IOWRT_EU_MACVLAN.2
$ obuspa -c get Device.Ethernet.X_IOWRT_EU_MACVLAN.*.LowerLayers
Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers => Device.Ethernet.Link.1
Device.Ethernet.X_IOWRT_EU_MACVLAN.2.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
Device.DHCPv4.Client.2.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
```

### 7. VLAN Translation

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Ethernet.Link.
obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c add Device.Bridging.Bridge.1.VLANPort.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1

obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.2

obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1
obuspa -c set Device.Bridging.Bridge.1.Port.4.Enable 1

obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.4.ManagementPort 0

obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Enable 1

obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Port Device.Bridging.Bridge.1.Port.2


obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Port Device.Bridging.Bridge.1.Port.3

obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.VLAN Device.Bridging.Bridge.1.VLAN.2
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Port Device.Bridging.Bridge.1.Port.4

obuspa -c set Device.Bridging.Bridge.1.VLAN.1.VLANID 100
obuspa -c set Device.Bridging.Bridge.1.VLAN.2.VLANID 200

obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.1.Port.4.LowerLayers Device.Ethernet.Interface.3

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1
obuspa -c set Device.Ethernet.Link.2.LowerLayers Device.Ethernet.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd07:a062:db26::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface1'
        option proto 'none'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4'
        option macaddr '44:D4:37:71:B5:54'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        option macaddr '44:D4:37:71:B5:53'
        list ports 'eth1.100'
        list ports 'eth3.100'
        list ports 'eth4.200'

config device 'br_1_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth1'
        option name 'eth1.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_2'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth3'
        option name 'eth3.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_3'
        option type '8021q'
        option enabled '1'
        option vid '200'
        option ifname 'eth4'
        option name 'eth4.200'
        option macaddr '44:D4:37:71:B5:53'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3,Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.1.Port.4.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.1.VLAN.1.Enable => 1
Device.Bridging.Bridge.1.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLAN.1.Name => br_1_vlan_1
Device.Bridging.Bridge.1.VLAN.1.VLANID => 100
Device.Bridging.Bridge.1.VLAN.2.Enable => 1
Device.Bridging.Bridge.1.VLAN.2.Alias => cpe-2
Device.Bridging.Bridge.1.VLAN.2.Name => br_1_vlan_2
Device.Bridging.Bridge.1.VLAN.2.VLANID => 200
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.1.VLANPort.1.Enable => 1
Device.Bridging.Bridge.1.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLANPort.1.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.1.Port => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.2.Enable => 1
Device.Bridging.Bridge.1.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.1.VLANPort.2.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.2.Port => Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.VLANPort.2.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.3.Enable => 1
Device.Bridging.Bridge.1.VLANPort.3.Alias => cpe-3
Device.Bridging.Bridge.1.VLANPort.3.VLAN => Device.Bridging.Bridge.1.VLAN.2
Device.Bridging.Bridge.1.VLANPort.3.Port => Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.VLANPort.3.Untagged => 0
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
```

### 8. Managed Bridge

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.Bridging.Bridge.

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.3.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.3.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.1.Port.3.Enable 1

obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.4.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.4.LowerLayers Device.Ethernet.Interface.3
obuspa -c set Device.Bridging.Bridge.1.Port.4.Enable 1

obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c set Device.Bridging.Bridge.1.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Port Device.Bridging.Bridge.1.Port.2
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.VLAN Device.Bridging.Bridge.1.VLAN.1

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.Port Device.Bridging.Bridge.1.Port.3
obuspa -c set Device.Bridging.Bridge.1.VLANPort.2.VLAN Device.Bridging.Bridge.1.VLAN.1

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.3.Port Device.Bridging.Bridge.1.Port.4

obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Bridging.Bridge.1.Port.1

obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.Link.1

obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fde2:72a7:da9d::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config device 'dev_br1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1.100'
        list ports 'eth3.100'
        list ports 'eth4.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_1'
        option type '8021q'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1.100'
        option vid '100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_2'
        option type '8021q'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3.100'
        option vid '100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_3'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface1'
        option proto 'dhcp'
        option disabled '0'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2,Device.Bridging.Bridge.1.Port.3,Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.1.Port.3.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.1.Port.4.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.1.VLANPort.1.Enable => 1
Device.Bridging.Bridge.1.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLANPort.1.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.1.Port => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.2.Enable => 1
Device.Bridging.Bridge.1.VLANPort.2.Alias => cpe-2
Device.Bridging.Bridge.1.VLANPort.2.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.2.Port => Device.Bridging.Bridge.1.Port.3
Device.Bridging.Bridge.1.VLANPort.2.Untagged => 0
Device.Bridging.Bridge.1.VLANPort.3.Enable => 1
Device.Bridging.Bridge.1.VLANPort.3.Alias => cpe-3
Device.Bridging.Bridge.1.VLANPort.3.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.3.Port => Device.Bridging.Bridge.1.Port.4
Device.Bridging.Bridge.1.VLANPort.3.Untagged => 0
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.1.VLAN.1.Enable => 1
Device.Bridging.Bridge.1.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLAN.1.Name => br_1_vlan_1
Device.Bridging.Bridge.1.VLAN.1.VLANID => 100
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
```

### 9. QinQ lan untagged to wan double tagged (Bridge mode)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.2.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.2.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.3.Port.
obuspa -c set Device.Bridging.Bridge.3.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.3.Port.
obuspa -c set Device.Bridging.Bridge.3.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.3.Port.2.LowerLayers Device.Ethernet.Interface.3
obuspa -c set Device.Bridging.Bridge.3.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.3.VLAN.
obuspa -c set Device.Bridging.Bridge.3.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.3.VLANPort.
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.VLAN Device.Bridging.Bridge.3.VLAN.1
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.Port Device.Bridging.Bridge.3.Port.2

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.4.Port.
obuspa -c set Device.Bridging.Bridge.4.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.4.Port.
obuspa -c set Device.Bridging.Bridge.4.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.4.Port.2.TPID 34984
obuspa -c set Device.Bridging.Bridge.4.Port.2.LowerLayers Device.Bridging.Bridge.3.Port.2
obuspa -c set Device.Bridging.Bridge.4.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.4.VLAN.
obuspa -c set Device.Bridging.Bridge.4.VLAN.1.VLANID 300

obuspa -c add Device.Bridging.Bridge.4.VLANPort.
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.VLAN Device.Bridging.Bridge.4.VLAN.1
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.Port Device.Bridging.Bridge.4.Port.2

obuspa -c add  Device.Bridging.ProviderBridge.

obuspa -c set Device.Bridging.ProviderBridge.1.CVLANcomponents Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
obuspa -c set Device.Bridging.ProviderBridge.1.SVLANcomponent Device.Bridging.Bridge.4
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdf8:6c90:1a98::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:53'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface_br1'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config device 'pr_br_1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1'
        list ports 'eth3'
        list ports 'eth4.100.300'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_3_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:54'

config device 'br_4_port_1'
        option type '8021ad'
        option enabled '1'
        option vid '300'
        option ifname 'eth4.100'
        option name 'eth4.100.300'
        option macaddr '44:D4:37:71:B5:55'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.2.Port.1.LowerLayers => Device.Bridging.Bridge.2.Port.2
Device.Bridging.Bridge.2.Port.2.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.3.Port.1.LowerLayers => Device.Bridging.Bridge.3.Port.2
Device.Bridging.Bridge.3.Port.2.LowerLayers => Device.Ethernet.Interface.3
Device.Bridging.Bridge.4.Port.1.LowerLayers => Device.Bridging.Bridge.4.Port.2
Device.Bridging.Bridge.4.Port.2.LowerLayers => Device.Bridging.Bridge.3.Port.2
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.3.VLANPort.1.Enable => 1
Device.Bridging.Bridge.3.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.3.VLANPort.1.VLAN => Device.Bridging.Bridge.3.VLAN.1
Device.Bridging.Bridge.3.VLANPort.1.Port => Device.Bridging.Bridge.3.Port.2
Device.Bridging.Bridge.3.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.4.VLANPort.1.Enable => 1
Device.Bridging.Bridge.4.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.4.VLANPort.1.VLAN => Device.Bridging.Bridge.4.VLAN.1
Device.Bridging.Bridge.4.VLANPort.1.Port => Device.Bridging.Bridge.4.Port.2
Device.Bridging.Bridge.4.VLANPort.1.Untagged => 0
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.3.VLAN.1.Enable => 1
Device.Bridging.Bridge.3.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.3.VLAN.1.Name => br_3_vlan_1
Device.Bridging.Bridge.3.VLAN.1.VLANID => 100
Device.Bridging.Bridge.4.VLAN.1.Enable => 1
Device.Bridging.Bridge.4.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.4.VLAN.1.Name => br_4_vlan_1
Device.Bridging.Bridge.4.VLAN.1.VLANID => 300
$ obuspa -c get Device.Bridging.ProviderBridge.
Device.Bridging.ProviderBridge.1.Enable => 1
Device.Bridging.ProviderBridge.1.Status => Enabled
Device.Bridging.ProviderBridge.1.Alias => cpe-1
Device.Bridging.ProviderBridge.1.SVLANcomponent => Device.Bridging.Bridge.4
Device.Bridging.ProviderBridge.1.CVLANcomponents => Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
```

### 10. QinQ lan single tagged to wan double tagged (Bridge mode)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.1.Port.
obuspa -c set Device.Bridging.Bridge.1.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.1.Port.2.LowerLayers Device.Ethernet.Interface.1
obuspa -c set Device.Bridging.Bridge.1.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.1.VLAN.
obuspa -c set Device.Bridging.Bridge.1.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.1.VLANPort.
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.VLAN Device.Bridging.Bridge.1.VLAN.1
obuspa -c set Device.Bridging.Bridge.1.VLANPort.1.Port Device.Bridging.Bridge.1.Port.2

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.2.Port.
obuspa -c set Device.Bridging.Bridge.2.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.2.Port.2.LowerLayers Device.Ethernet.Interface.2
obuspa -c set Device.Bridging.Bridge.2.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.2.VLAN.
obuspa -c set Device.Bridging.Bridge.2.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.2.VLANPort.
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.VLAN Device.Bridging.Bridge.2.VLAN.1
obuspa -c set Device.Bridging.Bridge.2.VLANPort.1.Port Device.Bridging.Bridge.2.Port.2

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.3.Port.
obuspa -c set Device.Bridging.Bridge.3.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.3.Port.
obuspa -c set Device.Bridging.Bridge.3.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.3.Port.2.LowerLayers Device.Ethernet.Interface.3
obuspa -c set Device.Bridging.Bridge.3.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.3.VLAN.
obuspa -c set Device.Bridging.Bridge.3.VLAN.1.VLANID 100

obuspa -c add Device.Bridging.Bridge.3.VLANPort.
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.VLAN Device.Bridging.Bridge.3.VLAN.1
obuspa -c set Device.Bridging.Bridge.3.VLANPort.1.Port Device.Bridging.Bridge.3.Port.2

obuspa -c add Device.Bridging.Bridge.
obuspa -c add Device.Bridging.Bridge.4.Port.
obuspa -c set Device.Bridging.Bridge.4.Port.1.ManagementPort 1
obuspa -c add Device.Bridging.Bridge.4.Port.
obuspa -c set Device.Bridging.Bridge.4.Port.2.ManagementPort 0
obuspa -c set Device.Bridging.Bridge.4.Port.2.TPID 34984
obuspa -c set Device.Bridging.Bridge.4.Port.2.LowerLayers Device.Bridging.Bridge.3.Port.2
obuspa -c set Device.Bridging.Bridge.4.Port.2.Enable 1

obuspa -c add Device.Bridging.Bridge.4.VLAN.
obuspa -c set Device.Bridging.Bridge.4.VLAN.1.VLANID 300

obuspa -c add Device.Bridging.Bridge.4.VLANPort.
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.Enable 1
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.VLAN Device.Bridging.Bridge.4.VLAN.1
obuspa -c set Device.Bridging.Bridge.4.VLANPort.1.Port Device.Bridging.Bridge.4.Port.2

obuspa -c add  Device.Bridging.ProviderBridge.

obuspa -c set Device.Bridging.ProviderBridge.1.CVLANcomponents Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
obuspa -c set Device.Bridging.ProviderBridge.1.SVLANcomponent Device.Bridging.Bridge.4
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fde7:6307:3a39::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface_br1'
        option device 'br-dev1'
        option macaddr '44:D4:37:71:B5:53'

config device 'pr_br_1'
        option name 'br-dev1'
        option type 'bridge'
        option bridge_empty '1'
        list ports 'eth1.100'
        list ports 'eth3.100'
        list ports 'eth4.100.300'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_1_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth1'
        option name 'eth1.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_2_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth3'
        option name 'eth3.100'
        option macaddr '44:D4:37:71:B5:53'

config device 'br_3_port_1'
        option type '8021q'
        option enabled '1'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'
        option macaddr '44:D4:37:71:B5:55'

config device 'br_4_port_1'
        option type '8021ad'
        option enabled '1'
        option vid '300'
        option ifname 'eth4.100'
        option name 'eth4.100.300'
        option macaddr '44:D4:37:71:B5:53'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
Device.Bridging.Bridge.1.Port.1.LowerLayers => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.Port.2.LowerLayers => Device.Ethernet.Interface.1
Device.Bridging.Bridge.2.Port.1.LowerLayers => Device.Bridging.Bridge.2.Port.2
Device.Bridging.Bridge.2.Port.2.LowerLayers => Device.Ethernet.Interface.2
Device.Bridging.Bridge.3.Port.1.LowerLayers => Device.Bridging.Bridge.3.Port.2
Device.Bridging.Bridge.3.Port.2.LowerLayers => Device.Ethernet.Interface.3
Device.Bridging.Bridge.4.Port.1.LowerLayers => Device.Bridging.Bridge.4.Port.2
Device.Bridging.Bridge.4.Port.2.LowerLayers => Device.Bridging.Bridge.3.Port.2
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
Device.Bridging.Bridge.1.VLANPort.1.Enable => 1
Device.Bridging.Bridge.1.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLANPort.1.VLAN => Device.Bridging.Bridge.1.VLAN.1
Device.Bridging.Bridge.1.VLANPort.1.Port => Device.Bridging.Bridge.1.Port.2
Device.Bridging.Bridge.1.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.2.VLANPort.1.Enable => 1
Device.Bridging.Bridge.2.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLANPort.1.VLAN => Device.Bridging.Bridge.2.VLAN.1
Device.Bridging.Bridge.2.VLANPort.1.Port => Device.Bridging.Bridge.2.Port.2
Device.Bridging.Bridge.2.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.3.VLANPort.1.Enable => 1
Device.Bridging.Bridge.3.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.3.VLANPort.1.VLAN => Device.Bridging.Bridge.3.VLAN.1
Device.Bridging.Bridge.3.VLANPort.1.Port => Device.Bridging.Bridge.3.Port.2
Device.Bridging.Bridge.3.VLANPort.1.Untagged => 0
Device.Bridging.Bridge.4.VLANPort.1.Enable => 1
Device.Bridging.Bridge.4.VLANPort.1.Alias => cpe-1
Device.Bridging.Bridge.4.VLANPort.1.VLAN => Device.Bridging.Bridge.4.VLAN.1
Device.Bridging.Bridge.4.VLANPort.1.Port => Device.Bridging.Bridge.4.Port.2
Device.Bridging.Bridge.4.VLANPort.1.Untagged => 0
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
Device.Bridging.Bridge.1.VLAN.1.Enable => 1
Device.Bridging.Bridge.1.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.1.VLAN.1.Name => br_1_vlan_1
Device.Bridging.Bridge.1.VLAN.1.VLANID => 100
Device.Bridging.Bridge.2.VLAN.1.Enable => 1
Device.Bridging.Bridge.2.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.2.VLAN.1.Name => br_2_vlan_1
Device.Bridging.Bridge.2.VLAN.1.VLANID => 100
Device.Bridging.Bridge.3.VLAN.1.Enable => 1
Device.Bridging.Bridge.3.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.3.VLAN.1.Name => br_3_vlan_1
Device.Bridging.Bridge.3.VLAN.1.VLANID => 100
Device.Bridging.Bridge.4.VLAN.1.Enable => 1
Device.Bridging.Bridge.4.VLAN.1.Alias => cpe-1
Device.Bridging.Bridge.4.VLAN.1.Name => br_4_vlan_1
Device.Bridging.Bridge.4.VLAN.1.VLANID => 300
$ obuspa -c get Device.Bridging.ProviderBridge.
Device.Bridging.ProviderBridge.1.Enable => 1
Device.Bridging.ProviderBridge.1.Status => Enabled
Device.Bridging.ProviderBridge.1.Alias => cpe-1
Device.Bridging.ProviderBridge.1.SVLANcomponent => Device.Bridging.Bridge.4
Device.Bridging.ProviderBridge.1.CVLANcomponents => Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
```

### 11. QinQ (Route mode)

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.DHCPv4.Client.
obuspa -c add Device.Ethernet.VLANTermination.
obuspa -c add Device.Ethernet.VLANTermination.
obuspa -c add Device.Ethernet.Link.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.VLANTermination.2

obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1

obuspa -c set Device.Ethernet.VLANTermination.1.VLANID 100
obuspa -c set Device.Ethernet.VLANTermination.1.LowerLayers Device.Ethernet.Link.1

obuspa -c set Device.Ethernet.VLANTermination.2.TPID 34984
obuspa -c set Device.Ethernet.VLANTermination.2.VLANID 200
obuspa -c set Device.Ethernet.VLANTermination.2.LowerLayers Device.Ethernet.VLANTermination.1

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fde6:fba3:37bb::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface1'
        option proto 'dhcp'
        option disabled '0'
        option device 'eth4.100.200'
        option macaddr '44:D4:37:71:B5:53'

config device 'vlan_ter_1'
        option type '8021q'
        option vid '100'
        option ifname 'eth4'
        option name 'eth4.100'

config device 'vlan_ter_2'
        option type '8021ad'
        option vid '200'
        option ifname 'eth4.100'
        option name 'eth4.100.200'
        option macaddr '44:D4:37:71:B5:53'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.VLANTermination.2
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
Device.Ethernet.VLANTermination.1.LowerLayers => Device.Ethernet.Link.1
Device.Ethernet.VLANTermination.2.LowerLayers => Device.Ethernet.VLANTermination.1
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
```

### 12. PPPoE WAN connection

- **TR-181 Commands**

```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*

obuspa -c add Device.IP.Interface.
obuspa -c add Device.PPP.Interface.
obuspa -c add Device.Ethernet.Link.

obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.PPP.Interface.1

obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.1
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1

obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd8d:6e8e:444f::/48'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'iface1'
        option proto 'pppoe'
        option disabled '0'
        option device 'eth4'
        option macaddr '44:D4:37:71:B5:53'
        option username 'test'
        option password 'test'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
```

### 13. Switch WAN connection from DHCP to PPP

- **TR-181 Commands**

```bash
obuspa -c set Device.DHCPv4.Client.1.Interface ""
obuspa -c set Device.DHCPv6.Client.1.Interface ""
obuspa -c set Device.IP.Interface.2.LowerLayers ""

obuspa -c add Device.PPP.Interface.
obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1

obuspa -c set Device.IP.Interface.2.LowerLayers Device.PPP.Interface.1
```

- **Network UCI Config**

```bash
$ cat /etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'pppoe'
        option macaddr '44:D4:37:71:B5:52'
        option username 'test'
        option password 'test'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => 
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => 
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```

### 14. Switch WAN connection from PPP to Static

- **TR-181 Commands**

```bash
obuspa -c set Device.IP.Interface.2.LowerLayers ""

obuspa -c del Device.PPP.Interface.1

obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.IP.Interface.2.Enable 1

obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.1.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.1.IPAddress 10.100.1.222
obuspa -c set Device.IP.Interface.2.IPv4Address.1.SubnetMask 255.255.255.0

obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.2.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.2.IPAddress 10.100.10.222
obuspa -c set Device.IP.Interface.2.IPv4Address.2.SubnetMask 255.255.255.0
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'none'
        option macaddr '44:D4:37:71:B5:52'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:54'

config interface 'iface2_ipv4_1'
        option device 'eth4'
        option proto 'static'
        option disabled '0'
        option ipaddr '10.100.1.222'
        option netmask '255.255.255.0'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2_ipv4_2'
        option device 'eth4'
        option proto 'static'
        option disabled '0'
        option ipaddr '10.100.10.222'
        option netmask '255.255.255.0'
        option macaddr '44:D4:37:71:B5:54'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => 
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => 
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.IP.Interface.2.IPv4Address.
Device.IP.Interface.2.IPv4Address.1.Enable => 1
Device.IP.Interface.2.IPv4Address.1.Status => Enabled
Device.IP.Interface.2.IPv4Address.1.Alias => cpe-1
Device.IP.Interface.2.IPv4Address.1.IPAddress => 10.100.1.222
Device.IP.Interface.2.IPv4Address.1.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.1.AddressingType => Static
Device.IP.Interface.2.IPv4Address.2.Enable => 1
Device.IP.Interface.2.IPv4Address.2.Status => Enabled
Device.IP.Interface.2.IPv4Address.2.Alias => cpe-2
Device.IP.Interface.2.IPv4Address.2.IPAddress => 10.100.10.222
Device.IP.Interface.2.IPv4Address.2.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.2.AddressingType => Static
```

### 15. Switch WAN connection from Static to DHCP

- **TR-181 Commands**

```bash
obuspa -c del Device.IP.Interface.2.IPv4Address.1
obuspa -c del Device.IP.Interface.2.IPv4Address.2

obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.2
obuspa -c set Device.DHCPv6.Client.1.Interface Device.IP.Interface.2
```

- **Network UCI Config**

```bash
$ cat /etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'dhcp'
        option macaddr '44:D4:37:71:B5:52'
        option hostname 'eagle-44d43771b550'
        option vendorid 'dslforum.org'
        option sendopts '124:00000DE90403757370 125:00000DE91C0106343444343337020B593037323131343030383603054541474C45'
        option reqopts '125 43'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'wan6'
        option device 'eth4'
        option proto 'dhcpv6'
        option macaddr '44:D4:37:71:B5:52'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```

### 16. Switch WAN connection from DHCP to Static

- **TR-181 Commands**

```bash
obuspa -c set Device.DHCPv4.Client.1.Interface ""
obuspa -c set Device.DHCPv6.Client.1.Interface ""

obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.1.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.1.IPAddress 10.100.1.222
obuspa -c set Device.IP.Interface.2.IPv4Address.1.SubnetMask 255.255.255.0

obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.2.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.2.IPAddress 10.100.10.222
obuspa -c set Device.IP.Interface.2.IPv4Address.2.SubnetMask 255.255.255.0
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'none'
        option macaddr '44:D4:37:71:B5:52'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2_ipv4_1'
        option device 'eth4'
        option proto 'static'
        option disabled '0'
        option ipaddr '10.100.1.222'
        option netmask '255.255.255.0'
        option macaddr '44:D4:37:71:B5:53'

config interface 'iface2_ipv4_2'
        option device 'eth4'
        option proto 'static'
        option disabled '0'
        option ipaddr '10.100.10.222'
        option netmask '255.255.255.0'
        option macaddr '44:D4:37:71:B5:54'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => 
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => 
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.IP.Interface.2.IPv4Address.
Device.IP.Interface.2.IPv4Address.1.Enable => 1
Device.IP.Interface.2.IPv4Address.1.Status => Enabled
Device.IP.Interface.2.IPv4Address.1.Alias => cpe-1
Device.IP.Interface.2.IPv4Address.1.IPAddress => 10.100.1.222
Device.IP.Interface.2.IPv4Address.1.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.1.AddressingType => Static
Device.IP.Interface.2.IPv4Address.2.Enable => 1
Device.IP.Interface.2.IPv4Address.2.Status => Enabled
Device.IP.Interface.2.IPv4Address.2.Alias => cpe-2
Device.IP.Interface.2.IPv4Address.2.IPAddress => 10.100.10.222
Device.IP.Interface.2.IPv4Address.2.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.2.AddressingType => Static
```

### 17. Switch WAN connection from Static to PPP

- **TR-181 Commands**

```bash
obuspa -c del Device.IP.Interface.2.IPv4Address.1
obuspa -c del Device.IP.Interface.2.IPv4Address.2

obuspa -c set Device.IP.Interface.2.LowerLayers ""

obuspa -c add Device.PPP.Interface.
obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1

obuspa -c set Device.IP.Interface.2.LowerLayers Device.PPP.Interface.1
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'pppoe'
        option macaddr '44:D4:37:71:B5:52'
        option username 'test'
        option password 'test'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => 
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => 
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```

### 18. Switch WAN connection from PPP to DHCP

- **TR-181 Commands**

```bash
obuspa -c set Device.IP.Interface.2.LowerLayers ""

obuspa -c del Device.PPP.Interface.1

obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2

obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.2
obuspa -c set Device.DHCPv6.Client.1.Interface Device.IP.Interface.2
```

- **Network UCI Config**

```bash
$ cat /etc/config/network 

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd7c:b8d8:8e46::/48'

config device 'br_lan'
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1'
        list ports 'eth3'
        option multicast_to_unicast '0'
        option macaddr '44:D4:37:71:B5:51'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option is_lan '1'
        option macaddr '44:D4:37:71:B5:51'

config interface 'wan'
        option device 'eth4'
        option proto 'dhcp'
        option macaddr '44:D4:37:71:B5:52'
        option hostname 'eagle-44d43771b550'
        option vendorid 'dslforum.org'
        option sendopts '124:00000DE90403757370 125:00000DE91C0106343444343337020B593037323131343030383603054541474C45'
        option reqopts '125 43'

config device 'dev_eth1'
        option enabled '1'
        option ifname 'eth1'
        option name 'eth1'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth3'
        option enabled '1'
        option ifname 'eth3'
        option name 'eth3'
        option eee '0'
        option pause '0'
        option macaddr '44:D4:37:71:B5:51'

config device 'dev_eth4'
        option enabled '1'
        option ifname 'eth4'
        option name 'eth4'
        option eee '0'
        option pause '1'
        option macaddr '44:D4:37:71:B5:52'

config interface 'wan6'
        option device 'eth4'
        option proto 'dhcpv6'
        option macaddr '44:D4:37:71:B5:52'

```

- **TR-181 Data Model**

```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```

### 19. MACVLAN Dual WAN with Policy-Based Routing

#### MACVLAN — recap

The `Device.Ethernet.X_IOWRT_EU_MACVLAN` object (described in sections 5 and 6) creates
a virtual Ethernet interface that shares a physical port but carries its own MAC address,
so the upstream device treats it as a separate connection and issues it an independent
DHCP lease.  This scenario builds on that foundation to add a second WAN on the same
physical port and then use Policy-Based Routing to steer specific traffic through it.

---

#### Introduction to Policy-Based Routing (PBR)

Normal IP routing uses a single routing table for every packet — all traffic follows the
same default gateway regardless of its source, destination, or type.  **Policy-Based
Routing** lets you maintain several routing tables and select which one is used based on
attributes of each individual packet: its source address, destination address, or a
numeric mark stamped on it by a classifier.

A typical dual-WAN use case: you have two internet connections and want to send video
streaming or traffic to a specific server through one WAN, while everything else continues
through the primary WAN.  PBR makes this possible without changing the application or the
LAN configuration.

**This section covers:**

- How TR-181 objects map to Linux routing concepts
- How `Routing.Router`, `Routing.Policy`, and `IP.Interface` are connected
- Variant 1: Plain PBR — steer traffic by destination IP prefix
- Variant 2: PBR with QoS classification — steer traffic by L4 criteria (protocol/port)
  using `ForwardingPolicy` as a shared tag between the QoS classifier and the routing rule
- Equivalent UCI and verification steps
- Static routes via `IPv4Forwarding` (for setups without DHCP)

---

#### How TR-181 objects map to Linux concepts

| TR-181 object | Linux concept | How to inspect |
|---|---|---|
| `Device.Routing.Router.{i}` | Routing table (identified by an integer ID) | `ip route show table <ID>` |
| `Device.Routing.Policy.{i}` | IP rule | `ip rule show` |

**Routing table — `Device.Routing.Router`**

Linux supports up to 252 user-defined routing tables, each identified by a number.
Every `Routing.Router` instance corresponds to one table; the `ID` parameter holds
its number.  Table 254 (named `main`) always exists and handles normal traffic.
When you `add Device.Routing.Router.` the daemon auto-assigns the next free table ID
from the range 1–252 — check `Device.Routing.Router.{i}.ID` after the add to learn
the assigned number.  You cannot specify the ID directly.

**IP rule — `Device.Routing.Policy`**

The kernel evaluates rules in priority order (lower number = checked first).  Each rule
has a match condition and a `lookup <table>` action — a matching packet is forwarded
using the routes in that table.  Without any matching rule a packet falls through to the
`main` table and uses the default gateway.

The most useful match fields on `Device.Routing.Policy`:

| Parameter | UCI option | `ip rule` field | Meaning |
|---|---|---|---|
| `Priority` | `priority` | priority N | Order in which rules are evaluated |
| `SourceIPPrefix` | `src` | `from <prefix>` | Match by source address |
| `DestIPPrefix` | `dest` | `to <prefix>` | Match by destination address |
| `RouterRef` | `lookup` | `lookup <table>` | Routing table to use when rule matches |

---

#### How the objects are connected

```
Device.IP.Interface.3              ← new WAN (MACVLAN-backed)
    │
    │  .Router = Device.Routing.Router.2
    │  Tells the DHCP client to install learned routes into routing table N,
    │  not into the main table.  (Sets ip4table='N' in UCI.)
    ▼
Device.Routing.Router.2            ← routing table N  (ip route show table N)
    ▲
    │  .RouterRef = Device.Routing.Router.2
    │
Device.Routing.Policy.1            ← ip rule: "packets matching X → look up table N"
```

**`IP.Interface.Router` → `Routing.Router`**

Setting this on a WAN interface causes its DHCP client to install the learned default
gateway into the specified routing table instead of the `main` table.  Without this
link, the second WAN's DHCP default route would overwrite the primary WAN's route in
the main table and all traffic would suddenly leave via the wrong interface.

```sh
# dmcli — link the WAN interface to routing table N
set Device.IP.Interface.3.Router  Device.Routing.Router.2
# Writes: option ip4table 'N' on the UCI interface section.
# udhcpc then places its learned default gateway into table N automatically.
```

**`Routing.Policy.RouterRef` → `Routing.Router`**

This is what actually steers packets.  The ip rule says "if this packet matches my
criteria, use routing table N for its forwarding decision".  The `Routing.Router`
holds the routes (including the default gateway placed there by DHCP).

```sh
# dmcli — create an ip rule that sends matching traffic to table N
add Device.Routing.Policy.
set Device.Routing.Policy.1.RouterRef    Device.Routing.Router.2
set Device.Routing.Policy.1.Priority     100
set Device.Routing.Policy.1.Enable       true
# Add match criteria — see Variant 1 and Variant 2 below.
```

---

#### Scenario

A MACVLAN is layered on the existing physical WAN port.  It gets its own MAC address so
the upstream device sees it as a separate interface and issues an independent DHCP lease.
A dedicated routing table is created for this interface so its DHCP default gateway does
not displace the primary WAN's default route in the main table.

```
Device.IP.Interface.3
        │  (LowerLayers)
        ▼
Device.Ethernet.X_IOWRT_EU_MACVLAN.1    ← own MAC address; upstream sees a separate device
        │  (LowerLayers)
        ▼
Device.Ethernet.Link.3
        │  (LowerLayers)
        ▼
Device.Ethernet.Interface.5             ← shared physical WAN port
```

Two PBR variants are shown:

1. **Plain PBR** — route traffic destined for `8.8.8.8/32` via the MACVLAN WAN; all
   other traffic uses the primary WAN.
2. **PBR with QoS classification** — route UDP traffic on port 5001 via the MACVLAN
   WAN, identified by L4 fields using a QoS classifier.

---

#### Variant 1: Plain PBR

**Step 1 — Create the MACVLAN interface stack and routing table**

The routing table assignment (`IP.Interface.Router`) must be committed before the DHCP
client is added.  When `DHCPv4.Client` is created, `udhcpc` starts immediately; if the
routing table is not yet assigned it installs the learned gateway into the main table,
defeating the purpose of the dedicated table.  See the limitation note in the Important
notes section.

```sh
# dmcli
start
add Device.Ethernet.Link.
set Device.Ethernet.Link.3.Enable       1
set Device.Ethernet.Link.3.Alias        new-link
set Device.Ethernet.Link.3.LowerLayers  Device.Ethernet.Interface.5
add Device.Ethernet.X_IOWRT_EU_MACVLAN.
set Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers  Device.Ethernet.Link.3
add Device.IP.Interface.
set Device.IP.Interface.3.Enable        1
set Device.IP.Interface.3.Alias         new-iface
set Device.IP.Interface.3.LowerLayers   Device.Ethernet.X_IOWRT_EU_MACVLAN.1

add Device.Routing.Router.
# Auto-assigns a table ID. Check with: get Device.Routing.Router.2.ID
set Device.Routing.Router.2.Name            new_router

# Link the WAN interface to this routing table.
set Device.IP.Interface.3.Router            Device.Routing.Router.2

# Add an ip rule: packets destined for 8.8.8.8/32 → look up table N.
add Device.Routing.Policy.
set Device.Routing.Policy.1.Priority        100
set Device.Routing.Policy.1.RouterRef       Device.Routing.Router.2
set Device.Routing.Policy.1.DestIPPrefix    8.8.8.8/32
set Device.Routing.Policy.1.SourceIPPrefix  0.0.0.0/0
set Device.Routing.Policy.1.Enable          true

# Add the DHCP client
add Device.DHCPv4.Client.
set Device.DHCPv4.Client.2.Enable       1
set Device.DHCPv4.Client.2.Alias        new-dhcp
set Device.DHCPv4.Client.2.Interface    Device.IP.Interface.3
commit
```

**Step 2 — NAT and firewall**

```sh
# dmcli
start
# Enable masquerading on the new WAN so LAN source IPs are rewritten before egress.
# Without this, reply packets have no path back to the LAN client.
set Device.NAT.InterfaceSetting.3.Enable 1

# Allow forwarding from LAN to the new MACVLAN WAN.
# Without this the default DROP policy blocks forwarded traffic.
# Adjust SourceInterface to match your actual LAN interface.
add Device.Firewall.Chain.1.Rule.
set Device.Firewall.Chain.1.Rule.12.SourceInterface  Device.IP.Interface.1
set Device.Firewall.Chain.1.Rule.12.DestInterface    Device.IP.Interface.3
set Device.Firewall.Chain.1.Rule.12.Target           Accept
set Device.Firewall.Chain.1.Rule.12.Enable           1
commit
```

**Resulting kernel state**

```sh
$ ip rule show
0:      from all lookup local
100:    from 0.0.0.0/0 to 8.8.8.8 lookup 1      ← created by Routing.Policy.1
32766:  from all lookup main
32767:  from all lookup default

$ ip route show table 1
default via <macvlan-gw> dev ae_wan_1             ← installed by udhcpc
```

---

#### Variant 2: PBR with QoS classification

`Device.Routing.Policy` can match by source or destination IP prefix, but `ip rule`
cannot inspect L4 fields (protocol, port).  When you need to steer traffic based on
those, a second object is needed: `Device.QoS.Classification`.

The connection between the two is `ForwardingPolicy` — a shared numeric tag that
becomes a Linux **firewall mark (fwmark)** on the packet:

- `Device.QoS.Classification.ForwardingPolicy` — when a packet matches the classifier
  (by protocol, port, etc.) the daemon stamps it with this value via
  `iptables -t mangle … MARK --set-mark <N>`.
- `Device.Routing.Policy.ForwardingPolicy` — the ip rule matches packets carrying this
  fwmark and routes them to the associated routing table
  (`ip rule add fwmark <N> lookup <table>`).

Setting the **same number** in both objects is how they are wired together.  The value
itself is arbitrary — it just needs to be consistent between the two.

This variant routes only UDP traffic destined for port 5001 through the MACVLAN WAN.
The QoS classifier stamps matching packets with `fwmark 5`; the routing policy matches
on that mark.  Steps 2 and 3 (DHCP client, NAT and firewall) are identical to Variant 1.

**Step 1 — Create the MACVLAN interface stack, routing table, PBR rule, and QoS classifier**

```sh
# dmcli
start
add Device.Ethernet.Link.
set Device.Ethernet.Link.3.Enable       1
set Device.Ethernet.Link.3.Alias        new-link
set Device.Ethernet.Link.3.LowerLayers  Device.Ethernet.Interface.5
add Device.Ethernet.X_IOWRT_EU_MACVLAN.
set Device.Ethernet.X_IOWRT_EU_MACVLAN.1.LowerLayers  Device.Ethernet.Link.3
add Device.IP.Interface.
set Device.IP.Interface.3.Enable        1
set Device.IP.Interface.3.Alias         new-iface
set Device.IP.Interface.3.LowerLayers   Device.Ethernet.X_IOWRT_EU_MACVLAN.1

add Device.Routing.Router.
set Device.Routing.Router.2.Name              udp5001_wan
set Device.IP.Interface.3.Router              Device.Routing.Router.2

# ip rule: packets with fwmark=5 → look up table N
add Device.Routing.Policy.
set Device.Routing.Policy.1.Priority          100
set Device.Routing.Policy.1.RouterRef         Device.Routing.Router.2
set Device.Routing.Policy.1.ForwardingPolicy  5
set Device.Routing.Policy.1.SourceIPPrefix    0.0.0.0/0
set Device.Routing.Policy.1.Enable            true

# QoS classifier: UDP dport 5001 → set fwmark=5 via iptables mangle
add Device.QoS.Classification.
set Device.QoS.Classification.13.Order            1
set Device.QoS.Classification.13.AllInterfaces    true
set Device.QoS.Classification.13.Protocol         17       # 17 = UDP
set Device.QoS.Classification.13.DestPort         5001
set Device.QoS.Classification.13.ForwardingPolicy 5
set Device.QoS.Classification.13.Enable           true

# Add the DHCP client
add Device.DHCPv4.Client.
set Device.DHCPv4.Client.2.Enable       1
set Device.DHCPv4.Client.2.Alias        new-dhcp
set Device.DHCPv4.Client.2.Interface    Device.IP.Interface.3

commit
```

**Resulting kernel state**

```sh
$ ip rule show
0:      from all lookup local
100:    from 0.0.0.0/0 fwmark 0x5 lookup 1       ← created by Routing.Policy.1
32766:  from all lookup main
32767:  from all lookup default

$ iptables -t mangle -L qos_prerouting -n -v
Chain qos_prerouting (1 references)
 pkts bytes target  prot opt in  out  source    destination
    0     0 MARK    udp  --  *   *    0.0.0.0/0 0.0.0.0/0  udp dpt:5001  MARK set 0x5
```

---

#### Equivalent UCI (for reference)

After applying the configuration, the relevant `/etc/config/network` stanzas look like:

```
config device 'mac_vlan_1'
    option type    'macvlan'
    option ifname  'ae_wan'       # the underlying physical or link interface
    option name    'ae_wan_1'
    option macaddr '58:00:32:C0:0E:44'

config interface 'iface3'
    option proto    'dhcp'
    option disabled '0'
    option device   'ae_wan_1'
    option macaddr  '58:00:32:C0:0E:44'
    option ip4table '1'           # set by IP.Interface.3.Router; routes DHCP lease into table 1

# Variant 1 — match by destination prefix
config rule 'rule_1'
    option disabled  '0'
    option priority  '100'
    option lookup    '1'          # table ID auto-assigned to Routing.Router.2
    option src       '0.0.0.0/0'
    option dest      '8.8.8.8/32'

# Variant 2 — match by fwmark (replace rule above)
# config rule 'rule_1'
#     option disabled  '0'
#     option priority  '100'
#     option lookup    '1'
#     option mark      '5'        # UCI uses 'mark'; kernel displays this as 'fwmark 0x5'
#     option src       '0.0.0.0/0'
```

---

#### Important notes

**DHCP client must be added after the routing table is assigned**

When `DHCPv4.Client` is created, `udhcpc` starts immediately and installs its learned
default gateway into whatever routing table is current at that moment.  If
`IP.Interface.Router` has not been set yet, `udhcpc` writes into the main routing table
(254) instead of the dedicated one, and traffic that should be isolated to the new WAN
can escape via the main table or interfere with the primary WAN's default route.

For this reason the interface stack and `IP.Interface.Router` assignment must be
committed in the same transaction, and the `DHCPv4.Client` must be added in a separate
subsequent transaction — as shown in the steps above.

**Default route on the MACVLAN interface**

There is currently no way to suppress the extra default route that `udhcpc` may install
in the main routing table when the MACVLAN interface comes up.  If this happens the new
interface's gateway can displace the primary WAN's default route, and a **device reboot
may be required** to restore expected routing.  Setting `IP.Interface.Router` isolates
the DHCP-assigned routes into a separate table but may not prevent `udhcpc` from also
writing a default route into the main table on all firmware versions.

**`option in 'loopback'` written by default**

- In order to allow working with loopback interface, `option in 'loopback'` is written
into the generated UCI rule if SourceIPPrefix and interface is not set for a
Device.Routing.Policy object, which is also the case when you add a new object.

- This allows the user to set policy for loopback interface. But in this case,
ForwardingPolicy cannot be used.

- When `SourceIPPrefix` is set, this is automatically removed. If needed, the user can
set this to the match-all prefix, which clears the `in` field:

```sh
set Device.Routing.Policy.1.SourceIPPrefix 0.0.0.0/0
```

Both variants above already include this.  Alternatively, fix directly in UCI:

```sh
uci del network.rule_1.in && uci commit network && /etc/init.d/network reload
```

**Firewall forwarding rule is required**

Without an explicit accept rule between the LAN `IP.Interface` and the MACVLAN
`IP.Interface`, forwarded traffic is dropped by the default firewall `FORWARD DROP`
policy.  Adjust `SourceInterface` to match the LAN interface your test clients sit
behind.

**NAT on the new WAN interface**

`Device.NAT.InterfaceSetting` enables MASQUERADE on the interface so LAN-side source
addresses are rewritten to the MACVLAN's WAN address before egress.  Without NAT,
reply packets from the internet are addressed to the LAN IP and cannot return.

---

#### Verification

From a LAN client (not from the router itself — locally generated traffic bypasses
`PREROUTING` and the fwmark rule will never apply to it):

- **Variant 1:** send any traffic to `8.8.8.8`, e.g. `ping 8.8.8.8`
- **Variant 2:** send UDP to port 5001 on any destination

Watch for packets on the MACVLAN interface on the router:

```sh
# On the router
tcpdump -i ae_wan_1 -n

# Expected — Variant 1 (LAN client 10.0.0.5, NAT rewrites source):
58:00:32:c0:0e:44 > aa:00:aa:73:01:01, ethertype IPv4
    10.10.10.150 > 8.8.8.8: ICMP echo request

# Traffic to other destinations exits via the primary WAN (not ae_wan_1):
aa:00:aa:73:01:01 > 58:00:32:c0:0e:41, ethertype IPv4
    1.1.1.1 > 10.0.0.5: ICMP echo reply
```

The source IP `10.10.10.150` on egress confirms that PBR steered the packet onto the
MACVLAN WAN and NAT rewrote the source address.

For Variant 2, additionally verify the fwmark counter and the routing decision:

```sh
# Zero the mangle counter, send UDP/5001, then check it incremented:
iptables -t mangle -Z qos_prerouting
# ... send UDP/5001 from a LAN device ...
iptables -t mangle -L qos_prerouting -n -v

# Verify routing decision for marked vs unmarked packets (no traffic needed):
ip route get 8.8.8.8 mark 5   # expected: dev ae_wan_1 (MACVLAN WAN)
ip route get 8.8.8.8           # expected: dev ae_wan   (primary WAN)
```

---

#### Static routes via IPv4Forwarding

In the scenarios above the DHCP client automatically populates the routing table
(`ip4table`) with the learned gateway, so no manual routes are needed.  If you are
configuring a static WAN instead, you can add routes directly into the routing table
using the `IPv4Forwarding` sub-object of `Routing.Router`:

```sh
# dmcli — add a static default route into the routing table of Router.2
add Device.Routing.Router.2.IPv4Forwarding.
set Device.Routing.Router.2.IPv4Forwarding.1.DestIPAddress    0.0.0.0
set Device.Routing.Router.2.IPv4Forwarding.1.DestSubnetMask   0.0.0.0
set Device.Routing.Router.2.IPv4Forwarding.1.GatewayIPAddress 10.10.10.1
set Device.Routing.Router.2.IPv4Forwarding.1.Interface        Device.IP.Interface.3
set Device.Routing.Router.2.IPv4Forwarding.1.Enable           true
```

This is equivalent to `ip route add default via 10.10.10.1 dev ae_wan_1 table N` and
writes a `config route` stanza with `option table 'N'` in `/etc/config/network`.

---

## Deployment Scenarios Limitations

- Device.Bridging.Bridge.{i}.Port.{i}.LowerLayers: its value will be generated automatically when user defines **'ManagementPort'** parameter as **1**
- If user forgets to define a Bridge.{i}.Port. instance as management port, then there is no way to assign that Bridge.{i}.Port.{i}. for any interface(Device.Ethernet.Link.{i}.)
- Only one device port(ethx) is allowed for each Bridge{i}.Port. instance
- There are other deployment scenarios that can be configured by our devices using TR-181 data model, but we describe only the most important ones above
