路由器配置命令
- 格式:docx
- 大小:234.95 KB
- 文档页数:8
路由器配置命令大全路由器配置命令大全1.连接路由器1.1 使用串行控制台线连接路由器1.2 使用以太网接口连接路由器1.3 使用无线网络连接路由器2.基本配置2.1 配置主机名router(config)hostname [hostname]2.2 配置域名解析router(config)ip domn-name [domn-name] 2.3 配置密码router(config)enable secret [password] router(config)line console 0router(config-line)password [password] router(config-line)loginrouter(config-line)exitrouter(config)line vty 0 15router(config-line)password [password]router(config-line)loginrouter(config-line)exit2.4 配置管理IP地质router(config)interface [interface]router(config-if)ip address [ip-address] [subnet-mask]router(config-if)no shutdown3.网络协议配置3.1 配置静态路由router(config)ip route [destination-network] [subnet-mask] [next-hop]3.2 配置动态路由router(config)router [routing-protocol]router(config-router)network [network-address] [subnet-mask]3.3 配置带宽管理router(config)interface [interface]router(config-if)bandwidth [bandwidth-in-kbps]3.4 配置ACL(访问控制列表)router(config)access-list [access-list-number] [permit/deny] [source-network] [source-wildcard]4.NAT(网络地质转换)配置4.1 配置静态NATrouter(config)ip nat inside source static [inside-local-address] [outside-global-address]4.2 配置动态NATrouter(config)ip nat pool [pool-name] [start-ip-address] [end-ip-address] netmask [subnet-mask]router(config)ip nat inside source list [access-list] pool [pool-name]4.3 配置PAT(端口地质转换)router(config)interface [interface]router(config-if)ip nat insiderouter(config)interface [interface]router(config-if)ip nat outside5.VLAN(虚拟局域网)配置5.1 配置VLANrouter(config)vlan [vlan-id]router(config-vlan)name [vlan-name]5.2 配置接口VLANrouter(config)interface [interface]router(config-if)switchport mode accessrouter(config-if)switchport access vlan [vlan-id]5.3 配置Trunk接口router(config)interface [interface]router(config-if)switchport mode trunkrouter(config-if)switchport trunk allowed vlan [vlan-list]6.特定协议配置6.1 配置DHCP(动态主机配置协议)router(config)ip dhcp pool [pool-name]router(dhcp-config)network [network-address] [subnet-mask]router(dhcp-config)default-router [default-gateway]router(dhcp-config)dns-server [dns-server-ip]6.2 配置NTP(网络时间协议)router(config)ntp server [ntp-server-ip]router(config)ntp update-calendar6.3 配置SNMP(简单网络管理协议)router(config)snmp-server community [community-string] [ro/rw]router(config)snmp-server host [host-ip] [community-string]7.安全配置7.1 配置SSH(安全外壳协议)router(config)hostname [hostname]router(config)ip domn-name [domn-name]router(config)crypto key generate rsarouter(config)ip ssh version 2router(config)line vty 0 15router(config-line)transport input sshrouter(config-line)login localrouter(config-line)exit7.2 配置防火墙router(config)access-list [access-list-number] [permit/deny] [source-network] [source-wildcard] router(config)interface [interface]router(config-if)ip access-group [access-list-number] [in/out]附件:无法律名词及注释:- IP地质:Internet Protocol Address,互联网协议地质,用于标识网络上主机的唯一数字标识。
路由器配置命令1:连接路由器要配置路由器,首先需要通过网线将计算机与路由器连接。
确保电脑和路由器处于同一个局域网中,并且电脑的网卡设置为自动获取IP地址。
2:登录路由器打开计算机上的浏览器,输入路由器的管理IP地址(通常为192.168.1.1或192.168:0:1)并按回车键。
在弹出的登录界面中输入用户名和密码进行登录。
3:路由器基本设置在路由器的管理界面中,选择“基本设置”选项。
在此部分可以设置路由器的主机名、域名、时区以及路由器的管理密码等。
4:网络设置在管理界面中找到“网络设置”选项。
在此部分可以设置路由器的IP地址、子网掩码、网关和DNS信息等。
确保这些设置与网络环境相匹配。
5: WLAN设置如果路由器支持无线网络功能,可以在“WLAN设置”选项中进行相关设置。
包括无线网络的SSID名称、加密方式及密码等。
6:接口设置在管理界面中找到“接口设置”选项。
在此部分可以设置路由器的LAN口、WAN口、VLAN等接口相关的配置。
7:安全设置保护路由器的安全至关重要,可以在“安全设置”选项中进行相关的配置。
包括设置防火墙、启用ACL以及安全登录等选项。
8:服务设置在管理界面中找到“服务设置”选项。
在此部分可以设置路由器的DHCP服务、DNS代理、动态DNS等相关服务。
9: NAT设置如果需要进行网络地址转换(NAT)配置,可以在“NAT设置”选项中进行相关设置。
包括端口映射、虚拟服务器等。
10:路由设置在管理界面中找到“路由设置”选项。
在此部分可以进行路由设置相关的配置,如静态路由等。
附件:本文档不附带任何附件。
法律名词及注释:1: IP地址:互联网协议地址,用于标识计算机或网络设备在网络上的唯一标识。
2:子网掩码:用于将IP地址分成网络地址和主机地址两部分的32位二进制数。
3:网关:连接两个不同网络的设备,用于在网络之间进行中转和交换数据。
4: DNS:域名系统,将域名解析为IP地址的系统。
路由器配置命令大全视图模式介绍:普通视图router>特权视图router# /在普通模式下输入enable全局视图router(config)# /在特权模式下输入config t接口视图router(config-if)# /在全局模式下输入int 接口名称例如int s0或int e0路由协议视图router(config-route)# /在全局模式下输入router 动态路由协议名称1、基本配置:router>enable /进入特权模式router#conf t /进入全局配置模式router(config)# hostname xxx /设置设备名称就好像给我们的计算机起个名字router(config)#enable password /设置特权口令router(config)#no ip domain lookup /不允许路由器缺省使用DNS解析命令router(config)# Service password-encrypt /对所有在路由器上输入的口令进行暗文加密router(config)#line vty 0 4 /进入设置telnet服务模式router(config-line)#password xxx /设置telnet的密码router(config-line)#login /使能可以登陆router(config)#line con 0 /进入控制口的服务模式router(config-line)#password xxx /要设置console的密码router(config-line)#login /使能可以登陆2、接口配置:router(config)#int s0 /进入接口配置模式serial 0 端口配置(如果是模块化的路由器前面加上槽位编号,例如serial0/0 代表这个路由器的0槽位上的第一个接口)router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码router(config-if)#enca hdlc/ppp 捆绑链路协议hdlc 或者ppp 思科缺省串口封装的链路层协议是HDLC所以在show run配置的时候接口上的配置没有,如果要封装为别的链路层协议例如PPP/FR/X25就是看到接口下的enca ppp或者enca frrouter(config)#int loopback /建立环回口(逻辑接口)模拟不同的本机网段router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码给环回口在物理接口上配置了ip地址后用no shut启用这个物理接口反之可以用shutdown管理性的关闭接口3、路由配置:(1)静态路由router(config)#ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 下一条或自己的接口router(config)#ip route 0.0.0.0 0.0.0.0 s 0 添加缺省路由(2)动态路由rip协议router(config)#router rip /启动rip协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#version 2 转换为rip 2版本router(config-router)#no auto-summary /关闭自动汇总功能,rip V2才有作用router(config-router)# passive-int 接口名/启动本路由器的那个接口为被动接口router(config-router)# nei xxx.xxx.xxx.xxx /广播转单播报文,指定邻居的接ip,igrp协议-----内部网关路由协议(IGRP:Interior Gateway Routing Protocol)router(config)#router igrp xxx /启动igrp协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#variance xxx /调整倍数因子,使用不等价的负载均衡eigrp---Enhanced Interior Gateway Routing Protocol(增强网关内部路由线路协议)router(config)#router eigrp xxx /启动协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#variance xxx /调整倍数因子,使用不等价的负载均衡router(config-router)#no auto-summary /关闭自动汇总功能ospf协议----开放最短路径协议(OSPF)协议router(config)#router ospf xxx /启动协议启动一个OSPF协议进程router(config-router)#network xxx.xxx.xxx.xxx area xxx /宣告自己的接口或网段在ospf的区域中,可以把不同接口宣告在不同区域中router(config-router)#router-id xxx.xxx.xxx.xxx /配置路由的idrouter(config-router)#area xxx stub /配置xxx区域为末梢区域,加入这个区域的路由器全部要配置这个条命令router(config-router)#area xxx stub no-summary /配置xxx区域为完全末梢区域,只在ABR上配置router(config-router)#area xxx nssa /配置xxx区域为非纯末梢区域,加入这个区域的路由器全部要配置这个条命令router(config-router)#area xxx nssa no-summary /配置xxx区域为完全非纯末梢区域,只在ABR上配置,并发布缺省路由信息进入这个区域内的路由器4、保存当前修改/运行的配置:router#write /将RAM中的当前配置存储到NVRAM中,下次路由器启动就是执行保存的配置router#Copy running-config startup-config /命令与write效果一样5、一般的常用命令router(config-if)#exitrouter(config)#router(config-router)#exitrouter(config)#router(config-line)#exitrouter(config)#router(config)#exitrouter#exit命令/从接口、协议、line等视图模式下退回到全局配置模式,或从全局配置模式退回到特权模式router(config-if)#endrouter(config-router)#endrouter(config-line)#endrouter#end命令/从任何视图直接回到特权模式router#Logout /退出当前路由器登陆模式相对与windows的注销router#reload /重新启动路由器(热启动)冷启动就是关闭路由器再打开电源开关特权模式下:router#show ip route /查看当前的路由表router#clear ip route * /清楚当前的路由表router#show ip protocol /查看当前路由器运行的动态路由协议情况router#show ip int brief /查看当前的路由器的接口ip地址启用情况router#show running-config /查看当前运行配置router#show startup-config /查看启动配置router#debug ip pack /打开ip报文的调试router#terminal monitor /输出到终端上显示调试信息router#show ip eigrp neighbors /查看eigrp协议的邻居表router#show ip eigrp top //查看eigrp协议的拓朴表router#show ip eigrp interface /查看当前路由器运行eigrp协议的接口情况router#show ip ospf neighbor /查看当前路由器的ospf协议的邻居表router#show ip ospf interface /查看当前路由器运行ospf协议的接口情况router#clear ip ospf process /清楚当前路由器ospf协议的进程router#Show interfaces /显示设置在路由器和访问服务器上所有接口的统计信息. 显示路由器上配置的所有接口的状态router#Show interfaces serial /显示关于一个串口的信息router#Show ip interface /列出一个接口的IP信息和状态的小结, 列出接口的状态和全局参数。
路由器配置命令大全视图模式介绍:普通视图router>特权视图router# /在普通模式下输入enable全局视图router(config)# /在特权模式下输入config t接口视图router(config-if)# /在全局模式下输入int 接口名称例如int s0或int e0路由协议视图router(config-route)# /在全局模式下输入router 动态路由协议名称1、基本配置:router>enable /进入特权模式router#conf t /进入全局配置模式router(config)# hostname xxx /设置设备名称就好像给我们的计算机起个名字router(config)#enable password /设置特权口令router(config)#no ip domain lookup /不允许路由器缺省使用DNS解析命令router(config)# Service password-encrypt /对所有在路由器上输入的口令进行暗文加密router(config)#line vty 0 4 /进入设置telnet服务模式router(config-line)#password xxx /设置telnet的密码router(config-line)#login /使能可以登陆router(config)#line con 0 /进入控制口的服务模式router(config-line)#password xxx /要设置console的密码router(config-line)#login /使能可以登陆2、接口配置:router(config)#int s0 /进入接口配置模式serial 0 端口配置(如果是模块化的路由器前面加上槽位编号,例如serial0/0 代表这个路由器的0槽位上的第一个接口)router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码router(config-if)#enca hdlc/ppp 捆绑链路协议hdlc 或者ppp 思科缺省串口封装的链路层协议是HDLC所以在show run配置的时候接口上的配置没有,如果要封装为别的链路层协议例如PPP/FR/X25就是看到接口下的enca ppp或者enca frrouter(config)#int loopback /建立环回口(逻辑接口)模拟不同的本机网段router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码给环回口在物理接口上配置了ip地址后用no shut启用这个物理接口反之可以用shutdown管理性的关闭接口3、路由配置:(1)静态路由router(config)#ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 下一条或自己的接口router(config)#ip route 0.0.0.0 0.0.0.0 s 0 添加缺省路由(2)动态路由rip协议router(config)#router rip /启动rip协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#version 2 转换为rip 2版本router(config-router)#no auto-summary /关闭自动汇总功能,rip V2才有作用router(config-router)# passive-int 接口名/启动本路由器的那个接口为被动接口router(config-router)# nei xxx.xxx.xxx.xxx /广播转单播报文,指定邻居的接ip,igrp协议-----内部网关路由协议(IGRP:Interior Gateway Routing Protocol)router(config)#router igrp xxx /启动igrp协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#variance xxx /调整倍数因子,使用不等价的负载均衡eigrp---Enhanced Interior Gateway Routing Protocol(增强网关内部路由线路协议)router(config)#router eigrp xxx /启动协议router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段router(config-router)#variance xxx /调整倍数因子,使用不等价的负载均衡router(config-router)#no auto-summary /关闭自动汇总功能ospf协议----开放最短路径协议(OSPF)协议router(config)#router ospf xxx /启动协议启动一个OSPF协议进程router(config-router)#network xxx.xxx.xxx.xxx area xxx /宣告自己的接口或网段在ospf的区域中,可以把不同接口宣告在不同区域中router(config-router)#router-id xxx.xxx.xxx.xxx /配置路由的idrouter(config-router)#area xxx stub /配置xxx区域为末梢区域,加入这个区域的路由器全部要配置这个条命令router(config-router)#area xxx stub no-summary /配置xxx区域为完全末梢区域,只在ABR上配置router(config-router)#area xxx nssa /配置xxx区域为非纯末梢区域,加入这个区域的路由器全部要配置这个条命令router(config-router)#area xxx nssa no-summary /配置xxx区域为完全非纯末梢区域,只在ABR上配置,并发布缺省路由信息进入这个区域内的路由器4、保存当前修改/运行的配置:router#write /将RAM中的当前配置存储到NVRAM中,下次路由器启动就是执行保存的配置router#Copy running-config startup-config /命令与write效果一样5、一般的常用命令router(config-if)#exitrouter(config)#router(config-router)#exitrouter(config)#router(config-line)#exitrouter(config)#router(config)#exitrouter#exit命令/从接口、协议、line等视图模式下退回到全局配置模式,或从全局配置模式退回到特权模式router(config-if)#endrouter(config-router)#endrouter(config-line)#endrouter#end命令/从任何视图直接回到特权模式router#Logout /退出当前路由器登陆模式相对与windows的注销router#reload /重新启动路由器(热启动)冷启动就是关闭路由器再打开电源开关特权模式下:router#show ip route /查看当前的路由表router#clear ip route * /清楚当前的路由表router#show ip protocol /查看当前路由器运行的动态路由协议情况router#show ip int brief /查看当前的路由器的接口ip地址启用情况router#show running-config /查看当前运行配置router#show startup-config /查看启动配置router#debug ip pack /打开ip报文的调试router#terminal monitor /输出到终端上显示调试信息router#show ip eigrp neighbors /查看eigrp协议的邻居表router#show ip eigrp top //查看eigrp协议的拓朴表router#show ip eigrp interface /查看当前路由器运行eigrp协议的接口情况router#show ip ospf neighbor /查看当前路由器的ospf协议的邻居表router#show ip ospf interface /查看当前路由器运行ospf协议的接口情况router#clear ip ospf process /清楚当前路由器ospf协议的进程router#Show interfaces /显示设置在路由器和访问服务器上所有接口的统计信息. 显示路由器上配置的所有接口的状态router#Show interfaces serial /显示关于一个串口的信息router#Show ip interface /列出一个接口的IP信息和状态的小结, 列出接口的状态和全局参数。
路由器的配置命令总结配置路由器的命令可以分为以下几类:1. 基础配置命令:- configure terminal:进入全局配置模式- hostname:设置路由器的主机名- enable password:设置特权模式密码- line console 0:进入控制台线路配置模式- line vty 0 4:进入虚拟终端线路配置模式2. 接口配置命令:- interface interface_name:进入接口配置模式- ip address:配置接口IP地址- no shutdown:激活接口- description:为接口添加描述信息3. 路由配置命令:- ip route destination_network next_hop:配置静态路由- router rip:进入RIP路由器配置模式- network:指定RIP协议工作的网络地址4. 网络地址转换(NAT)配置命令:- ip nat inside source static inside_local_ip outside_global_ip:配置静态NAT- ip nat pool pool_name start_ip end_ip netmask:配置动态NAT 池5. 访问控制列表(ACL)配置命令:- access-list acl_number {deny | permit} source destination:创建ACL规则- interface interface_name:进入接口配置模式- ip access-group acl_number {in | out}:应用ACL到接口6. VLAN配置命令:- vlan vlan_id:创建VLAN- switchport mode {access | trunk}:配置接口模式7. 安全配置命令:- enable secret:设置特权模式加密密码- username username password password:创建本地用户8. 特定协议配置命令:- router ospf process_ID:进入OSPF路由器配置模式- network network_address wildcard_mask area area_number:配置OSPF网络- router bgp autonomous_system_number:进入BGP路由器配置模式- neighbor ip_address remote-as autonomous_system_number:配置BGP邻居以上是一些常见的路由器配置命令,不同型号和品牌的路由器可能会有一些差异,具体命令请参考相应的操作手册或文档。
路由器的配置模式●用户模式:Router>●特权模式:Router#●全局配置模式:Router(config)#●接口配置模式:Router(config-if)#●子接口配置模式:Router(config)#interface fa0/0.1Router(config-subif)#●Line模式:Router(config-line)#●路由模式:Router(config-router)#静态路由的配置Router A>enableRouter A#config terminalRouter A(config) #interface f0/0Router A(config-if) #ip address 192.168.2.2 255.255.255.0 Router A(config-if)#no shutdownRouter A(config-if)#exitRouter A(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1 默认路由的配置Router B>enableRouter B#config terminalRouter B(config) #interface f0/1Router B(config-if) #ip address 192.168.2.1 255.255.255.0Router B(config-if)#no shutdownRouter B(config-if)#exitRouter B(config) #interface f0/0Router B(config-if) #ip address 192.168.1.1 255.255.255.0Router B(config-if)#no shutdownRouter B(config-if)#exitRouter B(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2查看路由表RouterA#show ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setS 192.168.1.0/24 [1/0] via 192.168.2.1C 192.168.2.0/24 is directly connected, FastEthernet0/0RouterA#show ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setS 192.168.1.0/24 [1/0] via 192.168.2.1C 192.168.2.0/24 is directly connected, FastEthernet0/0配置路由器的控制台会话●配置控制台会话时间teacher(config)#line console 0teacher(config_line)#exec-timeout 0 0●配置控制台输出日志同步teacher(config)#line console 0teacher(config_line)#logging synchronous●配置禁用DNSteacher(config)#no ip domain-lookup路由器与交换机之间的单臂路由Router(config)# interface f0/0.1Router(config-subif)# encapsolution dot1q 1Router(config-subif)# ip address 192.168.1.1 255.255.255.0Router(config)# interface f0/0.2Router(config-subif)# encapsolution dot1q 2Router(config-subif)# ip address 192.168.2.1 255.255.255.0。
路由器的配置命令Router> (用户模式)Router>enable (进入特权模式)Router# (特权模式)Router#configure terminal (进入全局配置模式)Router(config)# (全局配置模式)Router(config)#hostname XXX (设置路由器主机名)Router(config)#enable password 123 (设置特权非密口令)Router(config)#enable secret 123 (设置特权加密口令)Router(config)#interface f0/6 (进入端口配置模式)Router(config-if)# (端口配置模式)Router(config)#line consode 0 (进入控制台端口)Router(config)#line vty 0 4 (进入虚拟终端配置模式)Router(config- line)# (虚拟终端配置模式)Router(config)#router rip (进入rip路由协议配置模式)Router(config-router) ( rip路由协议配置模式)Router(config-router)network 159.105.0.0 (设置参与RIP协议的网络地址,不支持可变长掩码,只有IP网络号)Router(config)#router ospf 63 (进入ospf路由协议配置模式)Router(config-router) # ( ospf路由协议配置模式)Router#write memory (保存配置到路由器的NVRAM中)Router#write network tftp (保存配置到TFTP服务器中)Router#write erase (删除路由配置)设置模式(setup) 刚出厂第一次建立配置文件RXBOOT模式密码丢失,进入可以恢复密码exit逐级退出end 或ctrl+z 直接退至特权模式基本命令:telnet ping trace showtelnet 可以由一台路由器登录到另一台路由器,最多支持5个连接。
路由器的配置命令1.路由器的模式Router>用户模式Router#特权模式Router(config)#配置模式Router(config-if)# 接口模式Router(config)#interface f0/0.1 进入子接口Router(config-subif)# 子接口模式Router(config-line)# 进行线模式Router(config-router)# 路由配置模式2.配置静态路由条目Router(config)# ip route 192.168.10.0 255.255.255.0 192.168.9.2 /192.168.10.0网段及掩码需要经过相邻路由器接口的IP地址3.配置默认路由Router B(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2 /所以外出的数据包如果找不到路由表目均找192.168.2.2接口。
4.配置路由控制台密码teacher(config)#line console 0teacher(config-line)#loginteacher(config-line)password ciscoteacher(config)#enable password cisco /配置特权模式密码teacher(config)#enable secret 1234 /配置加密保存的密码teacher(config)#service password-encryption / 对所有密码加密5.配置控制台会话时间teacher(config)#line console 0teacher(config-line)exec-timeout 0 06.配置控制台输出日志同步teacher(config)#line console 0teacher(config-line)#logging synchronous7.路由密码恢复(1)进入ROM Monitor 模式(2)修改配置寄存器的值,启动是绕过 startup-config文件rommon1>confreg ox2140rommon2>reset(3)用startup-config覆盖running-configROuter#copy starup-config running-config修改密码Router(config)#enable password cisco(4)修改配置寄存器的值Router(config)#config-register ox21028.动态路由配置(1)截断超时(2)打开接口(3)为接口设置IP 地址Router(config)#interface f0/0Router(config-if)#ip address 192.168.1.1Router(configif)#no shutdown(4)启动RIP进程,并宣告主网络号Router(config)#router ripRouter(config-router)#network 192.68.1.09.单臂路由配置Router(config)#interface f0/0.1router(config-subif)#encapsolution dotlq 1 :子接口封装dot1q针对的是VLAN1Router(config-subif)#ip address 192.168.1.1 255.255.255.0 :设置VLAN的网关地址Router(config)#interface f0/0.2router(config-subif)# encapsolution dotlq 2 子网接口封装do1q针对的是VLAN2 Router(config-subif)# 192.168.2.1 255.255.255.0 :设置VLAN2的网关地址路由器的操作系统,它是一个功能非常强大的系统,特别是在一些高档的路由器中,它具有相当丰富的操作命令,就像我们的DOS系统一样。
路由器的配置命令路由器的配置命令可以通过命令行界面(CLI)或者图形用户界面(GUI)来完成。
在命令行界面下,我们可以使用不同的命令,来对路由器进行配置和管理。
一、基本配置命令1. 进入特权模式在配置路由器之前,我们需要进入特权模式。
在命令行界面中输入以下命令,然后按下回车键即可:```enable```2. 进入全局配置模式进入特权模式之后,我们需要进入全局配置模式。
在全局配置模式下,可以对路由器进行各种配置。
在命令行界面中输入以下命令,按下回车键即可:```configure terminal```3. 配置主机名在全局配置模式下,我们可以为路由器配置一个唯一的主机名,以区分其他路由器。
在命令行界面中输入以下命令,按下回车键即可:```hostname Router1```这里的"Router1"可以替换为你想要的主机名。
4. 配置密码为了保护路由器的安全,我们可以为路由器配置密码。
以下是两种常用的密码配置命令:为特权模式设置密码:```enable secret password```为虚拟终端线路设置密码:```line vty 0 4password passwordlogin```这里的"password"可以替换为你想要的密码。
二、接口配置命令1. 进入接口配置模式在全局配置模式下,我们可以进入接口配置模式,对特定接口进行配置。
以下是两个常用的进入接口模式的命令:进入以太网接口配置模式:```interface Ethernet0/0```进入串口接口配置模式:```interface Serial0/0```2. 配置IP地址在接口配置模式下,我们可以为接口配置IP地址。
以下是一个配置IP地址的命令示例:```ip address 192.168.0.1 255.255.255.0```这里的"192.168.0.1"和"255.255.255.0"可以替换为你想要的IP地址和子网掩码。
1、路由器模式的转换:用户模式:router> 权限低,只能查看,输入“enable ”命令进入到特权模式特权模式:router# 权限高,输入“configure terminal”命令进入到全局模式全局模式(通配模式):router(config)#具体配置模式:router(config-if)#2、查看的命令:show ******router# show interface查看端口router# show interface Ethernet 0查看具体端口3、在路由器里有两种配置文件:1)running-config:当前运行的配置文件2)startup-config:启动配置文件查看配置文件:show running-configshow startup-configcopy running-config startup-config4、改路由器的名字:在全局模式下router(config)# hostname 路由器的名字5、设置路由器的登陆消息:在全局模式下router(config)# banner motd # 回车在此输入消息的内容#6、命令:Router(config)# ip address <ip address> <subnet mask>例如:配置以太网口//以Router1为例命令:R1# config tR1(config)#interface Ethernet 0R1(config-if)# ip address 192.168.1.1 255.255.255.0 //配置以太网口R1(config-if)# no shutdown // 启用该以太网口7、CDP协议:1)R1#show cdp interface //查看cdp接口2)R1#show cdp neighbors (details) //查看cdp邻居3)R1(config)#cdp run //激活cdp4)R1(config)#no cdp run //禁用cdp5)R1(config)#int e0 //进入到接口6)R1(config-if)#cdp enable //激活e0 的cdp7)R1(config-if)#no cdp enable //禁用e0 的cdp8、TFTP服务器的配置配置路由器:R1#config tR1(config)#int e0 //配置路由器的接口地址R1(config-if)#ip address 192.168.0.1 255.255.255.0R1(config-if)#no shutdownR1#ping 192.168.0.1配置PC:IP地址:192.168.0.2 网关:192.168.0.1测试:ping 192.168.0.1继续配置路由器:R1#copy running-config startup-configR1#copy startup-config tftpR1#erase startup-configR1# copy tftp startup-configR1#show startup-config9、路由器口令的设置:1)控制台口令:R1#config terminalR1(config)#line con 0R1(config-line)#loginR1(config-line)#password 密码2)enable 口令R1#config terminalR1(config)#enable password 密码3)远程登陆口令R1#config terminalR1(config)#line vty 0 4R1(config-line)#loginR1(config-line)#password 密码10、远程登陆:从一台计算机登陆到远端的另一台计算机,使用另一台计算机就像使用自己的计算机一样。
路由器的配置命令Router> (用户模式)Router>enable (进入特权模式)Router# (特权模式)Router#configure terminal (进入全局配置模式)Router(config)# (全局配置模式)Router(config)#hostname XXX (设置路由器主机名)Router(config)#enable password 123 (设置特权非密口令)Router(config)#enable secret 123 (设置特权加密口令)Router(config)#interface f0/6 (进入端口配置模式)Router(config-if)# (端口配置模式)Router(config)#line consode 0 (进入控制台端口)Router(config)#line vty 0 4 (进入虚拟终端配置模式)Router(config- line)# (虚拟终端配置模式)Router(config)#router rip (进入rip路由协议配置模式)Router(config-router) ( rip路由协议配置模式)Router(config-router)network (设置参与RIP协议的网络地址,不支持可变长掩码,只有IP网络号)Router(config)#router ospf 63 (进入ospf路由协议配置模式)Router(config-router) # ( ospf路由协议配置模式)Router#write memory (保存配置到路由器的NVRAM中)Router#write network tftp (保存配置到TFTP服务器中)Router#write erase (删除路由配置)设置模式(setup) 刚出厂第一次建立配置文件RXBOOT模式密码丢失,进入可以恢复密码exit逐级退出 end 或ctrl+z 直接退至特权模式基本命令:telnet ping trace showtelnet 可以由一台路由器登录到另一台路由器,最多支持5个连接。
ping 可以通过echo协议判断网络的连接情况。
trace 查询网络上数据传输流向的理想工具,测试转发分组的每一步,不可达***,退出Ctrl-Shinf-6show 查看了解路由器的各种信息。
R1>show flash 查看FLASHR1>show clock 查看时钟R1>show version 查看路由器软件、硬件版本在特权模式查看:R1#show configuration 查看路由器配置R1#show ip route 查看路由表R1#show ip protocols 查看路由协议的详细信息配置方式:1.使用控制端口(console)配置2.使用AUX端口连接一台Modem,通过拨号远程配置路由器.3.使用telnet远程登录到路由器上配置.4.使用TFTP服务,拷贝配件文件,修改配置文件的形式配置路由器5.通过网络管理协议SNMP修改路由器配置文件进行配置.远程虚拟终端配置:Router(config)#line vty 0 4 (进入虚拟终端配置模式)Router(config-line)#pasword 7 zzz123 (配置远程虚拟终端登录密码)Router(config-line)#路由器是互联不同的逻辑子网的设备,因此,他的每个接口都必须配置唯一的逻辑地址(IP),telnet登录时,可以使用任意一个处于激活状态的接品的IP,所以路由器不需要单独配置设备管理地址,远程登录时只需要密码即可.Router(config)#hostname R1 命名路由器R1R1(config)#Router(config)#enable secret xxx123 超级用户加密密码Router(config)#enable password 7 aaa123 超级用户明文密码Router#write memory 保存路由器配置到NVRAM中Router#write network tftp 保存路由器配置到TFTP中Router#write erase 清除路由器配置Router(config)#interface g0/8Router(config-if)#description To-shenzhen 描述,连接到深圳Router(config)#interface pos 3/0Router(config)#bandwidth 2500000 设置接口带宽,以kbps为单位Router(config)#interface g0/10Router(config-if)#ip address 配置接口IP地址Router(config)#interface g0/10Router(config-if)# no shutdown 开启接口标准以太网Router(config)#interface E0 进入标准以太网E接口Router(config-if)#description To-shanghai 连接到上海Router(config-if)#ip address 端口IP地址Router(config-if)#bandwidth 1000 带宽1GRouter(config-if)#exitRouter(config)#exitRouter#快速以太网Router(config)#inerface f2/1 进入快速以太网f接口Router(config-if)#description To-beijing 连接到北京Router(config-if)#ip address 端口IP地址Router(config-if)#bandwidth 2000000 带宽2GRouter(config-if)#duplex full 模式为全双工(full双工hull半双工auto自动)Router(config-if)#no ip directed-broadcast 禁止定向子网广播Router(config-if)#no ip proxy-arp 不作arp代理Router(config-if)#no shutdown 开启端口.Router(config-if)#exit 退出千兆以太网Router(config)#inerface g0/1 进入千兆以太网g接口Router(config-if)#description To-beijing 连接到北京Router(config-if)#ip address 端口IP地址Router(config-if)#bandwidth 2500000 带宽Router(config-if)#duplex full 模式为全双工(full双工hull半双工auto自动)Router(config-if)#no ip directed-broadcast 禁止定向子网广播Router(config-if)#no ip proxy-arp 不作arp代理Router(config-if)#no shutdown 开启端口.Router(config-if)#exit 退出配置POS接口Pos是packet over SONET/SDH的缩写,是一种利用SONT/SDH提供的高速传输通道直接传送IP数据包的技术,POS技术支持光纤介质,是一种高速先进的广域网连接技术.链路层协议主要有PPP和HDLC,目前可以提供155M,622M,和10G的传输速率接口.接口配置参数有接口带宽,接口地址,接口链路层协议,接口帧格式,接口CRC校验和flag(帧头中净负荷类型标志位),要注意接口参数的一致性.Router(config)#inerface POS3/0 进入快速以太网f接口Router(config-if)#description To-beijing 连接到北京Router(config-if)#bandwidth 带宽10GRouter(config-if)#ip address 端口IP地址Router(config-if)#crc 32 (可选的crc校验位是16和32)Router(config-if)#pos framing shd (可选的帧格式是shd和sonet)Router(config-if)#no ip directed-broadcast 禁止定向子网广播Router(config-if)#pos flag s1 s0 2 (注意:s1 s0 =00 表示sonet 帧数据, s1 s0 =10<十进制2> 表示sonet 帧数据) Router(config-if)#no ip proxy-arp 不作arp代理Router(config-if)#no shutdown 开启端口.Router(config-if)#exit 退出POS接口实例配置:(2011年9月网考试题)某园区网用的POS技术与Internet相连,POS接口的帧格式是SONET。
路由协议的选择方案是:园区网内部采用OSPF动态路由协议,园区网与Internet的连接使用静态路由。
图1 网络拓扑图问题:请阅读以下R3和R4的部分配置信息,并补充【6】到【10】空白处的配置命令或参数,按题目要求完成路由器的配置。
R3的POS接口、OSPF和缺省路由的配置信息Router-R3 #configure terminalRouter-R3 (config)#Router-R3 (config)#interface pos3/0Router-R3 (config-if)#description To InternetRouter-R3 (config-if)#bandwidth 2500000Router-R3 (config-if)#ip addressRouter-R3 (config-if)# 【6】 crc 32Router-R3 (config-if)#pos framing sonetRouter-R3 (config-if)#no ip directed-broadcastRouter-R3 (config-if)#pos flag 【7】s1s0 0Router-R3 (config-if)#no shutdownRouter-R3 (config-if)#exitRouter-R3 (config)#router ospf 65Router-R3 (config-router)#network 【8】 area 0Router-R3 (config-router)#redistribute connected metric-type 1 subnetsRouter-R3 (config-router)#area 0 range 【9】Router-R3 (config-router)#exitRouter-R3 (config)#ip route 0.0.0..0Router-R3 (config)#exitRouter-R3 #R4的静态路由配置信息Router-R4 #configure terminalRouter-R4 (config) #ip route 【10】解析:(config-if)# crc 32指的是配置CRC的校验功能;【7】S1 S0 0;解析:在pos flag的设置中,s1 s0=00(十进制0)表示是SONET帧的数据,s1 s0=10(十进制2)表示是SDH帧的数据。