> For the complete documentation index, see [llms.txt](https://hamidsec.gitbook.io/cisco/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hamidsec.gitbook.io/cisco/setup-router-on-stick-layer-2-layer-3.md).

# Setup Router-on-a-Stick(Layer 2 -Layer 3)

![Router-On-a-stick](/files/-LAAdBwOnR2qyOqujJkZ)

To connect several vlans together, there is a model which is called "*Router-on-a-stick*". This model has some advantages:

* Cost effective
* Easy to Implement

On the other hand, there are some drawbacks in this model:

* Congestion on link(bottleneck on trunk port)
* If router becomes down, network will down&#x20;

```
switch(config)# int gi0/1
switch(config-if)# switchport mode trunk
```

```
router(config)# int gi0/0.10
router(config-subif)# encapsulation dot1Q 10
router(config-subif)# ip address 192.168.10.1 255.255.255.0

router(config)# int gi0/0.20
router(config-subif)# encapsulation dot1Q 20
router(config-subif)# ip address 192.168.20.1 255.255.255.0

router(config)# int gi0/0.30
router(config-subif)# encapsulation dot1Q 30
router(config-subif)# ip address 192.168.30.1 255.255.255.0
```

{% hint style="info" %}
In Switch layer2, we use router-on-a-stick to connect vlans together based on access-list we define.
{% endhint %}

## Layer 3 switches

![Multilayer Switch](/files/-LAdN3EyKpvRnNekZh54)

As it is shown, first set an IP address for the PC0 and PC1. PC0 is on Vlan 10, while PC1 is on Vlan 20. Default Gateway of both PCs are set with the IP address of Vlan in Switch. For routing between to Vlan, Just we use "*ip routing*" command as it is shown in below code:

```
switch(config)# vlan 10
switch(config-if)# ip address 192.168.10.254 255.255.255.0
switch(config-if)# exit

switch(config)# vlan 20
switch(config-if)# ip address 192.168.20.254 255.255.255.0
switch(config-if)# exit

switch(config)# ip routing

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hamidsec.gitbook.io/cisco/setup-router-on-stick-layer-2-layer-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
