> For the complete documentation index, see [llms.txt](https://jncia-workbook.gitbook.io/workbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jncia-workbook.gitbook.io/workbook/junos-switching/4-router-on-a-stick.md).

# 4) Router-on-a-Stick

### Pre-Work

Load the config called **lab4.cfg** using the **load\_config\_on\_nodes.py** script.

```
python3 load_config_on_nodes.py --lab_dir switched-lan --config_filename lab4.cfg
```

### Lab

Labs 1-3 are already pre-configured.&#x20;

Configure R1 as a "router on a stick" so that hosts in VLAN 100 can reach hosts in VLAN 200.

* `ae1.100` - `10.0.100.1/24` and `2001:db8:100::1/64`
* `ae1.200` - `10.0.200.1/24` and `2001:db8:200::1/64`

### Answer

<details>

<summary>Expand to reveal</summary>

```
set interfaces ae1 vlan-tagging
delete interfaces ae1.0
set interfaces ae1.100 vlan-id 100
set interfaces ae1.100 family inet address 10.0.100.1/24
set interfaces ae1.100 family inet6 address 2001:db8:100::1/64
set interfaces ae1.200 vlan-id 200
set interfaces ae1.200 family inet address 10.0.200.1/24
set interfaces ae1.200 family inet6 address 2001:db8:200::1/64
```

\
`Unit 0` was present in the previous lab to bring the bundle up. Now we must delete it, as we are using vlan-tagging on the interface.

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

In order to use VLAN-tagged subinterfaces, we must add the following configuration. This is true whether you are using a physical interface or LACP bundle.

```
set interfaces <interface> vlan-tagging
```

\
There are actually three available options:

* `vlan-tagging` - one single VLAN tag required on each unit
* `stacked-vlan-tagging` - two VLAN tags (QinQ) required on each unit
* `flexible-vlan-tagging` - one or two VLAN tags required on each unit. You can mix single-tagging and double-tagging on different units on the same interface.

\
Next we assign the VLAN id to each logical unit:

```
set interfaces ae1.100 vlan-id 100
```

\
IPv4/IPv6 address configuration is the same as usual.

```
set interfaces ae1.100 family inet address 10.0.100.1/24
set interfaces ae1.100 family inet6 address 2001:db8:100::1/64
```

\
We can see the VLAN-tagged logical interfaces are present:

```
admin@R1> show interfaces terse | match ae1 
ge-0/0/0.100            up    up   aenet    --> ae1.100
ge-0/0/0.200            up    up   aenet    --> ae1.200
ge-0/0/0.32767          up    up   aenet    --> ae1.32767
ge-0/0/1.100            up    up   aenet    --> ae1.100
ge-0/0/1.200            up    up   aenet    --> ae1.200
ge-0/0/1.32767          up    up   aenet    --> ae1.32767
ae1                     up    up
ae1.100                 up    up   inet     10.0.100.1/24   
ae1.200                 up    up   inet     10.0.200.1/24   
ae1.32767               up    up   multiservice
```

\
Using `show interfaces`, we can see the configured VLAN tag:

```
admin@R1> show interfaces ae1.100 | match VLAN 
    Flags: Up SNMP-Traps 0x4000 VLAN-Tag [ 0x8100.100 ]  Encapsulation: ENET2
```

\
Hosts can ping each other in different VLANs:

```
admin@HOST-RTR> ping 10.0.200.104 routing-instance host1                    
PING 10.0.200.104 (10.0.200.104): 56 data bytes
64 bytes from 10.0.200.104: icmp_seq=0 ttl=63 time=5.888 ms
64 bytes from 10.0.200.104: icmp_seq=1 ttl=63 time=6.594 ms

admin@HOST-RTR> ping 2001:db8:200::104 routing-instance host1    
PING6(56=40+8+8 bytes) 2001:db8:100::101 --> 2001:db8:200::104
16 bytes from 2001:db8:200::104, icmp_seq=0 hlim=63 time=13.315 ms
16 bytes from 2001:db8:200::104, icmp_seq=1 hlim=63 time=5.264 ms
```

\
On R1, we should see corresponding ARP and ND entries:

```
admin@R1> show arp 
MAC Address       Address         Name                      Interface               Flags
52:55:0a:00:00:02 10.0.0.2        10.0.0.2                  fxp0.0                  none
aa:c1:ab:20:72:1e 10.0.100.101    10.0.100.101              ae1.100                 none
aa:c1:ab:65:0e:67 10.0.100.103    10.0.100.103              ae1.100                 none
aa:c1:ab:4c:d7:d4 10.0.200.102    10.0.200.102              ae1.200                 none
aa:c1:ab:23:b9:73 10.0.200.104    10.0.200.104              ae1.200                 none
02:00:00:00:00:10 128.0.0.16      fpc0                      em1.0                   none
Total entries: 6

admin@R1> show ipv6 neighbors 
IPv6 Address                            Linklayer Address  State       Exp   Rtr  Secure  Interface               
2001:db8::1                              none               unreachable  0    no   no      fxp0.0                  
2001:db8:100::101                        aa:c1:ab:20:72:1e  stale       1188  yes  no      ae1.100                 
2001:db8:200::104                        aa:c1:ab:23:b9:73  stale       1182  yes  no      ae1.200                 
fe80::2                                  52:56:00:00:00:02  stale       265   yes  no      fxp0.0                  
Total entries: 4
```

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/multicast-l2/topics/task/interfaces-enabling-vlan-tagging.html>
