交换机的基本配置

交换机的基本配置

一.交换机和路由器一共有四种工作模式

1.普通用户模式,在该模式下可以看到交换机的一部分系统和配置信息,并且只能输入一些有限的命令,但不能配置

Switch>

2.特权用户模式,该模式可以查看交换机的配置信息和调试信息,还能删除配置文件,在特权模式下还能进入到其他模式的关口,从普通用户模式到特权用户模式的命令为enable

Switch>enable 
Switch#

3.全局配置模式,从特权用户模式下输入configure terminal 即可进入到全局配置模式,在该模式下可以修改交换机的名字,配置交换机的特权密码,进入端口、vlan等配置。

Switch#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#

4.接口配置模式,是对交换机的各种接口的配置,如配置IP地址、数据传输协议、封装协议等,在全局配置模式下输入 interface + 要配置的端口即可,如下命令进入f0/1端口和进入vlan接口。

Switch(config)#interface f0/1
Switch(config-if)#exit
Switch(config)#interface vlan1
Switch(config-if)#

二.交换机的基本接口配置和修改主机名

1.在全局配置模式下修改主机名

Switch(config)#hostname S1
S1(config)#

2.密码配置

S1(config)#enable secret admin    #设置特权加密为admin
S1(config)#enable password 12345  #设置非特权加密为12345
S1(config)#line vty 0 4        #进入虚拟终端允许打开五窗口会话
S1(config-line)#password 123   #进入虚拟终端的密码为123
S1(config-line)#login    #验证登录
S1(config-line)#

3.配置管理地址,默认情况下是给vlan1配置的,配置完后PC可以通过telnet来远程连接交换机。

S1(config)#int vlan 1  #进入vlan1
S1(config-if)#ip address 192.168.1.1 255.255.255.0  #配置IP地址
S1(config-if)#no shutdown   #开启端口
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
S1(config-if)#exit
S1(config)#ip default-gateway 192.168.1.254  #设置默认网关
S1(config)#

在这里插入图片描述在这里插入图片描述
4.设置以太网端口的工作模式和速率

S1(config)#int f0/1  #进入F0/1
S1(config-if)#duplex ?
  auto  Enable AUTO duplex configuration  #自动检测双工模式 
  full  Force full duplex operation       #全双工
  half  Force half-duplex operation       #半双工
S1(config-if)#speed ?
  10    Force 10 Mbps operation      #10M
  100   Force 100 Mbps operation     #100M
  auto  Enable AUTO speed configuration  #自动检测

5.配置端口安全的常用命令,如下把vlan1分配给f0/1

S1(config-if)#int f0/1
S1(config-if)#switch ?
  access         Set access mode characteristics of the interface
  mode           Set trunking mode of the interface
  native         Set trunking native characteristics when interface is in
                 trunking mode
  nonegotiate    Device will not engage in negotiation protocol on this
                 interface
  port-security  Security related command
  priority       Set appliance 802.1p priority
  trunk          Set trunking characteristics of the interface
  voice          Voice appliance attributes
S1(config-if)#switchport access vlan 1
S1(config-if)#switchport mode trunk   #配置trunk口

6.在特权用户模式下保存交换机的配置

S1#copy running-config startup-config 
Destination filename [startup-config]? 
Building configuration...
[OK]
S1#

7.在特权模式下查看交换机的所有配置

S1#show running-config 
Building configuration...

Current configuration : 1189 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S1
!
enable secret 5 $1$mERr$vTbHul1N28cEp8lkLqr0f/
enable password 12345
!
!
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
 switchport mode trunk
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet1/1
!
interface GigabitEthernet1/2
!
interface Vlan1
 ip address 192.168.1.1 255.255.255.0
!
ip default-gateway 192.168.1.254
!
!
line con 0
!
line vty 0 4
 password 123
 login
line vty 5 15
 login
!
!
end


S1#

8.清除交换机配置信息

S1#erase startup-config 
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
%SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram

在这里插入图片描述

  • 28
    点赞
  • 196
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啊醒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值