当前位置:文档之家› 交换机配置命令

交换机配置命令

交换机配置命令 Prepared on 24 November 2020
配置命令
交换机之间用交叉线
1进入特权模式:Switch>enable
2配置模式 Switch#config
3配置主机名:Switch(config)#hostname S1
4.设置访问口令S1#configure terminal
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
5.将使能加密口令设置为 class。

S1(config)#enable secret class
S1(config)#配置默认网关
6.在虚拟接口vlan99设置交换机ip地址
S1(config)#interface vlan99
S1(config-if)#
S1(config-if)#no shutdown
S1(config-if)#exit
7.交换机 VLAN 分配端口
S1(config)#interface fa0/1
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 99
S1(config-if)#exit
8.给vlan命名
S1(config)#vlan 10
S1(config-vlan)#name Faculty/Staff
.本征vlan即分配端口连接s1 使用中继vlan S1中继vlan
S1(config)#interface FastEthernet 0/1
S1(config-if)#switchport mode trunk
S1(config-if)#switchport trunk native vlan 99
9..设置交换机默认网关
S1(config)#
S1(config)#exit
10..配置快速以太网接口的端口速率和双工设置。

S1#configure terminal
S1(config)#interface fastethernet 0/18
S1(config-if)#speed 100
S1(config-if)#duplex full
S1(config-if)#end
11.清除mac地址表S1#clear mac-address-table dynamic
12.设置静态 MAC 地址。

S1(config)#
13.在接入端口上配置端口安全性。

配置交换机端口 FastEthernet 0/18 仅接受两台设备,动态学习这些设备的MAC 地址,并在发生安全违规事件时关闭端口。

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 shutdown
S1(config-if)#exit
14.配置并测试 MOTD 标语。

配置当天消息 (MOTD),文本使用Authorized Access Only(仅限授权访问)。

标语文本区分大小写。

请勿在标语文本前后添加空格。

在标语文本前后使用定界符指示文本从何处开始,到何处结束。

下例中使用的定界符为&,但是您可以使用标语文本中未使用的任何字符。

配置完 MOTD 后,从交换机注销,然后再次登录,检查是否显示了上述标语。

S1(config)#banner motd &Authorized Access Only&
S1(config)#end [or exit]
S1#exit
15.首先必须启用端口安全性,方能在接口上使用其它端口安全性命令。

启用18号端口安全性
S1(config-if)#interface fa0/18
S1(config-if)#switchport port-security
Show
vlan 看默认vlan 配置
2.发出show running-config命令,检查当前的运行配置
3.发出show startup-config命令,检查当前 NVRAM 的内容
4.发出show interface vlan1命令,检查虚拟接口 VLAN1 的特征
5.现在使用show ip interface vlan1命令查看该接口的 IP 属性
6.使用show version命令显示 Cisco IOS 信息
7.使用show interface fastethernet 0/18命令检查 PC1 所用快速以太网接口
的默认属性。

8.在特权执行模式下使用show mac-address-table命令显示 MAC 地址
9.创建 VLAN 后,返回特权执行模式并发出show vlan brief命令,检查新
VLAN 是否创建成功。

其他命令
删除vlan数据库信息Switch#delete flash:
从NVRAM中删除交换机启动配置文件Switch#erase startup-config
在特权执行模式提示符下,输入reload命令开始这一过程。

Switch#reload
要把运行配置文件的内容保存到非易失性 RAM (NVRAM),请发出命令copy
running-config startup-config。

Switch#copy running-config startup-config
第四章
默认配置: show vtp status
将成为 VTP 服务器。

将 S1 设置为服务器模式。

S1(config)#vtp mode server
Device mode already VTP SERVER.
3. 将 S1 的 VTP 域名配置为 CCNA。

请记住,VTP 域名区分大小写。

S1(config)#vtp domain CCNA
Changing VTP domain name from NULL to CCNA
4. 将 S1 的 VTP 域口令配置为 cisco。

请记住,VTP 域口令区分大小写。

S1(config)#vtp password cisco
Setting device VLAN database password to cisco
S1(config)#
5.配置主辅银桥
S1 (config): spanning-tree vlan 1 root primary
S1(config): spanning-tree vlan 1 root secondary
6.配置桥的优先级
S1 (config):spanning-tree vlan 1 priority 4096
7.检验网桥优先级
Show spanning-tree
8.
使用封装配置子接口。

在 R1 上创建两个子接口:Fa0/ 和 Fa0/。

将这两个子接口分配到不同的VLAN。

要创建第一个子接口,请发出 interface fa0/ 命令进入 Fa0/ 的子接口配置模式。

请留意,路由器的命令提示符会更改。

在子接口配置模式下发出 encapsulation dot1Q 10 命令,将封装类型设置为并将VLAN 10 分配给该虚拟接口。

为端口分配正确的 IP 地址。

Fa0/ 的 IP 地址应为,子网掩码为。

使用正确的 IP 地址和 VLAN ID 对 Fa0/ 接口重复上述步骤。

R1(config)#interface fa0/
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#interface fa0/
R1(config-subif)#encapsulation dot1Q 30
任务 2:将 PPP 配置为封装方法。

步骤 1. 将 R1 配置为与 R2 之间使用 PPP 封装。

R1(config)#interface serial0/0/0
R1(config-if)#encapsulation ppp
步骤 1. 将 ISP 配置为与 R2 之间使用 HDLC 封装。

ISP(config)#interface serial0/0/0
ISP(config-if)#encapsulation hdlc
ISP(config-if)#no shutdown
步骤 1. 将 ANSI 配置为 R1、R2 和 R3 上的 LMI 类型。

对每台路由器的串行接口输入下列命令。

R1(config-if)#interface s0/0/0
R1(config-if)#frame-relay lmi-type ansi。

相关主题