一些vlan设置

http://hi.baidu.com/silenthj/blog/item/e11c78731ae83a168601b05d.html

 

1.分配交换机端口到 VLAN:

    Switch(config)#interface fa0/1
    Switch(config-if)#switchport access vlan N.o


2.检验 VLAN 配置:

      Switch#show vlan
或者:Switch#show interface vlan 1


3.为交换机上的中继端口配置中继和本征 VLAN::

    Switch(config)#interface f0/1
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#switchport trunk native vlan N.o

4.禁用 DNS 查找:

    Switch(config)#no ip domain-lookup      


5.将执行模式口令配置为 class:
  
    Switch(config)#enable secret class

6.为控制台连接配置口令 cisco:

   Switch(config)#line console 0
   Switch(config-line)#password cisco
   Switch(config-line)#login

7.为 vty 连接配置口令 cisco:
  
   Switch(config-line)#line vty 0 15
   Switch(config-line)#password cisco
   Switch(config-line)#login
   Switch(config-line)#exit


8.启用提供访问的用户端口:

   Switch(config)#interface f0/1
   Switch(config-if)#no shutdown


9.查看哪些端口已添加到 VLAN 10:

   Switch#show interface vlan 10
  
10.在每台交换机上配置管理 VLAN 56:
   
     S1(config)#vlan 56
     S1(config-vlan)#exit
     S1(config)#interface vlan 56
     %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan99, changed state to down
     S1(config-if)#ip address 172.17.99.11 255.255.255.0
     S1(config-if)#no shutdown
     
11. 检验 S1、S2 和 S3 是否能够通信:
  
   Switch>ping 192.168.1.1

12.查看当前的交换机配置: Switch#show running-config

   查看 NVRAM 当前的内容:Switch#show startup-config

   查看虚拟接口 VLAN1 的特征:Switch#show interface vlan1

   查看接口的 IP 属性:Switch#show ip interface vlan1

   查看交换机报告的下列版本信息: Switch#show version

   查看快速以太网接口的属性: Switch#show interface fastethernet 0/1

   查看交换机的VLAN 设置:Switch#show vlan

   查看闪存: Switch#dir flash或Switch#show flash

   查看检查启动配置文件: Switch#show startup-config

   将运行配置文件的内容保存到非易失性 RAM (NVRAM): Switch#copy running-config startup-config                                                   注:缩写copy run start

   为交换机指定名称:Switch(config)#hostname S1
   
   设置访问口令:S1(config)#line console 0
                          S1(config-line)#password cisco
                             S1(config-line)#login
                            S1(config-line)#line vty 0 15
                            S1(config-line)#password cisco
                 S1(config-line)#login
                 S1(config-line)#exit

    设置命令模式口令: S1(config)#enable secret class

    交换机上配置管理 VLAN 56:   S1(config)#vlan 56
                                S1(config-vlan)#exit
                                S1(config)#interface vlan 56
                                S1(config-if)#ip address 172.17.99.11 255.255.255.0
                                S1(config-if)#no shutdown

     将所有用户端口分配到 VLAN 99: S1(config)#interface range fa0/1 - 24
                                    S1(config-if-range)#switchport access vlan 99
                                    S1(config-if-range)#exit

     设置交换机的默认网关: S1(config)#ip default-gateway 172.17.99.1

     查看 VLAN 99 上的接口设置: S1#show interface vlan 99

     配置快速以太网接口的端口速度和双工设置: S1#configure terminal
                                              S1(config)#interface fastethernet 0/18
                                              S1(config-if)#speed 100
                                              S1(config-if)#duplex full
                                              S1(config-if)#end

     查看 MAC 地址: S1#show mac-address-table

     清除 MAC 地址表: S1#clear mac-address-table dynamic

     设置静态 MAC 地址: S1(config)#mac-address-table static 00e0.2917.1884 interface fastethernet 0/18 vlan 99

     删除静态 MAC 条目: S1(config)#no mac-address-table static 00e0.2917.1884 interface fastethernet 0/18 vlan 99

     配置端口安全性: S1(config)#interface fastethernet 0/18
                      S1(config-if)#switchport port-security ?
                      aging Port-security aging commands
                      mac-address Secure mac address
                      maximum Max secure addresses
                      violation Security violation mode
                     
                      S1(config-if)#switchport port-security

     在访问端口上配置端口安全: S1(config-if)#switchport mode access
                                S1(config-if)#switchport port-security
                                S1(config-if)#switchport port-security maximum 2
                                S1(config-if)#switchport port-security mac-address sticky
                                S1(config-if)#switchport port-security violation protect
                                S1(config-if)#exit

      查看端口安全设置: S1#show port-security

      激活端口: S1(config)#interface fastethernet 0/18
                S1(config-if)# no shutdown
                S1(config-if)#exit

      删除 VLAN 数据库信息文件: Switch#delete flash:vlan.dat
                                 Delete filename [vlan.dat]?[Enter]
                                 Delete flash:vlan.dat?[confirm] [Enter]

      从 NVRAM 删除交换机启动配置文件: Switch#erase startup-config

      重新启动软件: Switch(config)#reload

      Dynamic Mode:    Switch(config)#interface fa0/11
                                 Switch(config-if)#switchport mode access

switch mode详解:

cisco网络中,交换机在局域网中最终稳定状态的接口类型主要有四种:access/ trunk/ multi/ dot1q-tunnel。
1、access: 主要用来接入终端设备,如PC机、服务器、打印服务器等。

2、trunk: 主要用在连接其它交换机,以便在线路上承载多个vlan。

3、multi: 在一个线路中承载多个vlan,但不像trunk,它不对承载的数据打标签。主要用于接入支持多vlan的服务器或者一些网络分析设备。现在基本不使用此类接口,在cisco的网络设备中,也基本不支持此类接口了。

4、dot1q-tunnel: 用在Q-in-Q隧道配置中。

Cisco网络设备支持动态协商端口的工作状态,这为网络设备的实施提供了一定的方便(但不建议使用动态方式)。cisco动态协商协议从最初的DISL(Cisco私有协议)发展到DTP(公有协议)。根据动态协议的实现方式,Cisco网络设备接口主要分为下面几种模式:

1、switchport mode access: 强制接口成为access接口,并且可以与对方主动进行协商,诱使对方成为access模式。

2、switchport mode dynamic desirable: 主动与对协商成为Trunk接口的可能性,如果邻居接口模式为Trunk/desirable/auto之一,则接口将变成trunk接口工作。如果不能形成trunk模式,则工作在access模式。这种模式是现在交换机的默认模式。

3、switchport mode dynamic auto: 只有邻居交换机主动与自己协商时才会变成Trunk接口,所以它是一种被动模式,当邻居接口为Trunk/desirable之一时,才会成为Trunk。如果不能形成trunk模式,则工作在access模式。

4、switchport mode trunk: 强制接口成为Trunk接口,并且主动诱使对方成为Trunk模式,所以当邻居交换机接口为trunk/desirable/auto时会成为Trunk接口。

5、switchport nonegotiate: 严格的说,这不算是种接口模式,它的作用只是阻止交换机接口发出DTP数据包,它必须与switchport mode trunk或者switchport mode access一起使用。

6、switchport mode dot1q-tunnel: 配置交换机接口为隧道接口(非Trunk),以便与用户交换机的Trunk接口形成不对称链路。

转自:http://134dbc.blog.163.com/blog/static/59222141200992311239233/

你可能感兴趣的:(一些vlan设置)