1:用pc远程管理交换机

交换机的配置实例_休闲

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的配置:

交换机的配置实例_vlan vtp vlan间路由_02

通过telnet管理pc(是带内管理)

交换机的配置实例_职场_03:

2:交换机vlan的划分和配置

拓扑图:

交换机的配置实例_职场_04

交换机的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地址

实验拓扑图:

交换机的配置实例_休闲_05

交换机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

交换机的配置实例_交换机_06

交换机的配置实例_职场_07

三层交换机的接口必须先封装为dot1q后再封装为trunk

这时不同vlan间的pc就可以通信了

4 单臂路由实现不同vlan间路由

交换机的配置实例_休闲_08

交换机上配置:

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)

交换机的配置实例_职场_09

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