野菊花

首页 » 常识 » 预防 » 思科交换机配置命令大全,交换机配置案例详
TUhjnbcbe - 2021/6/15 10:54:00

一直以来,我们曾多次提到关于华为、H3C、锐捷这三家交换机的配置命令及案例,相信大家对他们的配置有一定的了解了,近期有一些朋友留言希望学习一下思科的交换机配置,思科的交换机虽然现在没有华为的用的多,但在项目中仍然有使用到,在我们弱电VIP技术群中也有不少朋友在项目中遇到。

本期我们就一起来详细的了解思科交换机的配置命令。

一、思科交换机基本配置命令

1:进入特权模式enable

switchenable

switch#

2:进入全局配置模式configureterminal

switchenable

switch#configureterminal

switch(conf)#

3:交换机命名hostnameaptech以aptech为例

switchenable

switch#configureterminal

switch(conf)#hostnameaptch-

aptech(conf)#

4:配置使能口令enablepasswordcisco以cisco为例

switchenable

switch#configureterminal

switch(conf)#hostnameaptch

aptech(conf)#enablepasswordcisco

5:配置使能密码enablesecretciscolab以cicsolab为例

switchenable

switch#configureterminal

switch(conf)#hostnameaptch

aptech(conf)#enablesecretciscolab

6:创建多个vlan

1、创建多个VLAN

Switchenable(进入特权模式)

Switch#vlandata(进入vlan配置模式)

Switch(vlan)#vlan10nameIT(划分vlan10,名称为IT)

Switch(vlan)#vlan20nameHR(划分vlan20,名称为HR)

Switch(vlan)#vlan30nameFIN(划分vlan30,名称为FIN)

Switch(vlan)#vlan40nameLOG(划分vlan40,名称为LOG)

Switch(vlan)#exit

7:设置vlan1

switchenable

switch#configureterminal

switch(conf)#hostnameaptch

aptech(conf)#interfacevlan1

aptech(conf-if)#ipaddress..1....0配置交换机端口ip和子网掩码

aptech(conf-if)#noshut是配置处于运行中

aptech(conf-if)#exit

aptech(conf)#ipdefault-gateway..设置网关地址

8:进入交换机某一端口interfacefastehernet0/17以17端口为例

switchenable

switch#configureterminal

switch(conf)#hostnameaptch

aptech(conf)#interfacefastehernet0/17

aptech(conf-if)#

9:查看命令show

switchenable

switch#showversion察看系统中的所有版本信息

showinterfacevlan1查看交换机有关ip协议的配置信息

showrunning-configure查看交换机当前起作用的配置信息

showinterfacefastethernet0/1察看交换机1接口具体配置和统计信息

showmac-address-table查看mac地址表

showmac-address-tableaging-time查看mac地址表自动老化时间

10:交换机恢复出厂默认恢复命令

switchenable

switch#erasestartup-configure

switch#reload

11:双工模式设置

switchenable

switch#configureterminal

switch(conf)#hostnameaptch-

aptech(conf)#interfacefastehernet0/17以17端口为例

aptech(conf-if)#duplexfull/half/auto有full,half,auto三个可选

11:cdp相关命令

switchenable

switch#showcdp查看设备的cdp全局配置信息

showcdpinterfacefastethernet0/17查看17端口的cdp配置信息

showcdptraffic查看有关cdp包的统计信息

showcdpnerghbors列出与设备相连的cisco设备

12:交换机telnet远程登录设置:

switchen

switch#configureterminal

switch(conf)#hostnameaptech-

aptech(conf)#enablepasswordcisco以cisco为特权模式密码

aptech(conf)#interfacefastethernet0/1以17端口为telnet远程登录端口

aptech(conf-if)#ipaddress..1....0

aptech(conf-if)#noshut

aptech(conf-if)#exit

aptech(conf)linevty04设置0-4个用户可以telnet远程登陆

aptech(conf-line)#login

aptech(conf-line)#passwordedge以edge为远程登录的用户密码

主机设置:

ip..1.2主机的ip必须和交换机端口的地址在同一网络

netmask...0

gate-way..1.1网关地址是交换机端口地址

运行:

telnet..1.1

进入telnet远程登录界面

password:edge

aptechen

password:cisco

aptech#

二、利用三层交换机,实现不同vlan间互相通信

上面我们了解了思科交换机的基本配置命令,下面我们来看下配置案例。

案例如下:

pc1与pc2由于阻绝在了两个不同的交换机里,且在不同的vlan中,是无法通信的,那怎么办呢?

S-24(三层交换机)1台、S交换机1台、pc1在vlan10里,pc2在vlan20里,如下图所示。

VLAN间通信实验拓扑结构图

配置如下:

1、在交换机SwitchA上创建VLAN20,并将F0/15口划分到VLAN20中。

SwitchAenable

SwitchA#configureterminal

SwitchA(config)#vlan20//创建VLAN20

SwitchA(config-vlan)#namevlan20//将VLAN20命名为vlan20

SwitchA(config)#interfacef0/15//进入F0/15接口配置模式

SwitchA(config-if)#switchportaccessvlan20//将F0/15端口划入VLAN20

SwitchA#showvlanid20//验证已创建了VLAN20并已将F0/15端口划入VLAN20中。

2、在交换机SwitchA上与SwitchB相连的端口(此处为F0/24端口)定义为tagvlan模式。

SwitchAenable

SwitchA#configureterminal

SwitchA(config)#interfacef0/24//进入接口配置模式

SwitchA(config-if)#switchportmodetrunk//将F0/24口设置为tagvlan模式

SwitchA(config)#showinterfacesf0/24switch//验证F0/24口已被设置为tagvlan模式

3、在交换机SwitchB上创建VLAN10,并将F0/5端口划入VLAN10中。

SwitchAenable

SwitchA#configureterminal

SwitchB(config)#vlan10//创建VLAN10

SwitchB(config-vlan)#namevlan10//将VLAN10命名为vlan

SwitchB(config)#interfacef0/5//进入F0/5接口配置模式

SwitchB(config-if)#switchportaccessvlan10!将F0/5端口划入VLAN10

SwitchB#showvlanid10//验证已创建了VLAN10并已将F0/5端口划入VLAN10中

4、在交换机SwitchB上与SwitchA相连的端口(此处为F0/24端口)定义为tagvlan模式。

SwitchAenable

SwitchA#configureterminal

SwitchB(config)#interfacef0/24//进入接口配置模式

SwitchB(config-if)#switchportmodetrunk//将F0/24口设置为tagvlan模式

SwitchB(config)#showinterfacesf0/24switch//验证F0/24口已被设置为tagvlan模式。

5、设置三层交换机VLAN间通讯,开启三层交换机的路由功能

SwitchAenable

SwitchA#configureterminal

SwitchA(config)#iprouting//开启三层交换机的路由功能

SwitchA(config)#interfacevlan10//创建虚拟接口vlan10

SwitchA(config-if)#ipaddress..10....0//配置vlan10的虚拟接口ip地址

SwitchA(config)#interfacevlan20//创建虚拟接口vlan20

配置vlan20的虚拟接口ip地址

SwitchA(config-if)#ipaddress..20....0//配置vlan20的虚拟接口ip地址

5、配置默认网关

将PC1的默认网关设置为..10.,将PC2的默认网关设置为..20.

如此,pc1与pc2便可以相互通。

弱电行业网
1
查看完整版本: 思科交换机配置命令大全,交换机配置案例详