交换机VLAN、 TRUNK 、VTP 配置

交换机VLANTRUNK VTP 配置

1. 配置 CISCO 二层交换机的IP 地址(catalyst 2950 为例)

SW1(config)#int vlan 1 //进入管理接口interface vlan 1

SW1(config-if)#ip address 11.1.1.2 255.255.255.0 //配置IP 地址

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#ip default-gateway 11.1.1.1 //配置网关,可通过show run 查

查看所配置的 IP 地址:

SW1#show int vlan 1

Vlan1 is up, line protocol is up

Hardware is CPU Interface, address is 0008.20ff.6400 (bia 0008.20ff.6400)

Internet address is 11.1.1.2/24

2.配置交换机的端口速度和双工(Speed and Duplex)

SW1(config)#interface fa0/1

SW1(config-if)#speed {10 | 100 | auto} //10M/100M/自适应

SW1(config-if)#duplex {auto | full | half} //自适应/全双工/半双工

一般情况下,交换机两端的端口速度和双工要匹配,这样通信质量才能得到保证,在相同厂家的产品

(比如说Cisco 的交换机互连)中端口协商不用配置一般不会有什么问题,可以通过show interface 查

看端口的速度和双工。通常在不同厂家的产品中(比如说Cisco 和华为互连)如果通过查看发现端口速

度和双工不匹配,可以通过手工配置来解决。如图:

通过 show interface 查看端口的速度和双工:

SW1#show interfaces fastEthernet 0/24

FastEthernet0/24 is up, line protocol is up (connected)

Hardware is Fast Ethernet, address is 0008.20ff.6418 (bia 0008.20ff.6418)

MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

Keepalive set (10 sec)

Full-duplex, 100Mb/s, media type is 100BaseTX

input flow-control is unsupported output flow-control is unsupported

ARP type: ARPA, ARP Timeout 04:00:00

Last input 00:00:03, output 00:00:00, output hang never

注:CISCO 交换机端口默认值:Auto-duplex, Auto-speed, media type is 100BaseTX

Cisco 设备配置端口速度(speed)和双工(duplex)命令:

SW1(config)#interface fastEthernet 0/24

SW1(config-if)#speed ?

10 Force 10 Mbps operation ----------------------------注:强制速度为10M

100 Force 100 Mbps operation---------------------------注:强制速度为100M

auto Enable AUTO speed configuration -----------------注:速度自动协议(默认值)

SW1(config-if)#duplex ?

auto Enable AUTO duplex configuration ----------------注:自动协商双工

full Force full duplex operation ---------------------------注:强制为全双工

half Force half-duplex operation --------------------------注:强制为半双工

3.设置永久MAC 地址不过期

SW1(config)#mac-address-table static mac_addr {vlan vlan_id} [interface int1 [int2 ... int15]]

SW1(config)#mac-address-table static 1111.1111.a111 vlan 1 interface f0/1

配置后show mac-address-table 可以看到静态添加的MAC 地址1111.1111.a111

SW1#show mac-address-table

Vlan Mac Address Type Ports

---- ----------- -------- -----

All 000f.72db.4ec0 STATIC CPU

1 1111.1111.a111 STATIC Fa0/1

4.管理MAC 地址表

SW1#show mac-address-table

Mac Address Table

-------------------------------------------

Vlan Mac Address Type Ports

---- ----------- -------- -----

All 000f.72db.4ec0 STATIC CPU

1 0000.0c3f.0b05 DYNAMIC Fa0/12

1 0030.94e6.391d DYNAMIC Fa0/11

1 00e0.b05a.5bfe DYNAMIC Fa0/10

1 1111.1111.a111 STATIC Fa0/1

5.设置交换机端口的访问模式(三种) access /dynamic / trunk

SW1(config-if)#switchport mode ?

access Set trunking mode to ACCESS unconditionally

dynamic Set trunking mode to dynamically negotiate access or trunk mode

trunk Set trunking mode to TRUNK unconditionally

SW1(config)#int fastEthernet 0/1

SW1(config-if)#switchport mode access //设置FA0/1 为ACCESS 模式

SW1(config-if)#switchport mode trunk //设置FA0/1 为TRUNK 模式

SW1(config-if)#switchport mode dynamic auto //设置FA0/1 为自动直协商模式(默认)

交换机TRUNK 端口配置:

1)一般交换机与交换机相连接的端口要设置为trunk 模式

2 )如果是梳心交换机与非网管的交换机相连,梳心交换机端口设置为access 模式

如下图:

配置 SW1:

SW1(config)#int f0/24

SW1(config-if)#no shutdown

