# 20201216 cisco VLAN

## 課堂資料

{% embed url="https://www.cnblogs.com/michael9/p/13360084.html" %}

{% embed url="https://www.jannet.hk/zh-Hant/post/vlan-trunking-protocol-vtp/" %}

### VLAN 的介绍

| Switch      |              |
| ----------- | ------------ |
| broadcast   | 採用"**廣播方式"** |
| multicast   | 採用"**廣播方式"** |
| Fwarding DB | 採用"**廣播方式"** |

{% hint style="info" %}
VLAN TAG 包的 VLAN ID 號，有效範圍是`1-4094`，0 和 4095 都為協議保留值，VLAN ID 0 表示不屬於任何 VLAN。

`1`为系统默认 VLAN，即 Native VLAN。默认情况下，所有的接口都属于 VLAN1. 当交换机收到未带有 VLAN TAG 包的数据帧时，会将数据包转发至 Native VLAN 端口。

`2-1001`是普通的 VLAN，`1006-1024`保留仅系统使用，用户不能查看和使用，`1002-1005`是支持 fddi 和令牌环的 VLAN，`1025-4095`是扩展的 VLAN。
{% endhint %}

### VLAN 802.1q

![802.1q VLAN](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MOd7gwVdsnN4YUS7bN1%2F-MOd92kGl9wgMdi_iT-f%2Fgfx2.png?alt=media\&token=c77c9445-8208-4f63-9759-0859c9c8dcad)

### VLAN VTP ( VLAN Trunking Protocol )

> #### VTP mode

| VTP         |                       |
| ----------- | --------------------- |
| Server      | 能創建、刪除、修改 VLAN        |
| Client      | 不能創建、刪除、修改 VLAN，能學習轉發 |
| Transparent | 能創建、刪除、修改 VLAN，不能學習轉發 |

## 課堂練習

### VLAN 802.1q

#### Part 01.&#x20;

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MOdcMsXYj78wqGSRa_3%2F-MOdhGRrkUlrefc_ukWQ%2Fimage.png?alt=media\&token=caddf71f-dc0b-42ae-bfc7-aa81950b9317)

{% tabs %}
{% tab title="VPC 2" %}
```
ip 192.168.1.1 255.255.255.0
```

```
ping 192.168.1.2
```

```
ping 192.168.1.3
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMfmuKyclB126E78zL%2Fimage.png?alt=media\&token=cff0539d-c2c9-415c-abc4-52b9c0e8ac9b)
{% endtab %}

{% tab title="VPC 3" %}
```
ip 192.168.1.2 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.3
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMg7znx5kRihZiOVFG%2Fimage.png?alt=media\&token=e2ce0f61-f298-4229-8d16-12b1486b6e60)
{% endtab %}

{% tab title="VPC 4" %}
```
ip 192.168.1.3 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.2
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMhxLOuQ8d3s8C_25v%2Fimage.png?alt=media\&token=b329b004-767d-46c6-9ff9-d687bbdda3e6)
{% endtab %}

{% tab title="VPC 5" %}
```
ip 192.168.1.4 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.2
```

```
ping 192.168.1.3
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMiJj_eB9pJRnJnlaN%2Fimage.png?alt=media\&token=bdd18603-d044-47d0-8bb0-b698b7f418ee)
{% endtab %}

{% tab title="SW" %}
```
vlan 10
```

```
name Vlan10
```

```
exit
```

```
vlan 20
```

```
name Vlan20
```

```
do sh vlan brief
```

```
int e0/0
```

```
switchport mode access
```

```
switchport access vlan 10
```

```
int e0/1
```

```
switchport mode access
```

```
switchport access vlan 10
```

```
int e0/2
```

```
switchport mode access
```

```
switchport access vlan 20
```

```
int e0/3
```

```
switchport mode access
```

```
switchport access vlan 20
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMpFqfluGNw73Lyuzg%2Fimage.png?alt=media\&token=757680bc-b22a-4c23-9314-3538f8d83fce)
{% endtab %}
{% endtabs %}

#### Part 02.&#x20;

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPMuDuQ-CUlcgTy_FpO%2Fimage.png?alt=media\&token=25ae617c-3c4c-4dd3-bf54-531249c6e38c)

{% tabs %}
{% tab title="VPC 2" %}
```
ip 192.168.1.1 255.255.255.0
```

```
ping 192.168.1.2
```

```
ping 192.168.1.3
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMssuvwcX38c7Mi_bd%2Fimage.png?alt=media\&token=c90ea85a-dd65-4aff-bb95-eff30b9f0b8e)
{% endtab %}

{% tab title="VPC 3" %}
```
ip 192.168.1.2 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.3
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMt5U3e6C_GLN9-bFW%2Fimage.png?alt=media\&token=7cfe3346-cb32-429b-ad85-c42015dd3c46)
{% endtab %}

{% tab title="SW 1" %}
```
vlan 10
```

```
name Vlan10
```

```
exit
```

```
vlan 20
```

```
name Vlan20
```

```
do sh vlan brief
```

```
int e0/0
```

```
switchport mode access
```

```
switchport access vlan 10
```

```
int e0/1
```

```
switchport mode access
```

```
switchport access vlan 20
```

```
int e0/2
```

```
switchport mode access
```

```
switchport access vlan 10
```

```
int e0/3
```

```
switchport mode access
```

```
switchport access vlan 20
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMs8Z74GTeLludtPcA%2Fimage.png?alt=media\&token=9a71231e-ec56-4405-aba8-33fad63f9beb)
{% endtab %}

