青蛙不是癞蛤蟆

CCNA Chapter 8

Chapter8 Virtual LANs(VLANs)
VLAN Basics
如何在一个交换机中分割广播域,很简单的方法就是划分vlan。Vlan是对物理端口进行的逻辑分组,他将产生一个更小的广播域,从而提高性能,默认配置vlan间是无法通信的,这对提高网络安全很有好处。
VLAN 的一些特点:
1.网络的增加,移动和改变,只需要在适当的VLAN 中配置合适的端口
2.安全,因为不同VLAN 的用户不能互相通信,除非依靠router 来做VLAN 间的通信
3.因为VLAN 可以被认为是按功能划分的逻辑分组,所以VLAN 和物理位置,地理位置无关
4.VLAN 增加安全性
5.VLAN 增加广播域的数量,而减小广播域的大小

实例:
2004年  29th ACM/ICPC Asia Region Shanghai Contest,为了杜绝比赛选手间的任何通讯,采用了一个端口划分为一个vlan的方案。这样所有的选手机只能和服务器通信,而不能和其他选手机间通信
Broadcast Control
任何一种协议都回产生boardcast,但产生的频度由如下3条决定
1.    协议类型
2.    运行在网络上的应用程序
3.    如何使用这些服务
Security
安全性是VLAN 的1 大特点,不同VLAN 的用户不能互相通信,除非依靠router 来做VLAN间的通信
Flexibility and Scalability
VLAN 的灵活性和可扩展性:
1. 可以不管物理位置如何,把适当的端口分配到适当的 VLAN 中就可以了
2. 当VLAN 增加的太大以后,你可以划分更多的VLAN,来减少广播消耗掉更多带宽的影响,在VLAN 中的用户越少,被广播影响的就越少


如图所示:每个网络都用hub相连,但如果有新的机器加入,扩展性较差。如果采用vlan,如下图


这样,VLAN设置打破了物理端口上的束缚。获得了极高的灵活性
VLAN Memberships
手动由管理员分配端口划分的VLAN 叫静态VLAN(static VLAN);使用智能管理软件,动态划分VLAN 的叫动态VLAN(dynamic VLAN)
Static VLANs
静态VLAN:静态VLAN 安全性较高,手动划分端口给VLAN,和设备的物理位置没什么关系.而且,每个VLAN 中的主机必须拥有正确的IP 地址信息,如VLAN2 配置为172.16.20.0/24
Dynamic VLANs
动态VLAN:使用智能管理软件,可以基于MAC 地址,协议,甚至应用程序来动态创建VLAN.Cisco 设备管理员可以使用VLAN 管理策略服务器(VLAN Management Policy Server,VMPS)的服务来建立个MAC 地址数据库,来根据这个动态创建VLAN,VMPS 数据库把MAC 地址映射VLAN 上

Identifying VLANs
当帧在网络中被交换,switches 根据类型对其跟踪,加上根据硬件地址来判断如何对它们进行操作.有1 点要记住的是:在不同类型的连接中,帧被处理的方式也不一样
交换环境中的2 种连接类型:
1.   access links:指的是只属于一个VLAN,且仅向该VLAN 转发数据帧的端口,也叫做native VLAN.switches 把帧发送到access-link 设备之前,移去任何的VLAN 信息.而且access-link 设备不能与VLAN 外通信,除非数据包被路由
2.   trunk links:指的是能够转发多个不同VLAN 的通信的端口.trunk link 必须使用100Mbps 以上的端口来进行点对点连接,1 次最多可以携带1005 个VLAN 信息.trunk link 使你的单独的1个端口同时成为数个VLAN 的端口,这样可以不需要层3 设备.当你在switches 之间使用了trunk link,多个VLAN 的信息将从这个连接上通过;如果在你switches 之间没有使用trunk link而使用一般的连接,那么只有VLAN1 的信息通过这个连接被互相传递.VLAN1 默认作为管理VLAN


