思科交换机一些简单配置

Switch>
Switch#config t
Switch(config)#interface range f0/1 -2
Switch(config-if-range)# Switchport mode trunk

Switch>Enable
Switch#configure t
Switch(config)#inter vlan 1
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#line vty 0 4
Switch(config-line)#login //打开登录认证功能
Switch(config-line)#password 5ijsj // 密码明码显示
Switch(config-line)# privilege level 3 // 配置远程登录用户的权限为最高级别权限3
Switch(config-line)#end
Switch#show run //显示当前交换机配置情况

Switch>en
Switch#conf t
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#inter fa 0/1
Switch(config-if)#switch access vlan 2
Switch(config-if)#exit
Switch(config)#inter fa 0/2
Switch(config-if)#switch access vlan 3
Switch(config-if)#exit
Switch(config)#inter fa 0/24
Switch(config-if)#switchport trunk encapsulation dot1q // 给这个接口的trunk封装为802.1Q 的帧格式
Switch(config-if)#switch mode trunk
Switch(config-if)#exit
Switch#show ip route //显示路由表
Switch#show vlan

Switch(config)#ip routing //开启三层交换机的简单路由功能
Switch (config)#interface fastEthernet 0/5
Switch (config-if)#no switchport
Switch (config-if)#ip address 192.168.1.1 255.255.255.0
Switch (config-if)#no shutdown
Switch (config-if)#end
show running //显示路由器当前配置情况

en
conf t
vlan 2
exit
int fa 0/10
switchport access vlan 2
exit
int vlan 1
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
int vlan 2
ip address 192.168.2.1 225.255.255.0
no shutdown
end

1.关闭telnet
Router> config t
Router(config) > line vty 0 4
Router(config-line-vty)> no password
Router(config-line-vty)> exit
Router(config) > exit
Router>

1、telnet
r1(config)#line vty 0 4
r1(config-line)#password cisco1
r1(config-line)#login //只要求提供密码,如果不用login,则不用密码也可以远程登录
2、ssh v2
r1(config)#ip domain name abc.com
r1(config)#username admin password qwer1234 asdf1234
r1(config)#crypto key generate rsa rsa非对称加密
how many bits in the modulus[512]:1024 (如果不输,默认是512)
r1(config)#line vty 0 4
r1(config-line)#login local //要求先输入用户名,再输入密码验证
r1(config-line)#transport input ssh 用ssh传输
r1(config)#ip ssh version 2
连接时:ssh -l r1 192.168.1.1
password:cisco

line con 0
speed 115200
line vty 0 4
exec-timeout 30 0
logging synchronous
transport input ssh
line vty 5 15
exec-timeout 30 0
logging synchronous
transport input ssh

配置VTP:

1、核心交换机配置为vtp Server。
2、vtp domain为guanli。
Switch>en
Switch#vlan database
Switch(vlan)#vtp domain guanli
Switch(vlan)#vtp server
Device mode already VTP SERVER.
Switch(vlan)#

配置汇聚层(接入层)交换机1。
Switch>en
Switch#vlan database
Switch(vlan)#vtp domain guanli
Switch(vlan)#vtp client
Switch(vlan)#


思科交换机的基本配置

一、基本配置

switch>enable //进入特权模式

switch#config terminal //进入全局配置模式

switch(config)#hostname //设置交换机的主机名

switch(config)#enable secret xxx //设置进入特权MD5加密口令

switch(config)#enable password xxa //设置进入特权明文加密口令

switch(config)#line console 0 //进入控制台口

switch(config-line)#line vty 0 4 //设置进入虚拟终端的连接数目 0~4 5个

switch(config-line)#login //允许登录

switch(config-line)#password xx //设置登录到普通用户口令xx

switch#exit //返回命令

二、交换机vlan的配置

switch#vlan database //进入VLAN设置

switch(vlan)#vlan 2 //建VLAN 2

switch(vlan)#no vlan 2 //删vlan 2

Switch(config)# interface range fastethernet 0/1-5 //进入同种类型多端口配置

三、端口操作

switch(config)#int f0/1 //进入端口1

switch(config-if)#switchport access vlan 2 // 将端口1当前端口加入vlan 2

switch(config-if)#switchport mode trunk //将f0/1设置为中继干线

switch(config-if)#switchport trunk allowed vlan 1,2 //设置允许通过中继的vlan

switch(config-if)#switchport trunk encap dot1q //设置vlan 中继执行的协议

VLAN的端口聚合叫TRUNK,用来在不同的交换机之间进行连接,以保证在跨越多个交换机上建立的同一个VLAN的成员能够相互通讯。

