misc.php?action=viewratings&tid=428986&pid=3043294
cisco路由器命令行基本配置方法
登录方法 配置方法 基本命令 配置实例 故障排除
登录方法
1用cisco路由器主控口osole接vt100及兼容终端进行配置
这是一种较为简便的配置方法,把终端与路由器可靠连接后,打开终端与路由器的电源,路由器的启动过程就会在终端上显示出来,当出现符号“>”时就可以在终端上对路由器进行配置了。如果终端上未显示路由器启动过程,可能是终端通讯端口参数配置不对,需重新配置。
2通过windows的终端仿真程序进行配置
用cisco随机带console线,一端连在cisco路由器的console口,一端连在计算机的com口。打开电脑,启动超级终端.为您的连接取个名字,比如cisco_setup,下一步选定连接时用com1,下一步选定第秒位数9600,数据位8,奇偶校验无,停止位1,数据流控制无.最后选确定。打开路由器电源,这时超级终端将出现路由器启动画面。
3aux口接modem,通过电话线与远方的终端或运行终端仿真软件的微机相连。
4在tcp/ip网上通过telnet进行配置
通过网络上的主机运行telnet 145.1.1.5(路由器的ip地址),输入正确的口令就可以登录到网络上的路由器进行配置了。如出现了“password required,but none set”,则表明路由器的vty 04中未定义口令,需加入口令。
5通过ssh安全登录进行配置
在cisco路由器产品系列中只有7200系列、7500系列和12000系列(gsr)等高端产品的ios支持ssh。一般支持ssh的ios版本文件名中都带有k3或者k4字样,k3 代表56bit ssh 加密,k4代表168bit ssh加密。目前cisco的产品只支持ssh-1,还不支持ssh-2。下面以gsr 12008为例详细介绍ssh-1的配置方法:
① 配置hostname和ip domain-name:
router#configure terminal
router(config)#hostname test-gsr12008
test-gsr12008(config)#ip domain-name jx.cn.net
② 配置登录用户名和密码(以本地认证为例):
test-gsr12008(config)#username test password 0 test
注:添加一个用户:test,口令:test
test-gsr12008(config)#line vty 0 4
test-gsr12008(config-line)#login local
在这两部分做完以后,用show run命令就能够看到:
hostname test-gsr12008
!
boot system flash gsr-k3p-mz.120-14.s.bin
enable secret 5 $1$dmyw$gdsiokcr7p8ytwcrwtnjg.
enable password 7 094f47c31a0a
!
username test password 7 0835495d1d
clock timezone prc 16
redundancy
main-cpu
auto-sync startup-config
!
!
!
!
ip subnet-zero
no ip finger
ip domain-name jx.cn.net
ip name-server 202.101.224.68
ip name-server 202.101.226.68
!
③ 配置ssh服务:
test-gsr12008(config)#crypto key generate rsa
the name for the keys will be: test-gsr12008.jx.cn.net
注:ssh的关键字名就是hostname + . +ip domain-name
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 rsa keys ...
[ok]
test-gsr12008(config)#end
test-gsr12008#write
building configuration...
这时候用show run命令可以看到:
ip subnet-zero
no ip finger
ip domain-name jx.cn.net
ip name-server 202.101.224.68
ip name-server 202.101.226.68
ip ssh time-out 120
ip ssh authentication-retries 3
!
用命令show ip ssh也能看到:
ssh enabled - version 1.5
authentication timeout: 120 secs; authentication retries: 3
现在ssh服务已经启动,如果需要停止ssh服务,用以下命令:
test-gsr12008(config)#crypto key zeroize rsa
④设置ssh参数
配置好了ssh之后,通过show run命令我们看到ssh默认的参数:超时限定为120秒,认证重试次数为3次,可以通过下面命令进行修改:
test-gsr12008(config)#ip ssh {[time-out seconds]} | [authentication-retries interger]}
如果要把超时限定改为180秒,则应该用:
test-gsr12008(config)# ip ssh time-out 180
如果要把重试次数改成5次,则应该用:
test-gsr12008(config)# ip ssh authentication-retries 5
这样,ssh已经在路由器上配置成功了,就能够通过ssh进行安全登录了。
配置方法
1 setup
第一次安装时系统会自动进入dialog setup。依次回答路由器名称,加密超级登录密码,超级登录密码,远程登录密码 ,动态路由协议,各个接口的配置等。之后回答yes保存该配置。然后等2分钟,按回车数下。出现路由器名称。打入enable命令,回答超级登录密码。出现路由器名称#。打入config terminal配置路由器:
no service config
no ip domain-lookup
(进一步的配置)
按ctrl-z退出,出现路由器名称#。打入write
memory保存配置。
2 命令配置
1.模式(modes)
cisco ios命令行界面是围绕模式(modes)这个概念来进行组织的。在配置路由器的时候,你要在几个不同的模式之间进进出出,而所处模式决定所用的命令。每个模式都有一整套可用于该模式的命令,并且其中的某些命令只能用于该模式。在任何模式中,输入问号将显示用于该模式的命令列表。
router>?
1.1 非特权模式。当你第一次连接路由器并提供口令(如果必要的话)时,进入exec模式,当前模式下只能查看有限的信息。输入show ? 将会显示所有用于当前模式的show命令。
router>show ?
1.2特权模式。运行命令enable并提供口令之后,你就会进入特权模式。一旦你进入特权模式,你就有权访问所有的配置信息。
router#
特权模式里有许多子模式。 所有子模式仍然以#号作结束,它们包含于特权模式之中。大多数模式都有自己的子模式。
router(参数)#
2. 基本配置
查看它当前的配置。运行命令enable进入特权模式,然后运行几个show命令来查看它们所显示的信息。
router#show interfaces
router#show ip protocols
router#show ip route
router#show ip arp
当配置路由器时,你要进入各种子模式来设置选项,然后返回到父模式来显示命令结果。你还要返回到父模式来进入其它的子模式。返回父模式,按ctrl-z键。这时,你刚才运行的任何命令都会发生影响,并把你带回到父模式中。
2.1 共用配置(config)
配置路由器的任何特性,必须进入配置模式,这就是父模式的第一个子模式。在父模式中,运行 config命令。
router#config
router(config)#
命名你的路由器:
router(config)#hostname examplename
examplename(config)#
指定路由器所用的dns服务器:
examplename(config)#ip name-server aa.bb.cc.dd
examplename(config)#ctrl-z
examplename#
为特权模式设置密码:
examplename(config)#enable secret examplepassword
examplename(config)#ctrl-z
examplename#
在配置模式,运行几个不同的命令,然后按ctrl-z键激活所有命令。每次你按下ctrl-z键返回到父模式并提示:
examplename#
2.2 配置接口
命名cisco接口是直发的,个别接口由本约定指定:
media type slot#/port#
“介质类型”是指端口为诸如ethernet、token ring、fddi、串口等接口的介质类型。插槽数只适用于为你提供可以安装模块的插槽的路由器。这些模块包括几个特定介质的端口,7200系列就是一个例子。这些模块甚至是可热插拔的。你可以从插槽中移去一个模块并用一块不同的模块来代替它,而不必中断由安装在路由器里的其它模块所提供的服务。这些插槽在路由器中是被编号的。
端口数涉及到的端口与该模块里的其它端口有关。编号方式是从左到右,所有编号都是从0开始,而不是1。
例如,cisco 7206是带有6个插槽的7200系列路由器。提到的一个接口是安装在第六插槽的ethernet模块的第三个端口,它应是以太网6/2接口。因此,为了显示该接口的信息,你可以使用命令:
examplename#show interface ethernet 6/2
如果你的路由器没有插槽,如1600,那么接口名的组成只有:
media type port#
例如:
examplename#show interface serial 0
这里有一个用一个ip地址来配置一系列端口的例子:
examplename#config
examplename(config)#interface serial 1/1
examplename(config-if)#ip address 192.168.155.2 255.255.255.0
examplename(config-if)#no shutdown
examplename(config-if)#ctrl-z
examplename#
然后验证配置:
examplename#show interface serial 1/1
注意no shutdown命令。一个接口在正确配置及物理连接后,也许仍是“在管理上关掉”。在这种情形下,它不会起作用。引起一个接口在管理上关掉的命令是shutdown。
examplename(config)#interface serial 1/1
examplename(config-if)#shutdown
examplename(config-if)#ctrl-z
examplename#show interface serial 1/1
在cisco ios中,相反的情形或者删除任何命令的结果是简单地把no放在该命令的前面。例如,如果我们想取消已经赋给interface serial 1/1 的ip地址:
examplename(config)#interface serail 1/1
examplename(config-if)#no ip address 192.168.155.2 255.255.255.0
examplename(config-if)ctrl-z
examplename#show interface serial 1/1
2.3 路由
在cisco路由器上,ip路由是自动激活的。在你的路由器上,如果ip路由先前一直是关闭的话,你可以用命令ip routing返回到config模式中。
examplename(config)#ip routing
examplename(config)#ctrl-z
有两种主要的方式让路由器知道把包发送到什么地方,静态路由(static routes)和动态路由协议(dynamic routing protocol)来知悉路由。
一个静态路由实例:
examplename#config
examplename(config)#ip route 172.16.0.0 255.255.255.0 192.168.150.1
examplename(config)#ctrl-z
examplename#show ip route
3用tftp server下载的配置文件进行配置
unix、os/2操作系统提供了tftp服务器的功能,以os/2为例,在os/2的dos窗口下运行ftfpd显示:
ibm tcp/ip os/2版本-tftp server版本19:50:56 on dec 7 1995已准备好
通过某种方式登录到路由器,当出现“>”后,就可以进行配置了,下面是一个配置实例。
router>en
password:abcdefg(特权用户口令)
roture #copy ftfp runnig-config(拷贝tftp服务器上的配置文件到路由
器的运行配置中)
host or network configuration file[host]?host
address of remote host[255.255.255.255]?145.1.1.1(主机的ip地址)
145.1.1.1为运行tftp的服务器,也是路由器配置文件所在的主机。
如出现提示:“there are no usable interface configured for ip”表明
路由器的ethernet 0(以太网口)未配置好。
配置ethernet 0:
router#conf t
router(config)#int e0
router(config-if)ip address 145.1.1.5
router(config-if)#no shutdown
router(config-if)#exit
router(config)#exit
router#wr(保存到启动配置中)
name of configuration file[router-config]?2511(配置文件名)
configure using 2511 from 145.1.1.1?[confirm]
显示:
loading 2511 from 145.1.1.1(via ethernet0)
[ok-1553/32723 bytes]
拷贝运行配置到启动配置文件nvram中:
router#copy runnig-config startup-config
输入router#i或重新开启路由器电源以重新启动路由器。
备份运行配置到服务器中:
router#copy runnig-config ftfp
remote host[]145.1.1.1
name of configuration file to write
[router-config] 2511bf
write file 2511bf on host 145.1.1.1?[confirm]
显示:writing 2511bf!![ok] 至此,路由器配置完成。
4通过ethernet上的snmp网管工作站
基本命令集
一、 基本路由器的检验命令
show version
show processes
show protocols
show mem
show ip route
show startup-config
show running-config
show flash
show interfaces
二、 基本路由配置命令
进入:config terminal/memory/network
配置网络时常采用的命令:copy和load
1. 标识:hostname 标识名
2. 启动标识:banner 启动标识
3. 接口:interface 端口号
4. 密码:line 0 6
login
passwd 口令
enable password/secret 口令
5. 接口:
1)配置端口
interface 端口号
clock rate 时钟速率(64000)/* 在串口中配置 */
bandwidth 带宽(缺省56) /* 在串口中配置 */
media-type 介质类型 /* 在以太网口上 */
early-token release /* 在令牌环网口上 */
ring-speed 16 /* 在令牌环网口上 */
no shutdown
write memory
2)检验端口
show interfaces
show controllers
6. 配置环境
1) 引导方式
boot system flash ios-filename
boot system tftp ios-filename tftp-address
boot system rom
2) 配置register值
config-register 0x2102
7. 查看邻居路由
show cdp interface
show cdp neighbors [detail]
show cdp entry routera
8. ip address 配置
ip address 网络地址 掩码
ip host 主机名 address
ip name-server 服务器地址1 服务器地址2 。。。
ip domain-lookup nsap
show hosts
ping 主机名/ip地址
trace 主机名/ip地址
三、 ip 路由
1. 静态路由
ip routing
ip route 目标网络号 掩码 端口号 [permanent]
2. 缺省路由
ip default-network 网络号
3. 动态路由
1) rip配置
router rip
network 网络号
show ip route
show ip protocol
debug ip
2) ospf 配置
router ospf 进程号
redistribute 其它路由协议
network 端口网络 反掩码 area 区域号
area 区域号 range 网络号 掩码
area 区域号 default-cost 花销值
ip ospf priority number
ip ospf cost 花销值
show ip ospf database
3) bgp 配置
router bgp 自治域号
redistribute 其它路由协议
network 网络号 /* 自治域内 */
aggregate-address 网络号 掩码 summary-only 汇总网络
neighbor 相邻网络号 remote-as 自治域号 /* 自治域间的网络 */
四、 流量控制
1) 被动端口
passive interface 端口号
2) 缺省路由
ip default 网络号/端口网络
3) 静态路由
ip route 目标网络号 掩码 端口号
4)acl过滤表
(全局上) access-list 访问号1 {permit|deny} 反掩码号 [ established]
access-list 访问号2 {permit|deny} ip/tcp协议 源网络 目的网络
操作符 参数
(端口上)access-group 访问号 in|out
distribute-list 访问号 in|out 端口号
4) null 0 interface
ip route address mask null 0
五、 广义网配置
1) ppp
ppp pap sent-usename 封装
ppp chap hostname
ppp chap password
2)x.25
encapsulation x25 [dce]
x25 address
x25 map 协议地址 /*svc */
x25 pvc pvc号 ip地址 x25地址 /*pvc */
ip switching
x25 route x.121地址 接口 x.121映射地址
2) framerelay
frame-relay local-dlci ip网络号
frame-relay map 协议地址
frame-relay lmi-type ansi
好东东 希望大家支持
(责任编辑:admin) |