Frame Tagging
帧的鉴别方法.当帧到达每个switch,首先先检查VLAN ID,然后决定如何对帧进行处理.当帧到达和VLAN ID 所匹配的access link 的时候,switch 移去VLAN 标识符

VLAN Identification Method
VLAN 标识符:在交换机的trunk link 上,可以通过对数据帧附加VLAN 信息,构建跨越多台交换机的VLAN.附加VLAN 信息的方法,最具有代表性的有:
1.Inter-Switch Link(ISL):属于Cisco 私有,只能在快速和千兆以太网连接中使用,ISL 路由可以使用在switch 的断端口,router 的接口和服务器接口卡等,如果不想打破80/20规则,这是一个很不错的选择。

2.IEEE 802.1Q:由IEEE 创建,所以在Cisco 和非Cisco 设备之间,就不能使用ISL必须使用802.1Q.
802.1Q 所附加的VLAN 识别信息,位于数据帧中的源MAC地址与类型字段之间.基于IEEE802.1Q 附加的VLAN 信息,就像在传递物品时附加的标签当然ISL 和802.1Q 的主要目的是提供VLAN 间通信
Inter-Switch Link(ISL) 运作在第2层,它是1 种外部标签处理过程,所以原始的数据帧不被改变,ISL 在数据帧头部加上26 字节长的ISL 头部信息,在数据帧尾部加上4 字节的FCS 字段进行CRC 运算,所以只有支持ISL 的设备才能对它进行读取,最大程度1522 字节.当帧被传送到access link时,ISL 封装信息将被移去。

使用trunk link 在多个VLAN 中行走,比使用router 连接的好处是:减少延时间
VLAN Trunking Protocol(VTP)
VTP 也是Cisco 创建的,但是现在已经不为Cisco 所私有.VTP 的主要目的是在1 个交换性的环境中管理所有配置好的VLAN 使所有的VLAN 保持一致性VTP 允许增加,删除和重命名VLAN,然后这些修改后的信息传播到整个VTP 域里的所有switches 上
VTP 的一些优点:
1.保持VLAN 信息的连续性
2.精确跟踪和监视VLAN
3.动态报告增加了的VLAN 信息给VTP 域中所有switch
4.可以使用即插即用(plug-and-play)的方法增加VLAN
5.可以在混合型网络中进行trunk link,比如以太网到ATM LANE,FDDI 等
在你使用VTP 管理VLAN 之前,必须先创建个VTP 服务器(VTP server),所有要共享VLAN信息的服务器必须使用相同的域名.而且,假如你把某个switch 和其他的switch 配置在1 个VTP 域里,这个switch 就只能和这个VTP 域里的switch 共享VLAN 信息.其实,如果你只有1个VLAN,就不需要使用VTP 了.VTP 信息通过trunk 端口进行发送和接收.可以给VTP 配置密码,但是要记住的是,所有的switch 必须配置相同的密码

