一、交换机五种模式<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 
Swith>                                    (用户模式)

Swith#                                     (特权模式)

Swith(config)#                           (全局配置模式)

Swith(config-if)#                            (接口模式)

Swith(config-line)#                        (线模式)

 
二、交换机模式切换

Swith>enable                              //切换到特权

Swith#config t                             //切换到全局配置模式

Swith(config)# interface f0/1                 //进入接口f0/0

Swith(config)# interface vlan 1               //进入VLAN 1中

Swith(config-if)#ip address 192.168.1.1 255.255.255.0 //对VLAN1设置IP地址和子网掩码

Swith(config-if)#no shutdown                 //激活VLAN1

 
三、设置交换机的密码
1、用户到特权的密码

Swith(config)#enable password 123  (优先级低)

Swith(config)#enable secret 456     (优先级高) //如果两个都设置则456生效

2、控制台console密码设置

Swith(config)# line con 0

Swith(config-line)#login

Swith(config-line)#password console123   //设置console密码为telnet123

3、启用telnet密码

Swith(config)#line vty 0 15   //最多有0~15人可以telnet访问swith,合计16人

Swith(config-line)#login

Swith(config-line)#password telnet123 //设置telnet密码为telnet123
注:要想真正生效telnet还要设置特权密码

hostname BENETSW01
Swith(config)#hostname BENETSW01          //使用hostname命名交换机的名字

 
四、show命令集
Swith#show version//显示IOS版本信息

Swith#show int vlan 1 brief//简单的显示VLAN1的信息

Swith#show running-config//显示正在运行的配置文件

Swith#show startup-config//显示己经保存的配置文件

Swith#show mac-address-table//显示MAC地址表

Swith#show mac-address-table//显示MAC地址表更新的间隔,默认为5分钟

Swith#show neighbor detail//显示邻居详细信息

Swith#show traffic//显示CDP流量

Swith#show

 
五、设置交换机的网关和DNS名称服务器的IP地址

Swith(config)# ip default-gateway 192.168.10.8//交换机的网关设置为192.168.10.8

Swith(config)#ip domain -name server 202.106.0.20 //设置DNS名称服务器地址

Swith(config)# no ip domain-lookup   //交换机名称服务器的域名查询

 
六、创建、删除、查看VLAN
Switch#vlan database       //进入vlan数据库配置模式

Switch(vlan)#vlan 2        //创建VLAN2命名为vlan0002,也可以使用vlan2 name sales

VLAN 2 added:

Name: VLAN0002

Switch(vlan)#exit                 //退出时应用生效

Swith(vlan)#no vlan 2               //删除vlan2

Switch(config)# interface f0/1

Switch(config-if)# switchport access vlan 2      //将端口加入vlan 2中

Switch(config-if)# no switchport access vlan 2      //将端口从vlan2中删除

Switch(config)# interface range f0/1 – 10            // 进行F0/1到10端口范围

Switch(config-if-range)# switchport access vlan 2  //将f0/1到f0/10之间的所有端口加入vlan 2

Switch# show vlan brief        //查看所有VLAN的摘要信息

Switch# show vlan id vlan-id        //查看指定VLAN的信息

 
七、开启并查看Trunk端口
Swith(config)#interface f0/24

Swith(config-if)#swith mode trunk //将f0/24端口设置为trunk

Switch#show interfacef0/24   switchport //查看f0/24的接口状态

 
八、从Trunk中添加、删除Vlan
Switch (config-if )# switchport trunk allowed vlan remove 3   //从trunk端口删除v lan3通过

Switch (config-if)# switchport trunk allowed vlan add 3      //从trunk端口添加vlan3通过

Switch # show interface interface-id switchport           //检查中继端口允许VLAN的列表

 
九、单臂路由配置

Router(config)# interface f0/0.1

Router(config-subif)# encapsolution dot1q 1 //子接口封装dot1q 针对的是VLAN1

Router(config-subif)# ip address  192.168.1.1 255.255.255.0 //设置VLAN的网关地址

Router(config)# interface f0/0.2

Router(config-subif)# encapsolution dot1q 2//子接口封装dot1q针对的是vlan2

Router(config-subif)# ip address192.168.2.1 255.255.255.0//设置vlan2的网关的地址