SW1(config-if)#switchport mode trunk //设置FA0/24 为TRUNK 模式

配置 SW2:

SW2(config)#int f0/24

SW2(config-if)#no shutdown

SW2(config-if)#switchport mode trunk //设置FA0/24 为TRUNK 模式

验证 TRUNK 命令:

Show interface trunk

Show interface f0/24 switchport

SW1#sho run int f0/24

interface FastEthernet0/24

switchport mode trunk

SW1#show int trunk

Port Mode Encapsulation Status Native vlan

Fa0/24 on 802.1q trunking 1

SW1#show int f0/24 switchport

Name: Fa0/24

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Voice VLAN: none

Administrative private-vlan host-association: none

Administrative private-vlan mapping: none

Administrative private-vlan trunk native VLAN: none

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk private VLANs: none

Operational private-vlan: none

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

Protected: false

Appliance trust: none

SW1#

SW2:

SW2#sho run int f0/24

interface FastEthernet0/24

switchport mode trunk

end

SW2#show int trunk

Port Mode Encapsulation Status Native vlan

Fa0/24 on 802.1q trunking 1

6.配置VLAN

1).创建VLAN

SW1(config)#vlan 2 //创建VLAN2

SW1(config)#name VLAN2 //命名为VLAN2,默认为vlan002,命名是可选命令

2).将端口加入VLAN

SW1(config-if)#switchport mode access //设配端口为access 模式

SW1(config-if)#switchport access vlan 2 //把端口加到vlan2

3).检查的命令

Switch#show vlan

例子:

创建 VLAN2 命令为widom ,

创建VLAN3 命令为market

把端口F0/4 加入VLAN2

SW1#config t

SW1(config)#vlan 2

SW1(config-vlan)#name wisdom

SW1(config-vlan)#exit

SW1(config)#vlan 3

SW1(config-vlan)#name market

SW1(config-vlan)#exit

SW1(config)#int fas0/4

SW1(config-if)#switchport mode access

SW1(config-if)#switchport access vlan 2

可以同时把多个端口加入到相应VLAN

SW1(config)#interface range fastEthernet 0/10 – 15 //可以同时把多个端口加入到一个VLAN 里

SW1(config-if-range)#switchport mode access

SW1(config-if-range)#switchport access vlan 3 //把端口10-15 都加入到VLAN3 里

SW1#show vlan //检查VLAN 信息

VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active Fa0/1, Fa0/5, Fa0/6, Fa0/7

Fa0/8, Fa0/9, Fa0/16, Fa0/17

Fa0/18, Fa0/19, Fa0/20, Fa0/21

Fa0/22, Fa0/23, Fa0/24

2 wisdom active Fa0/4

3 market active Fa0/10, Fa0/11, Fa0/12

Fa0/13, Fa0/14, Fa0/15

SW1#

7.配置VTP----VTP 技术使得在大型的网络里布置多个VLAN 变得简单.

VTP 的配置步骤:

1、配置Trunk (交换机和交换机相连的端口要设置为TRUNK)

2、配置VTP DOMAIN

3、配置VTP MODE

4、配置VLAN

5、将端口加入VLAN

6、检查

Switch#show interface xx/xx switchport //查看相应该接口的trunk 状态

Switch#show vtp status  //查看vtp 状态

Switch#show vlan //查看VLAN

配置 SW1:

SW1#configure terminal

SW1(config)#interface fastEthernet 0/24

SW1(config-if)#switchport mode trunk

SW1(config-if)#no shutdown

SW1(config-if)#exit

SW1(config)#vtp domain wisdom

Domain name already set to wisdom.

SW1(config)#vtp mode server

Device mode already VTP SERVER.

SW1(config)#vtp password cisco

Setting device VLAN database password to cisco

SW1(config)#vtp pruning //配置VTP 的修剪,只要在SERVER 端配置就行.

Pruning switched on

SW1#sho vtp status

VTP Version : 2

Configuration Revision : 1

Maximum VLANs supported locally : 64

Number of existing VLANs : 5

VTP Operating Mode : Server

VTP Domain Name : wisdom

VTP Pruning Mode : Enabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0xE8 0x5A 0x7D 0xB1 0x0E 0xBC 0xEB 0x1F

Configuration last modified by 11.1.1.2 at 3-1-93 02:56:31

Local updater ID is 11.1.1.2 on interface Vl1 (lowest numbered VLAN interface found)

创建 VLAN2 VLAN3 VLAN4 VLAN5

SW1(config)#vlan 2

SW1(config-vlan)#vlan 3

SW1(config-vlan)#vlan 4

SW1(config-vlan)#vlan 5

