1、Troubleshooting IP Address一些网络问题的排难1.打开 Windows里的 1个 DOS窗口,ping 本地回环地址 127.0.0.1,如果反馈信息失败,说明 IP协议栈有错,必须重新安装 TCP/IP协议2.如果 1成功,ping 本机 IP地址,如果反馈信息失败,说明你的网卡不能和 IP协议栈进行通信Chapter4 Introduction to the Cisco IOSThe Cisco Router User InterfaceCisco Internetwork Operation System(IOS)是 Cisco 的 routers和 switch
2、es的内核Cisco Router IOSIOS的一些功能:1.运载网络协议和功能2.对产生高速流量的设备进行连接3.增加网络安全性4.提供网络的可扩展性来简易化网络的增长和冗余问题5.可靠的连接网络资源你可以通过以下方式进入 IOS:1.通过 router的 console口,用于本地2.通过 modem连接 auxiliary(Aux)口,用于远程3.通过 VTY线路来 telnetBringing Up a Router当启动 1个 router的时候,大致将分为以下几个阶段:1.开机自检(power-on self-test,POST)2.如果 1正常, 如果 IOS存在的话,将从它的
3、闪存(flash memory)查找和加载IOS到 RAM中(2500 系列不加载 RAM中,直接从闪存中运行).闪存是 1种电子可擦除只读存储器(electronically erasable programmable read-only memory,EEPROM)3.如果 1和 2正常,接下来它将在非易失性 RAM(NVRAM)中查找启动配置文件startup-config,假如没有找到任何启动配置文件,router 将进入到 setup模式Setup Modesetup模式可以对 router进行些配置,但是我们不推荐使用这个方法对 router进行配置.它分为 2种模式:1.Basi
4、c Management2.Extended Management在 setup模式中,代表默认设置,你可以使用 Ctrl+C随时退出 setup模式Command-Line Interface当问你是否进入 setup模式,选择 no,即进入命令行模式Logging into the Router从用户模式(user mode)进入到特权模式(exec mode),注意提示符的变化:RouterenableRouter#从特权模式退出到用户模式:Router#disableRouter退出 router命令行:在用户模式和特权模式下输入 logout,如下:Router#logoutRout
5、er con0 is now availablePress RETURN to get startedOverview of Router Modes配置 router,需要进入到 1个叫做配置模式的模式,在特权模式下输入configure terminal进入全局配置模式(global configuration mode),在这之下输入的命令叫做全局命令,一旦输入,将对整个 router产生影响.如下,注意提示符的变化:Router#configConfigruation from terminal,memory or networkterminal?(press Enter)Router
6、(config)#参数 terminal,memory和 network的区别:1.configure terminal:配置 router的 running-config,所谓 running-config即为当前运行在动态 RAM(DRAM)的配置文件2.configure memory: 配置 router的 startup-config,所谓 startup-config即为存储在 router的 NVRAM里的配置文件3.configure network:配置存储在 TFTP主机的配置文件Interfaces在全局配置模式下切换 router接口,输入 interface命令,?用
7、于提示可选参数,为如下:Router(config)#interface ?(略)Serial Serial前半部分为参数,后半部分为描述,接着输入 serial 0,进入 router接口配置模式,如下:Router(config)#interface serial 0Router(config-if)#Subinterfaces在 router的某个接口划分逻辑子接口(subinterface),输入命令进入子接口模式,如下,注意提示符:Router(config)#interface fa0/0.?FastEhernet interface numberRouter(config)#in
8、terface fa0/0.1Router(config-subif)#Line Command进入线路配置模式,注意提示符,如下:Router(config)#line console 0Router(config-line)#Routing Protocol Configurations给 router配置路由协议,比如 RIP,注意提示符,如下:Router(config)#router ripRouter(config-router)#从全局模式退出到特权模式可以使用快捷键 Ctrl+ZEditing and Help Features一些特写:1.在命令行下输入?,将得到该模式下可以
9、使用的命令列表以及其描述2.假如你不确定 1个命令是如何写的,比如你只记得是字母 c开头,你可以输入c加 1个?,将得到该模式下可以使用的所有命令:Router#c?clear clock configuration connect copyRouter#clock ?set Set the time and date3.假如你输入的命令不完整,将得到 1个错误提示:Imcomplete command,这样有助于分析命令哪出错了4.router支持命令缩写,比如 show可以缩写为 sh,sho,但是假如你像如下那样输入了不完整的缩写,将得到错误提示:Ambiguous commandRou
10、ter#sh te% Ambiguous command: sh teRouter#sh te?tech-support template terminal一切其他的快捷键:1.Ctrl+A:把光标快速移动到整行的最开始2.Ctrl+E:把光标快速移动到整行的最末尾3.Esc+B:后退 1个单词4.Ctrl+B:后退 1个字符5.Esc+F:前进 1个单词6.Ctrl+F:前进 1个字符7.Ctrl+D:删除单独 1个字符8.Backspace:删除单独 1个字符9.Ctrl+R:重新显示 1行10.Ctrl+U:擦除 1整行11.Ctrl+W:删除 1个单词12.Tab:自动补齐命令13.U
11、p arrow或者 Ctrl+P:显示之前最后输入过的命令14.Down arrow或者 Ctrl+N:显示之前刚刚输入过的命令其他的一些关于历史的命令:1.show history:显示最后输入的 10条命令,默认是 10条,可以修改该值2.terminal history size:修改显示最后输入过的的命令的数量,默认是 10条,最大是 256条3.show terminal:显示命令历史缓存大小,如下:Router#sh terminal(略)History is enabled,history size is 10(略)Router#terminal history size ?Si
12、ze of history bufferRouter#terminal history size 25Router#sh terminal(略)History is enabled,history size is 25(略)Gather Basic Routing Informationshow version:显示系统硬件的基本配置和软件版本,以及配置文件的名字和来源,还有启动镜象,最后是 configuration register的值Set Passwords:有 5种密码用于加密你的 Cisco router:1.控制口(console)2.辅助口(AUX)3.VTY4.enable
13、password5.enable secretEnable Passwordsenable password:给 console和 AUX口加密,防止未授权用户进入特权模式,但是密码是非加密形式enable secret:给 console和 AUX口加密,防止未授权用户进入特权模式,密码是加密形式,并且一旦起用了这个密码,将凌驾于 enable password之上,如果同时设置了 enable password和 enable secret的情况下,必须输入不同的密码,如下:Router(config)#enable secret 123Router(config)#enable secr
14、et 123The enable password you have chosen is the same as your enable secret.This is not recommended.Re-enter the enable passwordRouter(config)#enable secret 321如果 VTY线路的密码没有设置,你将无法使用 telnet来连上它Auxiliary Password配置 AUX密码:Router#conf tRouter(config)#line aux ?First line numberRouter(config)#line aux 0
15、Router(config-line)#loginRouter(config-line)#password 123Console Password配置 console密码以及一些辅助命令:Router#conf tRouter(config)#line console ?First line numberRouter(config)#line console 0Router(config-line)#loginRouter(config-line)#password 123Router(config-line)#exec-timeout ?Timeout in minutesRouter(co
16、nfig-line)#exec-timeout 0 ?Timeout in secondsRouter(config-line)#exec-timeout 0 0Router(config-line)#logging synchonousexec-timeout命令:如果 X分钟 X秒不活动的话将自动退出,默认是 10分钟,0 0代表永远不自动退出logging synchronous:光标跟随Telnet Password配置 VTY密码:如果你的 IOS不是企业版(Enterprise edition),默认你只能有5条 VTY线路,线路 0到 4.配置如下:Router(config-l
17、ine)#line vty 0 ?Last Line NumberRouter(config-line)#line vty 0 4Router(config-line)#loginRouter(config-line)#password 123刚才说过了,如果你的 VTY线路没有配置密码的话,你将无法 telnet连上它,它会报错:VTY 线路没有配置密码.但是你可以取消 VTY密码,这样就可以在没有密码的情况下进行 telnet,处于安全考虑,此方法不推荐,配置如下:Router(config-line)#line vty 0 4Router(config-line)#no loginEnc
18、ryption Your Passwords只有 enable secret是加密的,当你在特权模式下输入 sh running-config显示DRAM的配置文件时,其他密码将被罗列出来:Router#sh run(略)!enable secret jhdflkdfg$#sdfenable password 123!(略)对密码进行加密:在全局配置模式下使用 service password-encryption命令Bannersbanner类似标语,问候语.最常用的是 MOTD(message of the day),分界符用于分隔信息,但是分隔符不能出现在 MOTD信息中,如下:Rout
19、er(config)#banner motd #The Router is mine#Router(config)#Z(Ctrl+Z)Router#exitRouter con0 is now availablePress RETURN to get startedThe Router is mineRouter其他的 3种 banner:1.exec banner2.incoming banner3.login bannerRouter Interfaces配置 router的接口,一般命令模式采用:interface type number 的格式,比如:Router(config)#in
20、t ethernet 0但是 Cisco的 2600,3600,4000和 7000等系列采用了物理卡槽和模块化的端口机制.因此,命令变化为:interface type slot/port,比如:Router(config)#int fastethernet 0% Imcomplete commandRouter(config)#int fastethernet 0?/Router(config)#int fastethernet 0/?Fastethernet interface numberRouter(config)#int fastethernet 0/1配置连接器的介质类型,使用
21、media-type命令,不过这个一般是自动检测,如下:Router(config)#int fa 0/0Router(config-if)#media-type ?100BaseX Use RJ45 for -TX; SC F0 for FXMII Use MII connectorBring Up an Interface打开和关闭 1个接口,分别使用 shutdown和 no shutdown命令,当你关闭某个接口的时候,使用 sh interfaces命令可以查看接口状态,并且你将看到以下输出:Router#sh int e0Ethernet0 is administratively
22、down,line protocol is down(略)接口是关闭的,所以你要手动打开它,如下:Router#conf tRouter(config)#int e0Router(config-if)#no shutRouter(config-if)#ZRouter#sh int e0Ethernet is up,line protocol is up(略)Configuring an IP Address on an Interface给某个接口配置 IP地址,使用 ip address address mask命令,如下:Router(config)#int e0Router(config
23、-if)#ip address 172.16.10.2 255.255.255.0记得把接口打开:Router(config-if)#no shutRouter(config-if)#Z如果你需要在 1个接口添加第二个子网地址,在末尾使用 secondary参数,这将替换现有 IP地址,如下:Router(config)#int e0Router(config-if)#ip address 172.16.20.2 255.255.255.0 secondaryRouter(config-if)#Z来验证下:Router#sh run(略)!interface Ethernet0ip addre
24、ss 172.16.20.2 255.255.255.0 secondaryip address 172.16.10.2 255.255.255.0!Serial Interface CommandsSerial口一般是连接在 CSU/DSU等类型的提供时钟频率的设备上.但是,假如你在个实验环境里采用了背对背配置,那么 1端将作为 DCE设备提供时钟频率.默认 Cisco的 router都是 DTE,所以你必须让 1个 serial接口来提供时钟频率,采用的命令是:clock rate,如下:Router(config)#int s0Router(config-if)#clock rate ?
25、Speed (bits per second)1200(略)5600064000(略)Router(config-if)#clock rate 64000% Error: This commands applies only to DCE interfacesRouter(config-if)#int s1Router(config-if)#clock rate 64000确定 serial接口是否是 DCE线缆使用 sh controllers命令,如下:Routersh controllers s 0HD unit 0, idb=0x297DE8, driver structure at
26、0x29F3A0Buffer size 1524 HD unit 0, V.35 DCE cableCisco的 router的默认 serial连接带宽是 T-1(1.544Mbps).有的路由协议要以带宽做为度来进行衡量,所以,我们给它配置带宽,使用 bandwidth命令,注意参数单位是 kb,如下:Router(config-if)#bandwidth ?Bandwidth in kilobitsRouter(config-if)#bandwidth 64Hostnames给 router配置主机名,使用 hostname命令,这个是本地标志,不影响 router在Internet上的
27、工作,注意回车立即生效,如下:Router(config)#hostname NokoNoko(config)#hostname NocoNoco(config)#Descriptionsdescription命令:本地标志,可以给接口加描述,以便用于区分,如下:Noco(config)#int e0Noco(config-if)#description Sales LANNoco(config-if)#Z来验证下:Noco#sh int e0(略)Description: Sales LAN(略)Viewing and Saving Configurations将 running-confi
28、g(DRAM)的文件复制到 startup-config(NVRAM)里,使用 copy running-config startup-config命令:Noco#copy run start可以使用 erase startup-config命令删除 startup-config文件,如下:Noco#erase startup-config(略)Noco#sh start% Non-volatile configuration memory is not present假如在这个情况下在特权模式使用 reload命令重新启动 router,将进入 setup模式Verifying Your C
29、onfigurationping:采用了 ICMP echo requests和 repliestraceroute:使用 ICMP和 IP TTL来跟踪包所经过的路径Verifying with the show ip interface Commandshow ip interface:提供 router接口的层 3信息,包括:1.接口状态2.IP地址和掩码3.访问列表(access-list)信息4.一些其他的基本的 IP信息Using the show ip interface brief Commandshow ip interface brief:和 show ip interface类似,只是提供简洁点的总结信息Using the show controllers Commandsh controllers:显示物理接口的信息,还提供 serial口线缆信息,如下:Router#sh controllers serial 0/0(略)buffer size 1524 HD unit 0, V.35 DTE cable(略)Router#sh controllers serial 0/1(略)buffer size 1524 HD unit 1, V.35 DCE cable