{% tab title="VPC 4" %}
```
ip 192.168.1.3 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.2
```

```
ping 192.168.1.4
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMtJIKVbPB75VqVJxx%2Fimage.png?alt=media\&token=8dc548f0-5bf8-40d6-b211-50979ab9b287)
{% endtab %}

{% tab title="VPC 5" %}
```
ip 192.168.1.4 255.255.255.0
```

```
ping 192.168.1.1
```

```
ping 192.168.1.2
```

```
ping 192.168.1.3
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMtZXbUD0ySvvC8VHi%2Fimage.png?alt=media\&token=98e8c199-415f-4673-b57b-12d9285804fe)
{% endtab %}

{% tab title="SW 2" %}
```
vlan 10
```

```
name Vlan10
```

```
exit
```

```
vlan 20
```

```
name Vlan20
```

```
do sh vlan brief
```

```
int range e0/0,e0/2
```

```
switchport mode access
```

```
switchport access vlan 10
```

```
int range e0/1,e0/3
```

```
switchport mode access
```

```
switchport access vlan 20
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMd9kvGgHGKhpRny2v%2F-MPMsaBhMcw4G02ChLih%2Fimage.png?alt=media\&token=1d3bc3ea-521a-4ee9-9006-d547508b7c3d)
{% endtab %}
{% endtabs %}

### VLAN VTP

#### Part 01.

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPN6Xdn79eu-_JgX6xK%2Fimage.png?alt=media\&token=fe27e6b9-d5d4-47ab-a1ea-5edaebe2de22)

{% tabs %}
{% tab title="sw1" %}
> #### VTP Server 設定

```
vtp domain mynet
```

```
vtp password cisco
```

```
do sh vtp status
```

```
do sh vtp password
```

```
vlan 11-15,1006
```

```
do sh vlan brief
```

```
int e0/0
```

```
switchport trunk encapsulation dot1q
```

```
switchport mode trunk
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPN70fRcuYUqlNbWcRz%2Fimage.png?alt=media\&token=456e9bab-61c4-4591-be26-890959f15345)

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPN8vkS5WHiL04o6eEs%2Fimage.png?alt=media\&token=72094c93-adf3-4694-9ea5-3e2e928d196c)
{% endtab %}

{% tab title="sw2" %}
> #### VTP Client 設定

```
vtp mode client
```

```
vtp domain mynet
```

```
vtp password cisco
```

```
do sh vtp status
```

```
do sh vlan brief
```

```
int e0/0
```

```
switchport trunk encapsulation dot1q
```

```
switchport mode trunk
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPN7UmAp8vNC415t9WH%2Fimage.png?alt=media\&token=85c99da4-1add-48d4-9d7e-b236fc2cc45b)
{% endtab %}
{% endtabs %}

#### Part 02.

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNCR2PKUVzUH0cjMxy%2Fimage.png?alt=media\&token=f09b1ef2-b987-432c-8239-1a3c8edadbb3)

{% tabs %}
{% tab title="sw1" %}
```
no vlan 13
```

```
do sh vlan brief
```

```
no vlan 11
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNCl87A_9qRYhTEhU2%2Fimage.png?alt=media\&token=542cfca0-236b-446e-9e64-507961d8bed3)

```
vlan 20,21,22
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNCwBiHCIt3sHq1m3S%2Fimage.png?alt=media\&token=b84d30b2-7ee3-4ccd-8978-4d6ef9b016cd)
{% endtab %}

{% tab title="sw2" %}
```
do sh vlan brief
```

```
no vlan 12
```

```
vlan 16
```

```
int e0/1
```

```
switchport trunk encapsulation dot1q
```

```
switchport mode trunk
```

```
do sh vlan brief
```

```
exit
```

```
vtp mode transparent
```

```
do sh vtp status
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNDxMtrvHvxk9sekW7%2Fimage.png?alt=media\&token=c3ef5539-c420-493a-b5a8-11b7e13a8e2b)

```
do sh vlan brief
```

```
vlan 30
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNEOoD5dl3dgCb8DD5%2Fimage.png?alt=media\&token=ea94f60b-2435-4db5-b32b-3c43319cec9c)
{% endtab %}

{% tab title="sw3" %}
```
vtp mode client
```

```
vtp domain mynet
```

```
do sh vtp status
```

```
do sh vlan brief
```

```
int e0/0
```

```
switchport trunk encapsulation dot1q
```

```
switchport mode trunk
```

```
do sh vlan brief
```

![](https://1182807199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHJUVmIukmM2g9Ai7CY%2F-MPMu6sGeYCTVqYNlzzx%2F-MPNDXP3IVkxmgQgGfQ6%2Fimage.png?alt=media\&token=7a893948-b8d1-4e19-a275-0f9b21a85968)
{% endtab %}
{% endtabs %}
