>enable (en)
#config t <script language="JavaScript1.1" src="http://ad.ccw.com.cn/adshow.asp?positionID=29&js=1&innerJs=1" type="text/javascript"></script>
Enter configuration commands,one per line.End with CNTL/Z
(config)#
为了安全和方便起见,我们给这个交换机起个名字,并且设置登陆密码。
(config)#hostname 1900Switch
1900Switch(config)# enable password level 15 goodwork
1900Switch(config)#
注意:密码必须是4-8位的字符。交换机密码的设置和路由器稍微不同,交换机用 level 级别的大小来决定密码的权限。Level 1 是进入命令行界面的密码,也就是说,设置了 level 1 的密码后,你下次连上交换机,并输入 K 后,就会让你输入密码,这个密码就是 level 1 设置的密码。而 level 15 是你输入了enable命令后让你输入的特权模式密码。路由器里面是使用 enable password 和 enable screet做此区分的。
好拉,我们已经设置好了名字和密码这样就足够安全了,让我们设置VLAN。VLAN的设置分以下2步:
1. 设置VLAN名称
2. 应用到端口
我们先设置VLAN的名称。使用 vlan vlan号 name vlan名称。 在特权配置模式下进行配置:
1900Switch (config)#vlan 2 name accounting
1900Switch (config)#vlan 3 name marketing
我们新配置了2个VLAN,为什么VLAN号从2开始呢?这是因为默认情况下,所有的端口否放在VLAN 1上,所以要从2开始配置。1900系列的交换机最多可以配置1024个VLAN,但是,只能有64个同时工作,当然了,这是理论上的,我们应该根据自己网络的实际需要来规划VLAN的号码。配置好了VLAN名称后我们要进入每一个端口来设置VLAN。在交换机中,要进入某个端口比如说第4个端口,要用 interface Ethernet 0/4,好的,结合上面给出的图我们让端口2、3、4和5属于VLAN2 ,端口17---22属于VLAN3 。命令是 vlan-membership static/ dynamic VLAN号 。 静态的或者动态的两者必须选择一个,后面是刚才配置的VLAN号。好的,我们看结果:
1900Switch(config)#interface ethernet 0/2 (进入第二个端口)有的int fa0/2也可以进入2端口
1900Switch(config-if)#vlan-membership static 2 (把该端口划归Vlan2)switchport access vlan XLS
1900Switch(config-if)#int e0/3
1900Switch(config-if)#vlan-membership static 2
1900Switch(config-if)#int e0/4
1900Switch(config-if)#vlan-membership static 2
1900Switch(config-if)#int e0/5
1900Switch(config-if)#vlan-membership static 2
1900Switch(config-if)#int e0/17
1900Switch(config-if)#vlan-membership static 3
。。。。。。
1900Switch(config-if)#int e0/22
1900Switch(config-if)#vlan-membership static 3
1900Switch(config-if)#
(设好后是两台交换机的话进入互联的端口比如24口连int fa0/24 switchport mode trunk)把fa0/24的模式设置为trunk
要实验跨交换机之间的VLAN通信,就必须先定义管道(trunk)。
管道(trunk)是交换机之间传递信息的一种链路。被划为Trunk的端口,从属于交换机上的每一个Vlan。
好的,我们已经把VLAN都定义到了交换机的端口上了。这儿,我们只是配置的静态的,关于动态的,我们在后面会有提及的。到现在为止,我们已经把交换机的VLAN配置好了,怎么样,没有你想象的那么复杂吧:)。为了验证我们的配置,我们在特权模式使用 show vlan命令。输出如下:
1900Switch(config)#show vlan
VLAN Name Status Ports
1 default Enabled 1,6-16,22-24,AUI,A,B
2 acconting Enabled 2-5
3 marketing Enabled 17-22
1002 fdd <script language="JavaScript1.1" src="http://ad.ccw.com.cn/adshow.asp?positionID=29&js=1&innerJs=1" type="text/javascript"></script>i-default Suspended
1003 token-ring-defau Suspended
1004 fddinet-default Suspended
1005 trnet-default Suspended
这是一个24口的交换机,并且带有AUI和两个100兆端口(A、B),可以看出来,我们的设置已经正常工作了,什么,还要不要保存running configure?当然不用了,交换机是即时自动保存的,所以不用我们使用命令来保存设置了。当然了,你也可以使用 show vlan vlan号 的命令来查看某个VLAN,比如show vlan 2 , show vlan 3. 还可以使用show vlan-membership ,改命令主要是显示交换机上的每一个端口静态或动态的属于哪个VLAN。
以上是给交换机配置静态VLAN的过程,下面我们看看动态的VLAN。动态的V L A N 形成很简单,由端口自己决定它属于哪个V L A N 时,就形成了动态的V L A N 。不过,这并不意味着就一层不变了,它只是一个简单的映射,这个映射取决于网络管理员创建的数据库。分配给动态V L A N 的端口被激活后,交换机就缓存初始帧的源M A C 地址,随后,交换机便向一个称为VMPS (V L A N 管理策略服务器)的外部服务器发出请求,V M P S 中包含一个文本文件,文件中存有进行V L A N 映射的M A C 地址。交换机对这个文件进行下载,然后对文件中的M A C 地址进行校验。如果在文件列表中找到M A C 地址,交换机就将端口分配给列表中的V L A N 。如果列表中没有M A C 地址,交换机就将端口分配给默认的V L A N (假设已经定义默认了V L A N )。如果在列表中没有M A C 地址,而且也没有定义默认的V L A N ,端口不会被激活。这是维护网络安全一种非常好的的方法。从表面上看,动态V L A N 的优势很大,但它也有致命的缺点,即创建数据库是一项非常艰苦而且非常繁琐的工作。如果网络上有数千个工作站,则有大量的输入工作要做。即使有人能胜任这项工作,也还会出现与动态的V L A N 有关的很多问题。另外,保持数据库为最新也是要随时进行的非常费时的工作。所以不经常用到它,这里我们就不做详细的讲解,可以参考相关的CISCO的文档资料。
这么样,没有你想象的那么复杂吧。我们已经把VLAN配置好了,那么VLAN的另一部分不容忽视的工作,就是前期的对网络的规划。就是说,哪些机器在一个VLAN中,各自的IP地址、子网掩码如何分配,以及VLAN之间互相通讯的问题。只有规划计划好了,才能够在配置和以后的使用维护过程中轻松省事。
sw1924_b<config>#enable password level 15 cisco15----------设置等级密码(15最高)
sw1924_b<config>#ip address 192.168.14.1 255.255.255.0-----设置交换机的管理IP地址
sw1924_b<config>#ip default-gateway 192.168.198.2----------设置交换机的网关地址
sw1924_b<config>#ip domain-name pctc.com.cn----------------设置交换机所连域的域名
sw1924_b<config>#ip name-server 218.87.18.230--------------设置交换机所连域的域名服务器IP
sw1924_b#show ip-------------------------------------------查看上述设置环境
sw1924_b#show version--------------------------------------查看交换机的版本等信息
sw1924_b#show running-config-------------------------------查看交换机的当前运行配置等全部信息
sw1924_b#show int e0/1-------------------------------------查看交换机的第1个端口信息