> 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/vlan.md).

# VLAN

&#x20;A virtual LAN (Local Area Network) is a logical subnetwork that can group together a collection of devices from different physical LAN.

## 1-1 Create VLAN

Imagine that we have different departments on your company and you want to separate each department based on their employees. So, with the VLAN concept you can create a VLAN and then assign different ports to these VLANs.

![Vlan 10-20-30 in Switch1](https://3594902569-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LAAgNTo1Y8Mu1gdPunH%2F-LAAiLVC3BzKR5zCiS-v%2Fimage.png?alt=media\&token=e0da47d3-f18a-4809-8f8c-75254738f5a2)

In the above picture, we have 3 departments, each of which is assigned to unique VLAN. let's configure switch:

```
sw# conf t
sw(config)# vlan 10
sw(config-vlan)# name Management
sw(config-vlan)# exit
sw(config)# vlan 20
sw(config-vlan)# name IT
sw(config-vlan)# exit
sw(config)# vlan 30
sw(config-vlan)# name SALES
sw(config-vlan)# exit
```

For viewing created VLANs, we enter this command:

```
sw# show vlan 
```

![](https://3594902569-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LAAgNTo1Y8Mu1gdPunH%2F-LAAjxXDSEdn4gecO56E%2Fimage.png?alt=media\&token=a831bd7d-20da-4152-aba1-ee5831a8c09d)

{% hint style="info" %}
&#x20;VLAN 1 is a default VLAN in Cisco devices. VLAN from 1002-1005 are for other protocols. VLAN from 1006- 4094 is called Extended VLAN.
{% endhint %}

## 1-2 Access Switch Ports to Vlan

In above picture, a PC in VLAN 10 is connected to port Fa0/1 switch. So, we can write this command to access port Fa0/1 to VLAN 10:

```
sw(config)# int fa0/1
sw(config-vlan)# switchport mode access
sw(config-vlan)# switchport access vlan 10
sw(config-vlan)# exit
```

Now, if we enter *show vlan:*

![](https://3594902569-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LAAlWrePnYELHPF59A2%2F-LAApJspUiCS2l1zLwTA%2Fimage.png?alt=media\&token=296fdd6e-79e0-4e20-964f-9583921cd4a8)

Now we do it for other ports:

```
sw(config)# int fa0/2
sw(config-vlan)# switchport mode access
sw(config-vlan)# switchport access vlan 20
sw(config-vlan)# exit
sw(config)# int fa0/3
sw(config-vlan)# switchport mode access
sw(config-vlan)# switchport access vlan 30
sw(config-vlan)# exit
```

and the result is:

![](https://3594902569-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA8bJEHYZEGCK8WGuvC%2F-LAAlWrePnYELHPF59A2%2F-LAAp2eurWH1lGjQx4FK%2Fimage.png?alt=media\&token=d820db7d-caa9-48c5-bb7d-eda273babc8c)

## 1-3 Native Vlan

By default in Cisco switches , Vlan 1 is a native Vlan. It means, untagged traffic carries in this vlan. We'll know how to change Native Vlan.