switch 通告VTP 管理域信息,加上版本号和已知VLAN 配置参数信息.还有种叫做透明VTP模式(transparent VTP mode),在这种模式里,你可以给switch 配置成通过trunk 端口转发VTP信息,但是不接受VTP 更新信息来更新它自己的VTP 数据库switch 通过VTP 通告检测到增加的VLAN,然后把新增加的VLAN 和已有的联结在一起共享信息.新的更新信息在之前的版本号上加1
VTP Modes of Operation
在VTP 域里操作的3 种模式:
1.服务器模式(server mode):所有Catalyst switches 的默认设置,1 个VTP 域里必须至少要有1个服务器用来传播VLAN 信息,对VTP 信息的改变必须在服务器模式下操作.配置保存在NVRAM 里
2.客户机模式(client mode):在这种模式下,switches 从VTP 服务器接受信息,而且它们也发送和接收更新,但是它们不能做任何改变.在VTP 服务器通知客户switches 说增加了新的VLAN之前,你不能在客户switch 的端口上增加新的VLAN.配置不保存在NVRAM 里
3.透明模式(transparent mode):该模式下的switch 不能增加和删除VLAN,因为它们保持的有自己的数据库,不和其他的共享.配置保存在NVRAM 里
VTP Pruning
VTP pruning:减少广播,组播,单播,保留带宽.VTP pruning 只在trunk link 上发送广播.默认情况,VTP pruning 在所有的switches 上是没有启用的.当你在VTP 服务器上启用了VTP pruning,整个VTP 域就启用了VTP pruning,默认只能在VLAN2 到VLAN1005,VLAN1 是管理VLAN
Routing between VLANs
可以使用支持ISL 路由的router 来连接VLAN,支持ISL 路由的最低型号是2600 系列,1600,1700 和2500 系列都不支持.如右图,就是router 和每个VLAN 之间的关联,每个router的接口都插入1 个access link,这个同时也说明了router 的每个接口的IP 地址都是每个VLAN的默认网关:
假如你有太多的VLAN,数量超过了router 接口数量,明显上面的方法就不适用了.你可以使用Cisco 的3 层switch Cisco3550,或者使用router 的快速以太网接口来做ISL 或者802.1Q 的trunk link,这样的方法叫做单臂路由(router on a stick).如右图:


Configuring VLANs