SW1(config-vlan)#

在 SW1 上创建VLAN 后查看修订版本:

SW1#show vtp status

VTP Version : 2

Configuration Revision : 5

Maximum VLANs supported locally : 128

Number of existing VLANs : 9

VTP Operating Mode : Server

VTP Domain Name : wisdom

VTP Pruning Mode : Enabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0x9C 0x64 0xD6 0x44 0x5E 0x54 0x9E 0xFC

Configuration last modified by 11.1.1.2 at 3-1-93 02:59:04

Local updater ID is 11.1.1.2 on interface Vl1 (lowest numbered VLAN interface found)

在交换机 SW1 上检查已创建的VLAN

SW1#sho vlan

VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active Fa0/1, Fa0/5, Fa0/6, Fa0/7

Fa0/8, Fa0/9, Fa0/16, Fa0/17

Fa0/18, Fa0/19, Fa0/20, Fa0/21

Fa0/22, Fa0/23, Fa0/24

2 VLAN0002 active

3 VLAN0003 active

4 VLAN0004 active

5 VLAN0005 active

检查 trunk 端口:

SW1#show interfaces fastEthernet 0/24 switchport

Name: Fa0/24

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Voice VLAN: none

Administrative private-vlan host-association: none

Administrative private-vlan mapping: none

Administrative private-vlan trunk native VLAN: none

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk private VLANs: none

Operational private-vlan: none

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

Protected: false

Appliance trust: none

配置 SW2:

Switch#

Switch#config t

Enter configuration commands, one per line. End with CNTL/Z.

SW2(config)#hostname SW2

SW2(config)#int fastEthernet 0/24

SW2(config-if)#switchport mode trunk

SW2(config-if)#exit

SW2(config)#vtp domain wisdom

Changing VTP domain name from test to wisdom

SW2(config)#vtp mode client

Setting device to VTP CLIENT mode.

SW2(config)#vtp password cisco

Setting device VLAN database password to cisco

SW2(config)#

查看 F0/24 trunk 状态:

SW2#show interfaces fastEthernet 0/24 switchport

Name: Fa0/24

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Voice VLAN: none

Administrative private-vlan host-association: none

Administrative private-vlan mapping: none

Administrative private-vlan trunk native VLAN: none

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk private VLANs: none

Operational private-vlan: none

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

Protected: false

Appliance trust: none

查看 VTP 状态:

SW2#show vtp status

VTP Version : 2

Configuration Revision : 5

Maximum VLANs supported locally : 128

Number of existing VLANs : 9

VTP Operating Mode : Client

VTP Domain Name : wisdom

VTP Pruning Mode : Enabled

VTP V2 Mode : Disabled

VTP Traps Generation : Disabled

MD5 digest : 0x9C 0x64 0xD6 0x44 0x5E 0x54 0x9E 0xFC

Configuration last modified by 11.1.1.2 at 3-1-93 02:59:04

----------此处可以看到SW2 的VLAN 信息是从SW1-11.1.1.2 同步过来的

SW2#show vlan

VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5

Fa0/6, Fa0/7, Fa0/8, Fa0/9

Fa0/10, Fa0/11, Fa0/12, Fa0/13

Fa0/14, Fa0/15, Fa0/16, Fa0/17

Fa0/18, Fa0/19, Fa0/20, Fa0/21

Fa0/22, Fa0/23, Fa0/24

2 VLAN0002 active

3 VLAN0003 active

4 VLAN0004 active

5 VLAN0005 active

实验结果:

SW2 不用配置VLAN,已同步了SW1 的VLAN 信息.实验成功

SW2 同步VTP SERVER 的VLAN 后,接下来的操作就是安要求把相应的端口加入到相应的VLAN

时间: 2024-07-31 18:46:19

交换机VLAN、 TRUNK 、VTP 配置的相关文章

交换机的Vlan /TRUNK/VTP配置

1. Sw1 sw2 sw3上有3个VLAN,要求,交换机之前采用vtp方式完成VLAN信息同步. 2. SW2必须是transparent 模式. 3. 实现不同VLAN 间的通信. 基础配置,以及启用vtp ,观察SW2如果使用vtp transparent 模式,能够将SW1的VLAN信息 传递给SW3 SW1 配置: Switch>enable Switch#config terminal Switch(config)#line console 0 Switch(config-line)

实验13:VLAN/TRUNK/VTP/