本质上解决同一 vlan 下,不同主机直接互通 ,不需要把交换机的端口一个一个于另一个交换机上的端口对应链接 ,只需要连接一条,并把这条线所在的双方端口都设置成trunk口就可以了

其中 vlan 模式 有三种 trunk , hybrid ,access

Access类型的端口 一般用于连接计算机的端口(非特定 端口);

Trunk类型的端口可以允许多个VLAN通过,可以接收和发送多个VLAN的报文,一般用于交换机之间连接的端口;

dynamic 将端口模式设定为 动态接入模式 ,可trunk可 access

四、设置vtp

switch(config)#vtp domain //设置发vtp域名

switch(config)#vtp password //设置发vtp密码

switch(config)#vtp mode server //设置发vtp模式

switch(config)#vtp mode client //设置发vtp模式

这里要说下,什么是VTP协议。

VTP:是VLAN中继协议,也被称为虚拟局域网干道协议。它是思科私有协议。作用是十几台交换机在企业网中,配置VLAN工作量大,可以使用VTP协议,把一台交换机配置成VTP Server, 其余交换机配置成VTP Client,这样他们可以自动学习到server 上的VLAN 信息。VTP的用途  通常情况下,我们需要在整个园区网或者企业网中的一组的交换机中保持VLAN数据库的同步,以保证所有交换机都能从数据帧中读取相关的VLAN信息进行正确的数据转发,然而对于大型网络来说,可能有成百上千台交换机,而一台交换机上都可能存在几十乃至数百个VLAN,如果仅凭网络工程师手工配置的话是一个非常大的工作量,并且也不利于日后维护——每一次添加修改或删除VLAN都需要在所有的交换机上部署。在这种情况下,我们引入了VTP。

五、交换机设置IP地址:
switch(config)#interface vlan 1 //进入vlan 1

switch(config-if)#ip address //设置IP地址

switch(config)#ip default-gateway //设置默认网关

switch#dir flash: //查看闪存

六、交换机显示命令

switch#write //保存配置信息

switch#show vtp //查看vtp配置信息

switch#show run //查看当前配置信息

switch#show vlan //查看vlan配置信息

switch#show interface //查看端口信息

switch#show int f0/0 //查看指定端口信息

七、交换机配置保存

Switch#show running-config //查看交换机配置

Switch#copy running-config startup-config //保存交换机配置

备注,关于保存的方式:

1、在接口配置模式下使用 do wr 或者是 do copy running-config startup-config
2、在全局配置模式下使用不带do的命令(以上两个)wr或者copy running-config startup-config

思科交换机的二层交换机的配置

二层交换机的配置(配置二层交换机可远程管理)

配置如下:

在这里插入图片描述

Switch>

Switch>en //进入特权模式

Switch#config //进入全局配置模式

Switch(config)#hostname 2ceng //更改主机名为2ceng

2ceng(config)#interface vlan 1 //进入VLAN 1

2ceng(config-if)#no shut //激活VLAN1

2ceng(config-if)#exit //退出到全局配置模式

2ceng(config)#interface vlan 2 //创建VLAN 2

2ceng(config-if)#no shut //激活VLAN2

2ceng(config-if)#exit //退出到全局配置模式

2ceng(config)#interface vlan 3 //创建VLAN 3

2ceng(config-if)#no shut //激活VLAN3

2ceng(config-if)# ip address 192.168.3.254255.255.255.0 //配置192.168.3.254为2ceng管理IP

2ceng(config-if)#exit //退出到全局配置模式

2ceng(config)#interface range fa0/1-12 //进入到端口1-12

2ceng(config-if-range)#switchport mode access //将1-12口设置为交换口

2ceng(config-if-range)#switch access vlan 1 //将1-12口划分到VLAN 1

2ceng(config-if-range)#exit //退出到全局配置模式

2ceng(config)#interface range fa0/13-23 //进入到端口13-23

2ceng(config-if-range)#switch access vlan 2 //将13-23口划分到VLAN2

2ceng(config-if-range)#exit //退出到全局配置模式

2ceng(config)#interface fastEthernet 0/24 //进入到24口

2ceng(config-if)#switch mode trunk //将24口设置为干线

2ceng(config-if)#exit //退出到全局配置模式

2ceng(config)#enable secret cisco //设置加密的特权密码cisco

2ceng(config)#line vty 0 4 // VTY是路由器的远程登陆的虚拟端口,0 4表示可以同时打开5个会话,line vty 04是进入VTY端口,对VTY端口进行配置,比如说配置密码

2ceng(config-line)#password telnet //设置远程登陆密码为telnet

2ceng(config-line)#login

2ceng(config-line)#exit

2ceng(config)#ip default-gateway 192.168.3.1

2ceng(config)#exit

2ceng#wr //保存配置

Building configuration…

[OK]

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值