Create a VLAN
1900 下,使用vlan [vlan#] name [name] [vlan#]命令, 如下:
>en
#config t
Enter configuration commands, one per line. End with CNTL/Z
(config)#hostname 1900
1900(config)#vlan 2 name sales
1900(config)#vlan 3 name marketing
1900(config)#vlan 4 name mis
1900(config)#exit
验证,使用show vlan 命令,记住在你没给VLAN 分配端口之前,之前做的VLAN 是不会起作用的.而且所有的端口默认是处在VLAN1 的,VLAN1 是管理VLAN.如下:
1900#sh vlan
VLAN Name Status Ports
--------------------------------------
1 default Enabled 1-12, AUI, A, B
2 sales Enabled
3 marketing Enabled
4 mis Enabled
1002 fddi-default Suspended
1003 token-ring-defau Suspended
1004 fddinet-default Suspended
1005 trnet-default Suspended
--------------------------------------
[output cut]
2950创建Vlan有些不同
Switch>
Switch>en
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#
Switch(config-vlan)#vlan 3
Switch(config-vlan)#name Sales
Switch(config-vlan)#vlan 4
Switch(config-vlan)#name Finance
Switch(config-vlan)#^Z
Switch#
同样也可以用这种方式在2950种创建vlan
2950#vlan database
2950(vlan)#vlan 2 name Marketing
VLAN 2 modified:
Name: Marketing
2950(vlan)#vlan 3 name Accounting
VLAN 3 added:
Name: Accounting
2950(vlan)#apply
APPLY complete
2950(vlan)#^C
2950#
使用show vlan 或者show vlan brief 命令验证下:
Switch#sh vlan brief
VLAN Name Status Ports
---- --------------------- --------- -------------------------------
1        default            active       Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12
2       VLAN0002            active
3       Sales               active
4       Finance             active
1002    fddi-default        act/unsup
1003    token-ring-default  act/unsup
1004    fddinet-default     act/unsup
1005    trnet-default       act/unsup
Switch#

Assigning Switch Ports to VLANs
创建了VLAN,接下来要做的就是给VLAN 分配端口.1900 下,使用vlan-membership 命令1 次只能分配1 个,可以static 或dynamic 作为参数,如下:

1900(config)#int e0/2
1900(config-if)#vlan-membership static 2
1900(config)#int e0/4
1900(config-if)#vlan-membership static 3
1900(config)#int e0/5
1900(config-if)#vlan-membership static 4
1900(config-if)#exit
1900(config)#exit
1900#

验证,如下:
1900#sh vlan
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default Enable 1-12, AUI, A, B
2 sales Enable 2
3 marketing Enable 4
(略)
2950 下的配置,使用switchport access vlan [vlan#]命令,如下:
2950(config-if)#int f0/2
2950(config-if)#switchport access vlan 2
2950(config-if)#int f0/3
2950(config-if)#switchport access vlan 3
2950(config-if)#int f0/4
2950(config-if)#switchport access vlan 4
2950(config-if)#exit
2950(config)#exit
2950#
验证配置信息,如下:
2950#sh vlan brief
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1 Fa0/5...Fa0/12
2 Marketing active Fa0/2
3 Accounting active Fa0/3
(略)
Configuring Trunk Ports
1900 只使用动态ISL(DISL)封装方式,在快速以太网配置trunk,在接口配置模式下使用trunk[参数]的命令,如下,将26 接口设置为trunk 端口:
1900(config)#int f0/26
1900(config-if)#trunk ?
auto Set DISL state to AUTO
desirable Set DISL state to DESIRABLE
nonegotiate Set DISL state to NONEGOTIATE
off Set DISL state to OFF
on Set DISL state to ON
1900(config-if)#trunk on

设置参数为on 即接口将作为永久ISL 的trunk 端口,可以和和相连的设备协商,并且把连接转换成trunk link

2950 下在接口配置模式,使用switchport 命令,如下:
2950(config)#int f0/12
2950(config-if)#switchport mode trunk
2950(config-if)#^Z
2950#

验证配置信息:
2950#sh run
(略)
!
interface FastEthernet0/12
switchport mode trunk
no ip address
!
(略)

Cisco Catalyst 3550交换机上配置中继模式
和2950类似,不过3550可以运行ISL,而2950只能运行dot 1Q.
所以3550多了一条命令switch port trunk encapsulation
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/12
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk encapsulation ?
dot1q   Interface uses only 802.1q trunking encapsulation when trunking
isl     Interface uses only ISL trunking encapsulation when trunking
negotiate Device will negotiate trunking encapsulation with peer on
interface
Configuring Inter-VLAN Routing
使VLAN 间互相通信,就必须使用router 或者3 层switch 来连接.要在router 的快速以太网接口支持ISL 和802.1Q,要把接口划分成许多逻辑接口(非物理),1 个接口对应1 个VLAN.这些接口就叫子接口(subinterfaces).还有要必须知道的是,默认你不可能在1900 和2950 之间做trunk 连接,因为1900 只支持ISL 路由而2950 只支持802.1Q 路由,2种相互不兼容,<2950不支持自家的ISL有些奇怪>
给连接1900 的trunk 端口配置,使用encapsulation isl [vlan#]命令,如下:
2600Router(config)#int f0/0.1
2600Router(config-subif)#encapsulation isl [vlan#]
给连接2950 的这样配置,如下:
2600Router(config)#int f0/0.1
2600Router(config-subif)#encapsulation dot1q [vlan#]
Notice:将路由器的端口配置为Trunk,带宽必须大于100Mbps

Host  IP            GateWay   mask
A     192.168.1.66  1.65       255.192
B     192.168.1.67  1.65       255.192
C     192.168.1.130 1.129      255.224


如右的网络结构图的配置:
2950#config t
2950(config)#int f0/1
2950(config-if)#switchport mode trunk
2950(config-if)#int f0/2
2950(config-if)#switchport access vlan 1
2950(config-if)#int f0/3
2950(config-if)#switchport access vlan 1
2950(config-if)#int f0/4
2950(config-if)#switchport access vlan 3
2950(config-if)#int f0/5
2950(config-if)#switchport access vlan 3
2950(config-if)#int f0/6
2950(config-if)#switchport access vlan 2
VLAN 1: 192.168.10.16/28
VLAN 2: 192.168.10.32/28
VLAN 3: 192.168.10.48/28
Router#config t
Router(config)#int f0/0
Router(config-if)#no ip address
Router(config-if)#no shutdown
Router(config-if)#int f0/0.1
Router(config-subif)#encapsulation dot1q 1
Router(config-subif)#ip address 192.168.10.17 255.255.255.240
Router(config-subif)#int f0/0.2
Router(config-subif)#encapsulation dot1q 2
Router(config-subif)#ip address 192.168.10.33 255.255.255.240
Router(config-subif)#int f0/0.3
Router(config-subif)#encapsulation dot1q 3
Router(config-subif)#ip address 192.168.10.49 255.255.255.240
另一例子网和VLAN划分
            Vlan 1 和 vlan 2 各有85 和115台host,故可以采用128的地址块,
即子网掩码/25的划分。
Here is the switch configuration:
2950#config t
2950(config)#int f0/1
2950(config-if)#switchport mode trunk
2950(config-if)#int f0/2
2950(config-if)#switchport access vlan 1
2950(config-if)#int f0/3
2950(config-if)#switchport access vlan 2
Here is the router configuration:
Router#config t
Router(config)#int f0/0
Router(config-if)#no ip address
Router(config-if)#no shutdown
Router(config-if)#int f0/0.1
Router(config-subif)#encapsulation dot1q 1
Router(config-subif)#ip address 172.16.10.1 255.255.255.128
Router(config-subif)#int f0/0.2
Router(config-subif)#encapsulation dot1q 2
Router(config-subif)#ip address 172.16.10.254 255.255.255.128
Configuring VTP
默认下,1900 和2950 都被配置成VTP 服务器模式,配置VTP,先配置VTP 域名,还有密码,是否pruning 等.
1900 下,在全局配置模式下使用vtp 命令,如下:
1900(config)#vtp ?
client VTP client
domain       Set VTP domain name
password     Set VTP password
pruning      VTP pruning
server       VTP server
transparent  VTP transparent
trap         VTP trap
1900(config)#vtp server
1900(config)#vtp domain nichole
1900(config)#vtp password kaka
在特权模式下使用show vtp 命令验证,如下:
1900#sh vtp
VTP version: 1
Configuration revision: 0
Maximum VLANs supported locally: 1005
Number of existing VLANs: 5
VTP domain name      : nichole
VTP password         : kaka
VTP operating mode   : Server
VTP pruning mode     : Disabled
VTP traps generation : Enabled
Configuration last modified by: 0.0.0.0 at 00-00-0000 00:00:00
1900#
Vtp mode
Switch(config)#vtp mode ?
client Set the device to client mode.
server Set the device to server mode.
transparent Set the device to transparent mode.
Vtp mode server
Switch(config)#vtp mode server
Device mode already VTP SERVER.
domain
Switch(config)#vtp domain ?
WORD The ascii name for the VTP administrative domain.
Switch(config)#vtp domain routersim
Changing VTP domain name from NULL to routersim
Switch(config)#
Show vtp
SwitchA#sh vtp ?
counters VTP statistics
status VTP domain status
SwitchA#sh vtp status
VTP Version                         : 2
Configuration Revision              : 1
Maximum VLANs supported locally     : 64
Number of existing VLANs            : 7
VTP Operating Mode                  : Server
VTP Domain Name                     : routersim
VTP Pruning Mode                    : Disabled
VTP V2 Mode                         : Disabled
VTP Traps Generation                : Disabled
MD5 digest : 0x4C 0x60 0xA6 0x5D 0xD7 0x41 0x8C 0x37
Configuration last modified by 172.16.10.1 at 3-1-94 06:40:09
Local updater ID is 172.16.10.1 on interface Vl1 (lowest numbered VLAN interface found)
Troubleshooting VTP
首先查看如下2台交换机的信息
SwitchA#sh vtp status
VTP Version                         : 2
Configuration Revision              : 0
Maximum VLANs supported locally     : 64
Number of existing VLANs            : 7
VTP Operating Mode                  : Server
VTP Domain Name                     : RouterSim
VTP Pruning Mode                    : Disabled
VTP V2 Mode                         : Disabled
VTP Traps Generation                : Disabled
SwitchB#sh vtp status
VTP Version                         : 2
Configuration Revision              : 1
Maximum VLANs supported locally     : 64
Number of existing VLANs            : 7
VTP Operating Mode                  : Server
VTP Domain Name                     : GlobalNet
VTP Pruning Mode                    : Disabled
VTP V2 Mode                         : Disabled
VTP Traps Generation                : Disabled
首先2台交换机都工作在VTP服务器模式,当然这不是最重要的问题,关键是2台交换机的VTP 的Domain Name不同,导致了不能同步。其次就是Client模式下,是不能创建,删除,添加和修改VLAN的。必须要变更到server模式才行


Configuring Switching in Our Sample Internetwork
如右图所示网络
2台Catalyst2950       2950B 2950C 
1台Catalyst1900       1900
3台2600路由           Lab_A Lab_B Lab_C
要求:对管理VLAN(VLAN 1)采用172.16.10.0/24
连接到B的fa0/0上。下面将再创建2个VLAN,
VLAN 2    172.16.20.0/24 
VLAN 3    172.16.30.0/24


先配置2950C,如下
2950C(config)#enable secret nichole
2950C(config)#line con 0
2950C(config-line)#login
2950C(config-line)#password kaka
2950C(config-line)#line vty 0 15
2950C(config-line)#login
2950C(config-line)#password kaka
2950C(config-line)#banner motd #
2950C
#
2950C(config-line)#exit
2950C(config)#int vlan1
2950C(config-if)#ip address 172.16.10.2 255.255.255.0
2950C(config-if)#no shut
2950C(config-if)#exit
2950C(config)#up default-gateway 172.16.10.1
2950C(config)#^Z
2950C#copy run start
Destination filename [startup-config]? [Enter]
Building configuration...
[OK]
2950C#

配置2950B,如下:
2950B(config)#enable secret nichole
2950B(config)#line con 0
2950B(config-line)#login
2950B(config-line)#password kaka
2950B(config-line)#line vty 0 15
2950B(config-line)#login
2950B(config-line)#password kaka
2950B(config-line)#banner motd #
2950B
#
2950B(config-line)#exit
2950B(config)#int vlan1
2950B(config-if)#ip address 172.16.10.3 255.255.255.0
2950B(config-if)#no shut
2950B(config-if)#exit
2950B(config)#up default-gateway 172.16.10.1
2950B(config)#^Z
2950B#copy run start
Destination filename [startup-config]? [Enter]
Building configuration...
[OK]
2950B#
2950B#ping 172.16.10.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.10.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/3/4 ms
2950B#
配置trunk,2950B 如下:
2950B(config)#int f0/1
2950B(config-if)#switchport mode trunk
2950B(config-if)#int f0/4
2950B(config-if)#switchport mode trunk
2950B(config-if)#int f0/5
2950B(confgi-if)#switchport mode trunk

配置trunk,2950C 如下:
2950C(config)#int f0/4
2950C(confgi-if)#switchport mode trunk
2950C(config-if)#int f0/5
2950C(config-if)#switchport mode trunk

验证trunk 信息,使用show interface trunk 命令.如下:
2950B#sh int trunk
Port Mode Encapsulation Status Native vlan
Fa0/1 on 802.1q trunking 1
Fa0/4 on 802.1q trunking 1
Fa0/5 on 802.1q trunking 1
[output cut]
之前我们已经对2950B 和2950C 做了基本配置和trunk 端口的配置,接下来应该设置VTP 和创建VLAN,并且进行验证.2950C 如下:
2950C(config)#vtp mode server
2950C(config)#vtp domain Cisco
2950C(config)#^Z
2950C#vlan database
2950C(vlan)#vlan 2 name sales
2950C(vlan)#vlan 3 name marketing
2950C(vlan)#apply
2950C(vlan)#^C
2950C#sh vlan brief
VLAN Name Status Ports
---- ----------------- --------- ------------------------------
1  default              active   Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/7, Fa0/8, Fa0/11, Fa0/12
2  Sales                active
3  Marketing            active
[output cut]
接下来分配端口,把Fa0/2 分配给VLAN2,Fa0/3 分配给VLAN3,默认所有的端口都处在VLAN1 下,配置如下:
2950C(config)#int fa0/2
2950C(config-if)#switchport access vlan2
2950C(config)#int fa0/3
2950C(config-if)#switchport access vlan3
验证信息,注意VLAN1 里的Ports 栏,如下:
2950C#sh vlan brief
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1 Fa0/5...Fa0/10
2 sales active Fa0/2
3 marketing active Fa0/3
配置2950B,把它设置成客户模式,2950B 从2950C 接收VLAN 信息,如下:
2950B(config)#vtp mode client
2950B(config)#vtp domain Cisco
2950B(config)#^Z
验证,注意2950B 已经从2950C 知道了VLAN 的信息,如下:
2950B#sh vlan brief
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1...Fa0/12
2 sales active
3 marketing active
但是仍然要给2950B 分配端口,如下:
2950B(config)#int fa0/2
2950B(config-if)#switchport access vlan2
2950B(config)#int fa0/3
2950B(config-if)#switchport access vlan3
验证信息,如下:
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1 Fa0/5...Fa0/12
2 sales active Fa0/2
3 marketing active Fa0/3
到现在,2950C 和2950B 的配置就算是完成了,经过验证,我们也没发现什么问题,接下来该配置什么呢?当然是配置VLAN 间的通信,根据上面的拓扑图,可以知道需要在RouterB 上进行配置,如下:
RouterB(config)#hostname Trunkrouter
Trunkrouter(config)#int f0/0
Trunkrouter(config-if)#no ip address
Trunkrouter(config-if)#no shut
创建子接口,并定义封装类型,如下:
Trunkrouter(config-if)#int f0/0.1
Trunkrouter(config-subif)#encapsulation dot1q 1
Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0
Trunkrouter(config-if)#int f0/0.2
Trunkrouter(config-subif)#encapsulation dot1q 2
Trunkrouter(config-subif)#ip address 172.16.20.1 255.255.255.0
Trunkrouter(config-if)#int f0/0.3
Trunkrouter(config-subif)#encapsulation dot1q 3
Trunkrouter(config-subif)#ip address 172.16.30.1 255.255.255.0
Trunkrouter(config-if)#exit
创建子接口,每个接口对应1 个VLAN.注意,如果你试图在第一个子接口分配IP 地址,将收到错误信息,除非你先定义了封装类型,如下:
Trunkrouter(config-if)#int f0/0.1
Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0
Configuring IP routing on a LAN subinterface is only allowed if that subinterface is already
configured as part of an IEEE 802.10, IEEE 802.1Q, or ISL VLAN.
验证配置信息,如下:
Trunkrouter#sh run
!
interface FastEthernet0/0
no ip address
no ip directed-broadcast
!
interface FastEthernet0/0.1
encapsulation dot1Q 1
ip address 172.16.10.1 255.255.255.0
no ip directed-broadcast
!
interface FastEthernet0/0.2
encapsulation dot1Q 2
ip address 172.16.20.1 255.255.255.0
no ip directed-broadcast
!
interface FastEthernet0/0.3
encapsulation dot1Q 3
ip address 172.16.30.1 255.255.255.0
no ip directed-broadcast

posted on 2006-08-17 09:34 学习资料库 阅读(1278) 评论(0)  编辑 收藏 引用 网摘 所属分类: Lan Switch


只有注册用户登录后才能发表评论。
网站导航: