网络基础命令

IOS基本操作命令
一、简介
Cisco 的网际操作系统(IOS:Internetwork Operating System),IOS配置通常是通过基于文本的命令行接口进行的。
二、操作模式
1、用户模式:
R1>
#常通可以查看统计信息
R1>logout
#退出用户模式

2、特权模式
R1>enable
R1#
#进入特权模式,特权模式是从用户模式进入的。用于查看和修改路由器。
R1#disable
#退出特权模式

3、全局配置模式
R1#confiigure terminal
R1(config)#
#进入全局模式,全局配置模式是从特权模式进入的。一但做修改,就会影响整个网络。

R1#config t简化命令或R#configure都可以进入全局配置模式。

R1(config)#exit
#退出全局配置模式,或使用快捷键ctrl+z

帮助命令与命令补全
R1#conf #按tab键
R1#configure t #按tab键
R1#configure terminal 补全所有命令为configure terminal

设置时钟:
R1#clock set 11:40:55 21 apr 2018

查看时间设置:
R1#show clock

支持快捷键
Ctrl+u 从光标所在位置删除到行首
Ctrl+u 光标移动到行首
Ctrl+e 水标移动到行尾
查看终端配置与历史命令保存数:R1#show terminal
查看历史命令:R1#show history
修改历史命令保存条数:R1#terminal history size 50 即把原来默认的10条改50条,不建议,占资源。
查看路由基本信息:R1#show version

三、路由器和交换机的密码管理:
1、设置主机名:把主机名从R1改名为R2
R1>en
R1#config t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#hostname R2
R2(config)#
2、设置登录提示信息
(1)定义日期信息登记
R1#config t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#banner motd i 分割界定符,在两个i之间里面可以是任意字符
Enter TEXT message. End with the character 'i'.
Abcdefjhklmnopqrstuvwxyz i
R1(config)#exit
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#coye run start 保存running-config到start
R1#reload重启路由器
(2)定义登录信息 此功能模拟器上没有实现
R(config)#banner login u
Ccccccccccccccccccc
U
R1(config)#exit
R1#
R1#copy run start
3、设置口令
路由器密码
接口密码,不能输入任何命令,需要马上输入
1)console口密码
本地接口,所以不用密码也可以管理
2)虚拟接口密码
a)telnet密码
b)ssh密码
3)aux接口
特权密码:
登录之后,执行enalbe命令,进入特权密码模式时需要
Conf t enable secret 密码

1)设置特权模式密码
R1(config)#enable password 123 #设置特权非密口令(明文)
R1(config)#enable screct 456 #设置特权加密口令(加密)
2)设置console端口登录口令
R1(config)#line console 0
R1(config-line)# #表示进入了console模式
R1(config-line)#password 123 #设置密码为123
R1(config-line)#login #启用密码检查
R1(config-line)#exec-timeout 0 0 #接口模式中,设置回话超时时间,0 0 是永不超时

R1(config-line)#logging synchronous #阻止控制台信息,避免打拢命令输入
3)设置telnet登录口令
R1(config)#line vty 0 15
R1(config-line)#password 123
R1(config-line)#login
#telnet登录不安全,请避免使用
R1(config-line)#line vty 0 15
R1(config-line)#no login
#允许telnet无密码登录(不安全,不允许使用)

4)密码加密
密码除了R1(config)#enable secret 456密码是加密保存,其他密码都是明文保存,可以通过:
R1(config)#show running-config查看
R1(config)#service password-encryption #可以开启加密服务,所有的密码都会密文保存

4、SSH登录
1)设置用户名和域名
R1(config)#hostname sc
SC(config)#ip domain-name lamp
修改主机名和域名,生成秘钥时需要用
#必须设定路由器时间
2)生成加密秘钥
R1(config)#hostname sc
sc(config)#ip domain-name lamp
sc(config)#cr
sc(config)#crypto key generate rsa general-keys modulus 1024
#使用rsa加密,生成1024位秘钥,如果钥匙位数小于468位,则不能使用2代ssh协议。 DSA
3)设定登录密码
sc(config)#aaa new-model #启用AAA(认证,授权和记帐)模式
sc(config)#username cisco password cisco #设定用户名和密码
4)设定超时时间、失败次数、版本
sc(config)#ip ssh time-out 120 #设定超时时间
sc(config)#ip ssh authentication-retries 5 #设置最大失败
sc(config)#ip ssh version 2 #设置ssh版本为SSH2
5)设定连接线路-----------------------?模拟器里没有找到line vty 0 998线路
SC(config)#line vty 0 988
Sc(config-line)#transport input SSH
#transport input SSH telnet
#远程登录后,特权模式不设置密码,是不能登录特权模式的

四、路由器接口操作
1、查看接口:
Router0#show running-config
2、选择接口,会进入接口配直模式
Router(config)#interface ?
Dot11Radio Dot11 interface #无线网卡接口
Ethernet IEEE 802.3 #以太网接口
FastEthernet FastEthernet IEEE 802.3 #快速以太网接口
GigabitEthernet GigabitEthernet IEEE 802.3z #千兆以太网接口
Loopback Loopback interface #回环网卡接口
Serial Serial #串行接口
Tunnel Tunnel interface #隧道接口
Virtual-Template Virtual Template interface #虚拟模拟接口
Vlan Catalyst Vlans #vlan接口
range interface range command #接口范围

sc(config)#interface fastEthernet0/1 #进入快速以太网接口0/0,其中0代表插槽,1代表端口
sc(config-if)#
#有些接口会用0/0/1描述,0代表路由器本身,0代表插槽,1代表端口
3、接口描述
sc(config)#int f0/1
sc(config-if)#description caiwu route #描述此接口连接的是哪一台路由器
4、do命令,就是在全局模式下,需要扫行在特权模式下的命令前加do才能执行。如R1(config)#do show run
5、激活接口,接口默认是关闭状态,需要激活
R1(config)#interface fastEthernet 0/0
sc(config)#interface f0/0
sc(config-if)#no shutdown
6、给接口配IP地址
sc(config)#in f0/0
sc(config-if)#ip address 192.168.1.1 255.255.255.0
sc(config-if)#
7、时钟频率
一般由服务器运营商来进行控制。时钟频率只对串口连接的路由器有效,串口是用于老式的广域网连接的,主要用E1网络(带宽2.048Mbps)。现在基本用光纤取代了。
如果Seria串口,则在DCE(数据通信)端需要配置时钟频频率,但是DTE(数据终端设备)端不需要配置。实验中,用串口连接两个路由,则需要在DCE口配置时钟频率。

查看s1/0/0或是s1/1/0接口情况,可以看到这个路由器的口是DTE或是DCE端
R#show controllers s1/1/0

DCE端需要配置时钟频率 单位bit/s
R2(config)#int s1/1/0
R2(config-if)#clock rate 64000
五、保存与删除
1、保存配置
Router0#copy running-config startup-config
#running-config是运行配置,保存在DRAM当中,重启会丢失。执行此命令会把running-config复制为startup-config。Startup-config是启动配置,保存在NVRAM中,永久生效。
Router0#show startup-config #查看启动配置
2、删除配置
Router# erase startup-config
Router#show startup-config
Startup-config is not present
Router#reload 重启路由器
六、查看验证配置
1、ping ip 测试ip地址是否通畅
2、Traceroute 域名或IP 测试路由路径
3、Telnet IP或域名 端口     远程管理,或探测端口
4、查看接口的参数和配置
Router0#show interfaces ?
Router0#show interfacesf0/0
5、清除接口的计数器
Router0#clear counters f0/0
6、查看IP信息
router0#show ip interface
7、查看所有接口的ip地址和状态
Router0#show ip interface brief
8、查看所有接口上的协议
#可以用于查询每个端口的状态和配置的IP地址
Router#show protocols

猜你喜欢

转载自blog.51cto.com/13707360/2107859
今日推荐