交換機的配置實例

1:用pc遠程管理交換機

clip_p_w_picpath002

1 首先先要通過帶外管理配置交換機的管理地址和一些密碼

enable password ghn

interface Vlan1

ip address 192.168.1.1 255.255.255.0

line vty 0 4

password ghn

login

管理地址要和pc的地址在一個網端內

Pc的配置:

clip_p_w_picpath004

通過telnet管理pc(是帶內管理)

clip_p_w_picpath006:

2:交換機vlan的劃分和配置

拓撲圖:

clip_p_w_picpath008

交換機的switch0 的配置

hostname s1

vlan 2(建立兩個vlan)

vlan 3

interface FastEthernet0/1

switchport access vlan 2(把接口劃分到vlan中)

switchport mode access(接口模式)

interface FastEthernet0/2

switchport access vlan 3

switchport mode access

交換機的switch1的配置

hostname s2

vlan 2

vlan 3

interface FastEthernet0/1

switchport access vlan 2

switchport mode access

interface FastEthernet0/2

switchport access vlan 3

switchport mode access

此時同一個vlan內的pc現在還是不能互相通信,因爲交換機的端口模式默認是access模式,但是這個模式只能傳輸默認的vlan,要修改爲trunk模式,纔可以傳輸多個vlan並且給每一個vlan打上標籤

交換機的switch0的配置

interface FastEthernet0/3

switchport mode trunk

交換機的switch1的配置

interface FastEthernet0/3

switchport mode trunk

此時同一個vlan內的pc可以互相通信了。

3:利用三層交換機實現vlan間路由:

技術原理:

三層交換機具備網絡層的功能,實現vlan相互訪問的原理是:利用三層交換機的路由功能,通過識別數據包的ip地址,查找路由表進行選路轉發,三層交換機利用直連路由可以實現不同vlan之間的互相訪問,三層交換機給接口配置ip地址,採用svi(交換機虛擬接口)的方式實現vlan間互連,svi是指爲交換機中的vlan創建虛擬接口,並且配置ip地址

實驗拓撲圖:

clip_p_w_picpath010

交換機2的配置:

hostname s1

vlan 2

vlan 3

interface FastEthernet0/1

switchport access vlan 2

switchport mode access

!

interface FastEthernet0/2

switchport access vlan 3

!

interface FastEthernet0/3

switchport mode trunk

三層交換機的配置:

hostname s3

vlan 2

vlan 3

interface FastEthernet0/3

switchport trunk encapsulation dot1q

switchport mode trunk

!

interface FastEthernet0/4

switchport trunk encapsulation dot1q

switchport mode trunk

interface Vlan2

ip address 192.168.1.1 255.255.255.0

!

interface Vlan3

ip address 192.168.2.1 255.255.255.0

交換機三的配置:

hostname s2

vlan 2

vlan 3

interface FastEthernet0/1

switchport access vlan 2

switchport mode access

!

interface FastEthernet0/2

switchport access vlan 3

!

interface FastEthernet0/4

switchport mode trunk

clip_p_w_picpath012

clip_p_w_picpath014

三層交換機的接口必須先封裝爲dot1q後再封裝爲trunk

這時不同vlan間的pc就可以通信了

4 單臂路由實現不同vlan間路由

clip_p_w_picpath016

交換機上配置:

interface FastEthernet0/1

switchport access vlan 2

!

interface FastEthernet0/2

switchport access vlan 3

!

interface FastEthernet0/3

switchport mode trunk

路由器上的配置

interface FastEthernet0/0

no ip address

duplex auto

speed auto

!

interface FastEthernet0/0.1

encapsulation dot1Q 2 (2 代表vlan號)

ip address 192.168.1.1 255.255.255.0

!

interface FastEthernet0/0.2

encapsulation dot1Q 3(3爲vlan3)

ip address 192.168.2.1 255.255.255.0

4:實現不同交換機間vlan的同步(vtp)

clip_p_w_picpath018

hostname s1

!

no ip domain-lookup

interface FastEthernet0/1

switchport access vlan 2

!

interface FastEthernet0/2

switchport access vlan 3

!

interface FastEthernet0/3

switchport mode trunk

line con 0

password ghn

logging synchronous

login

!

line vty 0 4

password ghn

logging synchronous

login

vlan 2

vlan 3

S1(config)#vtp mode server(vtp的模式)

s1(config)#vtp domain ghn(vtp的域名)

Changing VTP domain name from NULL to ghn

S1(config)#vtp password ghn(vtp的密碼)

Setting device VLAN database password to ghn

S1(config)#vtp version 2(vtp的版本)

Cannot modify version in VTP client mode

s1#show vtp status

VTP Version : 2

Configuration Revision : 1Maximum VLANs supported locally : 255

Number of existing VLANs : 7

VTP Operating Mode : Server

VTP Domain Name : ghn

VTP Pruning Mode : Disabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0x37 0xD5 0xCB 0x48 0x67 0xFA 0xE4 0x93

Configuration last modified by 0.0.0.0 at 3-1-93 00:03:55

Local updater ID is 0.0.0.0 (no valid interface found)

s1(config)#vlan 4

s1#show vtp status

VTP Version : 2

Configuration Revision : 2(每當服務器端修改了vlan的配置,其配置版本號就會加1,然後用新的版本號向域中通告)

Maximum VLANs supported locally : 255

Number of existing VLANs : 8

VTP Operating Mode : Server

VTP Domain Name : ghn

VTP Pruning Mode : Disabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0xF0 0x79 0xD7 0x05 0x5B 0x66 0x85 0xEC

hostname s2

interface FastEthernet0/1

switchport access vlan 2

interface FastEthernet0/2

switchport access vlan 3

interface FastEthernet0/3

switchport mode trunk

line con 0

password ghn

logging synchronous

login

line vty 0 4

password ghn

logging synchronous

login

s2(config)#vtp mode client

Setting device to VTP CLIENT mode.

s2(config)#vtp domain ghn

Changing VTP domain name from NULL to ghn

s2(config)#vtp password ghn

Setting device VLAN database password to ghn

s2(config)#vtp version 2

s2#show vtp status

VTP Version : 2

Configuration Revision : 1

Maximum VLANs supported locally : 255

Number of existing VLANs : 7

VTP Operating Mode : Client

VTP Domain Name : ghn

VTP Pruning Mode : Disabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0x37 0xD5 0xCB 0x48 0x67 0xFA 0xE4 0x93

Configuration last modified by 0.0.0.0 at 3-1-93 00:03:55

s2#show vtp status

VTP Version : 2

Configuration Revision : 2

Maximum VLANs supported locally : 255

Number of existing VLANs : 8

VTP Operating Mode : Client

VTP Domain Name : ghn

VTP Pruning Mode : Disabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章