实验10-1: 划分VLAN Ø    实验目的通过本实验,读者可以掌握如下技能:(1) 熟悉VLAN 的创建(2) 把交换机接口划分到特定VLAN Ø    实验拓扑 实验步骤要配置VLAN,首先要先创建VLAN,然后才把交换机的端口划分到特定的端口上:n    步骤1:在划分VLAN 前,配置R1(PC0) ,PC1和PC2的f0/0 接口,交换机的全部接口都在VLAN1 上,PC1和PC2应该能够通信:n    步骤2:在S1 上创建VLANSW1#vlan database//进入到VL

交换基础 VLAN TRUNK VTP

两台交换机互连,每台交换机下有两台pc(路由器做交换机添加交换模块,路由器做pc关闭路由功能) 第一台交换机下的pc1 f0/0:ip地址为192.168.10.1 vlan10,pc2 f0/0:192.168.20.1 vlan20,第二天交换机下的pc3 f0/0:ip地址为 192.168.10.2 vlan10,pc4 f0/0:192.168.20.2 vlan20 sw1 R3(config)#no ip routing R3(config)#int f0/0 R3(config-

CCNA网络工程师学习进程(5)路由器和交换机的登录安全配置和vlan划分

    本节详细介绍路由器和交换机的登录安全配置以及VLAN划分的原理.     (1)登录安全配置: 路由器登录有两种验证方式:有本地验证方式和远程验证方式.本地登录验证方式可以配置用户名和密码也可以只配置密码:远程登录只需配置密码. 实验拓扑图:(配置好IP地址)     1)配置本地登录验证: 1.1在路由器上分别配置上述代码: 本地仅密码验证: en conf t line console 0 password sjm login 本地用户名及密码验证: en conf t line c

交换机的原理及其配置(二)

六,交换机的配置 (1)交换机的配置方式 a)使用Console端口配置 使用控制端口Console配置交换机:Console是一个用来连接配置终端的异步串行口,接口标准为RJ-45.是交换机 刚出厂时,第一次对其进行配置所用的方法.使用Console端口配置交换机时,需要准备一台已经安装了超级终端软 件的计算机作为配置终端,同时还需要一条由厂家提供的RJ-45到9针或25针异步串行口接口的信号电缆.使用超级终 端软件对异步串行口进行参数配置:传输速率9600,数据位8位,停止位1位. 具体的步

Vmware esx/esxi Vlan三种配置模式(VST、EST和VGT)

在Vmwareesx/esxi中使用虚拟Lan(Vlan)时,一般是指Vlan Trunk的使用,使用的Vlan配置还有其它三种类型:Virtual Switch Tagging(虚拟交换机标记,缩写VST).External SwitchTagging(外部交换机标记,缩写EST)和Virtual Guest Tagging(虚拟guest标记,简称VGT). 那我们如今就来介绍下着三种类型的差别及用途. Virtual Switch Tagging(VST) VST採用802.1q Vlan

交换机VLAN与Trunk配置

交换机VLAN与Trunk配置 1 首先配置交换机SW1先创建vlan5与10,把与PC1相连的1端口配置为access模式,并把端口加入到vlan5把与PC2相连的2端口配置为access模式,并把端口加入到vlan10把与SW2相连的3端口配置为trunk模式,并允许vlan5,vlan10通过 2 配置交换机SW2先创建vlan5与10,把与PC3相连的1端口配置为access模式,并把端口加入到vlan5把与PC4相连的3端口配置为access模式,并把端口加入到vlan10把与SW1相

华为交换机VLAN与Trunk配置

首先,使用ensp软件搭建好实验环境,并提取途中重要信息.图中PC19和PC21在同一个vlan5,PC20和PC22在同一个vlan10 解题思路(1) 首先我们需要确定我们需要用到的端口模式:Access介入模式 pc-交换机 Trunk中继链路模式: 交换机-交换机(2) 其次在两个交换机上各创建vlan5.vlan10的端口,并把pc19与pc21的端口设置为access模式并加入vlan5,把pc20与pc22的端口设置为access模式并加入vlan10,把两个交换机相连接的端口设置

Cisco PT模拟实验(4) 交换机的VLAN划分与配置

Cisco PT模拟实验(4)  交换机的VLAN划分与配置 实验目的: 掌握虚拟LAN(VLAN)的基本配置: 掌握交换机Port Vlan和Tag Vlan的配置方法: 掌握VLAN中继(Vlan Trunk)及其协议(VTP)的配置方法. 实验背景:公司财务部.销售部的PC均放置在两个办公室内,并通过室内交换机互联实现通信:但为了数据安全起见,两个部门之间需要进行通信隔离,现要在交换机上做适当配置来实现这一目标. 技术原理: VLAN技术:指在一个物理上相连网段从逻辑上划分成若干个虚拟局域