当前位置:网站首页>Cisco common basic configuration of common commands
Cisco common basic configuration of common commands
2022-08-09 09:32:00 【Hengyue sunsite】
一、前言
思科就是数通界的NO1,老一辈网络工程师都是从学习思科开始的.此博文是介绍思科的基础命令,包括如何配置主机名、IP地址、telnet、ssh远程登录等常用基础命令.博文的初衷是作为一篇备忘录,在长时间不配置思科设备,临时要用时候的备查,可以可以作为新手入门必备命令,必须要熟悉和掌握的.思科模拟器有GNS3、CiscoPacketTracer等.此博文实验环境为:
- 模拟器:CiscoPacketTracer8.1
- 设备:CISCO2911
- IOS版本:Version 15.1(4)M4
二、常用基础配置
1、进入全局配置模式
router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
router(config)#
2、配置主机名
router(config)#hostname s1
s1(config)#
3、关闭域名查询

s1(config)#no ip domain lookup
4、配置同步日志输出


s1(config)#line con 0
s1(config-line)#logging synchronous
5、配置console
配置console密码后下次登录需要输入console密码,console登录特权级别为15,登录后直接进入特权模式;登录级别为小于15则进入普通用户模式,需要输入enable密码才可以进入特权模式.
s1(config)#line con 0
s1(config-line)#exec-timeout 30 0
s1(config-line)#password cisco
s1(config-line)#privilege level 15
s1(config-line)#login
6、配置vty
思科网络设备默认使用telnet方式远程管理,配置vty和IP地址后可以实现远程访问和管理.
s1(config)#line vty 0 15
s1(config-line)#exec-timeout 15 0
s1(config-line)#privilege level 1
s1(config-line)#password cisco
s1(config-line)#login
7、保存配置
思科网络设备可以使用wr或者copy running-config startup-config保存配置.
s1#wr
Building configuration…
[OK]
s1#copy running-config startup-config
Destination filename [startup-config]?
Building configuration…
[OK]
8、一步退回到特权模式
s1(config-line)#end
s1#
9、配置特权密码

s1(config)#enable password cisco
s1(config)#enable secret Cisco
10、开启ip路由功能
#ip routing功能默认开启
s1(config)#ip routing
11、查看running配置
running-config是当前配置,配置模式下的任何操作会写入running-config,执行保存命令后写入startup-config.
s1#show running-config
12、查启动配置
startup-config是设备开启启动时自动加载的配置.
s1#show startup-config
13、配置模式下强制执行show
Cisco设备配置模式下只能执行配置操作,如果要执行show查看配置操作需要退到用户模式或者特权模式下;配置模式下可以使用do show方式强制执行show.
s1(config)#do show ip int bri
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 unassigned YES unset administratively down down
…
14、取消配置
思科设置取消某配置在命令前加no,例如开启端口使用no shutdown,取消ip routing功能使用命令no ip routing.
s1(config-if)#no shutdown
15、接口下配置IP地址
s1(config-if)#int g0/0
s1(config-if)#ip add 192.168.1.1 255.255.255.252
16、配置loopback地址
loopback接口只要配置了状态始终是up状态,一般用于动态路由协议的routerID.
s1(config)#int loop 0
s1(config-if)#
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
s1(config-if)#ip add 172.16.1.1 255.255.255.0
17、配置静态路由
通过ip route 网络地址 掩码 next-hop的方式配置静态路由,next-hop可以是IP地址,接口等.如果网络地址和掩码均为0.0.0.0则配置的是默认路由.
s1(config)#ip route 172.16.2.0 255.255.255.0 192.168.1.2
18、查看ip接口状态
s1#show ip int bri
19、查看路由表
s1#show ip route
20、配置telnet登录

配置telnet需要本地账户和vty下的登录指定本地认证.
s1(config)#username wuhs secret cisco
s1(config)#line vty 0 15
s1(config-line)#login local
21、配置ssh登录

#配置ssh登录需要首先定义一个域名;
s1(config)#ip domain-name cisco.com
#然后生成key;
s1(config)#crypto key generate rsa general-keys
The name for the keys will be: s1.cisco.com
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable…[OK]
#定义远程登录用户
s1(config)#username wuhs secret cisco
#设置vty登录协议为ssh,默认是telnet,如果设置为all则运行ssh和telnet双协议.
s1(config)#line vty 0 15
s1(config-line)#transport input ssh
s1(config-line)#login local
22、查看ios版本
show version命令可以查看设备型号,软件版本和设备uptime时间等等.
s1#show version
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.1(4)M4, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright 1986-2012 by Cisco Systems, Inc.
Compiled Thurs 5-Jan-12 15:41 by pt_team
23、查看cdp邻居
cdp协议是思科的私有协议,可以查看与此设备直连的思科设备.
s1#show cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
s2 Gig 0/0 123 R C2900 Gig 0/0
24、日志打印到远程终端

s1#terminal monitor
边栏推荐
猜你喜欢

Teach you how to get a 0.1-meter high-precision satellite map for free

常用功能测试的检查点与用例设计思路

手机APP测试流程规范和方法你知道多少?

Ontology development diary 04 - to try to understand some aspects of protege

【机器学习】网络爬虫实战详解

QT sets the icon of the exe executable

运行flutter项目时遇到的问题
测试用例的原则、缺陷报告怎么写你都知道吗?
Do you know the principles of test cases and how to write defect reports?

接口性能测试方案设计方法有哪些?要怎么去写?
随机推荐
软件测试分析流程及输出项包括哪些内容?
使用Protege4和CO-ODE工具构建OWL本体的实用指南-1.3版本(4.Building An OWL Ontology)
接口开发规范及测试工具的使用
lateral view explode的另一种实现方式
MySQL Checking and Filling Leaks (5) Unfamiliar Knowledge Points
常用功能测试的检查点与用例设计思路
Sweet alert
MySQL indexes
JMeter初探五-配置元件与参数化
AES/ECB/PKCS5Padding encryption and decryption
选择黑盒测试用例设计方法的综合策略方案总结
性能测试的基本概念是什么?做好性能测试需要掌握哪些知识?
seata处理分布式事务
Ontology Development Diary 03-Understanding Code
map去重代码实现
进入大厂的面试经验(P7)
游戏测试的概念是什么?测试方法和流程有哪些?
web测试之功能测试常用的方法有哪几种?有什么要点要注意?
2.Collection接口
手机APP测试流程规范和方法你知道多少?