路由器命令
- 格式:docx
- 大小:16.50 KB
- 文档页数:5
路由器配置命令大全路由器配置命令大全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,互联网协议地质,用于标识网络上主机的唯一数字标识。
路由器配置命令大全视图模式介绍:普通视图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邻居以上是一些常见的路由器配置命令,不同型号和品牌的路由器可能会有一些差异,具体命令请参考相应的操作手册或文档。
CCNA、NP路由器常用命令大全一、基本命令介绍1、Router >:用户模式(简单的查看和测试)2、#:特权模式(所有的查看和测试,以及保存)3、Configure terminal :全局配置模式Enable:特权模式4、Hostname cisco(主机名):更改名字5、No hostname cisco :删除以前操作6、Disable:从特权模式恢复用户模式7、Exit(退出)Write(保存)Copy run start (保存)8、Reload:重启设备9、图标含意:* :预备缺省路由C:直连路由S:静态路由10、Pint -t 202.102.1.2 :一直Ping指定IP11、No logging console :关闭Console信息12、Terminal monitor :远程登录下显示日志信息13、Traceroute 5.5.5.0 :查看到达网络所经过的路径二、基本命令配置1、Hostname R1:修改主机2、No ip domain lookup :关闭域名查找3、Line console 0 :进入Console控制台4、exec-timeout 0 0 :设置超时时间(永不超时0 0)5、Logging synnchronous :日志同步(命令不尾随日志显示)三、查看配置命令1、Show ip route :查看路由表2、Show ip ospf database :查看OSPF链路状态信息3、Show ip protocols :查看动态路由协议4、Show ip eigrp neighbors :查看EIGRP的邻居表5、Show ip eigrp topology :查看EIGRP的拓扑表6、Show ip route eigrp :只查看EIGRP路由条目7、Show ip eigrp neighbor detail :查看EIGRP的详细邻居表9、Show ip interface brief :查看所有接口信息8、Show ip ospf neighbor :查看OSPF邻居表9、Show ip ospf database router :查看OSPF一类LSA10、Show ip ospf database summary :查看OSPF三类LSA11、Show ip ospf database asbr-summary :查看OSPF四类LSA12、Show ip ospf int f0/0 :查看OSPF接口信息13、Show ip route ospf :只查看OSPF路由条目14、Show mac-address-table :查看交机的MAC地址15、Show running-config :查看当前所有配置16、Show access-list :查看ACL定义条目17、Show run |s r e :只查看EIGRP配置18、Show run |s r r :只查看RIP配置19、Show run |s r o :只查看OSPF配置20、Show run |s access-list :只查看ACL配置21、Show ip nat translations :查看NAT转换条目22、Show privilege :查看登录用户优先级23、Show arp :查看ARP表24、Show ip route 0.0.0.0 :查看指定路由条目25、Show frame-relay route :查看帧中继的转换条目26、Show frame-relay map :查看帧中继的映射表27、Show clock :查看设备时间28、Show run int s1/0 :只查看接口信息29、Show ip bgp neighbor :查看BGP邻居表30、Show ip bgp summary :查看BGP的概要信息31、Show ip bgp :查看BGP32、Show ip bgp 5.5.5.0 :查看BGP的指定路由条目33、Show ip route bgp :只查看BGP消息34、Show ipv6 int brief :查看IPv6接口配置35、Show ipv6 int f0/0 :查看IPv6指定接口配置36、Show cdp neighbor :查看CDP相连邻居信息37、Show cdp neighbor detail :查看CDP相连邻居之间详细信息38、Show ipv6 routers :查看IPv6路由通告39、Show ipv6 neighbor :查看IPv6邻居信息40、Show ipv6 bgp ipv6 unicast :查看IPv6中的BGP表41、Show run int tunnel 2 :查看Tunnel遂道接口信息42、Clear ip bgp * :硬重置BGP邻居表43、Clear ip bgp * in :软重置(发送路由刷新报文)44、Clear ip bgp 12.1.1.2 :硬重置(只重置一个邻居)45、Clear ipv6 neighbor :清空IPv6邻居表46、Clear ip bgp ipv6 unicast 100 in :软重置IPv6中BGP的邻居47、Clear ip bgp ipv6 unicast :硬重置IPv6中BGP的邻居48、Clear ip ospf process :重置OSPF进程49、Clear ip route * :清空路由表50、Ping 2.2.2.2 repeat 1 :Ping指定目的IP一次51、Ping 4.4.4.4 size 555(字节)52、Ping 2.2.2.2(目的IP) source 1.1.1.1(源IP)四、动态调试配置命令1、Debug ip nat :动态调试NAT转换条目2、Debug ppp authentication :动态调试PPP认证消息3、Debug ip policy :动态调试策略4、Debug ip bgp out :动态调试BGP路由条目5、Debug ip bgp updates :动态调试BGP更新条目6、Debug ip packet :动态调试IP协议包7、Debug ip v6 packet :动态调试IPv6协议包8、Debug ip bgp events :动态调试BGP事件9、Debug ipv6 nd :动态调试IPv6状态信息10、Debug ip packet detail :动态调试IP协议包详细信息11、Debug ipv6 packet detail :动态调试IPv6协议包详细信息12、Undebug all :关闭所有动态调试信息。
路由器配置命令(最全)路由器的配置命令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个连接。
路由器的配置命令路由器的配置命令可以通过命令行界面(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. switch配置命令(1)模式转换命令用户模式----特权模式,使用命令"enable"特权模式----全局配置模式,使用命令"configt"全局配置模式----接口模式,使用命令"interface+接口类型+接口号" 全局配置模式----线控模式,使用命令"line+接口类型+接口号" 注:用户模式:查看初始化的信息.特权模式:查看所有信息、调试、保存配置信息全局模式:配置所有信息、针对整个路由器或交换机的所有接口接口模式:针对某一个接口的配置线控模式:对路由器进行控制的接口配置(2)配置命令show running config 显示所有的配置show versin 显示版本号和寄存器值shut down 关闭接口no shutdown 打开接口ip add +ip地址配置IP地址secondary+IP地址为接口配置第二个IP地址show interface+接口类型+接口号查看接口管理性show controllers interface 查看接口是否有DCE电缆show history 查看历史记录show terminal 查看终端记录大小hostname+主机名配置路由器或交换机的标识config memory 修改保存在NVRAM中的启动配置exec timeout 0 0 设置控制台会话超时为0service password-encryptin 手工加密所有密码enable password +密码配置明文密码ena sec +密码配置密文密码line vty 0 4/15 进入telnet接口password +密码配置telnet密码line aux 0 进入AUX接口password +密码配置密码line con 0 进入CON接口password +密码配置密码bandwidth+数字配置带宽no ip address 删除已配置的IP地址show startup config 查看NVRAM中的配置信息copy run-config atartup config 保存信息到NVRAMwrite 保存信息到NVRAMerase startup-config 清除NVRAM中的配置信息show ip interface brief 查看接口的谪要信息banner motd # +信息+ # 配置路由器或交换机的描素信息description+信息配置接口听描素信息vlan database 进入VLAN数据库模式vlan +vlan号+ 名称创建VLANswitchport access vlan +vlan号为VLAN为配接口interface vlan +vlan号进入VLAN接口模式ip add +ip地址为VLAN配置管理IP地址vtp+service/tracsparent/client 配置SW的VTP工作模式vtp +domain+域名配置SW的VTP域名vtp +password +密码配置SW的密码switchport mode trunk 启用中继no vlan +vlan号删除VLANshow spamming-tree vlan +vlan号查看VLA怕生成树议2. 路由器配置命令ip route+非直连网段+子网掩码+下一跳地址配置静态/默认路由show ip route 查看路由表show protocols 显示出所有的被动路由协议和接口上哪些协议被设置show ip protocols 显示了被配置在路由器上的路由选择协议,同时给出了在路由选择协议中使用的定时器等信息router rip 激活RIP协议network +直连网段发布直连网段interface lookback 0 激活逻辑接口passive-interface +接口类型+接口号配置接口为被动模式debug ip +协议动态查看路由更新信息undebug all 关闭所有DEBUG信息router eigrp +as号激活EIGRP路由协议network +网段+子网掩码发布直连网段show ip eigrp neighbors 查看邻居表show ip eigrp topology 查看拓扑表show ip eigrp traffic 查看发送包数量router ospf +process-ID 激活OSPF协议network+直连网段+area+区域号发布直连网段show ip ospf 显示OSPF的进程号和ROUTER-IDencapsulation+封装格式更改封装格式no ip admain-lookup 关闭路由器的域名查找ip routing 在三层交换机上启用路由功能show user 查看SW的在线用户clear line +线路号清除线路3. 三层交换机配置命令配置一组二层端口configure terminal 进入配置状态nterface range {port-range} 进入组配置状态配置三层端口configureterminal 进入配置状态interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} |{port-channel port-channel-number} 进入端口配置状态no switchport 把物理端口变成三层口ip address ip_address subnet_mask 配置IP地址和掩码no shutdown 激活端口例:Switch(config)# interface gigabitethernet0/2Switch(config-if)# no switchportSwitch(config-if)# ip address 192.20.135.21 255.255.255.0Switch(config-if)# no shutdown配置VLANconfigure terminal 进入配置状态vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改。
路由器基本配置命令在网络通信中,路由器被广泛应用于连接不同的子网或网络,实现互联网的数据传输。
要使路由器正常工作,需要进行基本的配置。
本文将介绍一些常用的路由器基本配置命令,帮助读者快速了解和掌握路由器的配置过程。
一、登录路由器首先,我们需要登录路由器的管理界面,以便进行配置。
通常情况下,路由器的默认IP地址为192.168.1.1或192.168.0.1,读者可以根据自己的路由器型号来确认默认IP地址。
在浏览器的地址栏中输入路由器的IP地址,然后按下Enter键,会跳转到登录界面。
输入正确的用户名和密码,即可成功登录路由器。
二、配置路由器接口登录成功后,我们需要配置路由器的接口。
接口是路由器与其他网络设备连接的通道,通过配置接口,路由器才能正常传输数据。
以下是一些常用的配置命令:1. 接口查看命令```bashshow interfaces```该命令可以查看路由器上所有的接口信息,包括接口名称、状态、IP地址等。
通过查看接口信息,可以确认哪些接口是可用的,以及它们的IP地址等信息。
2. 配置接口IP地址命令```bashinterface fa0/0 # 进入接口配置模式ip address 192.168.1.1 255.255.255.0 # 配置接口IP地址及子网掩码no shutdown # 启用接口```以上命令将路由器的fa0/0接口配置为IP地址为192.168.1.1,子网掩码为255.255.255.0的接口,并启用该接口。
3. 配置默认网关命令```baship default-gateway 192.168.1.254```默认网关是路由器与其他网络设备进行通信的出口,需要将默认网关配置为正确的IP地址,使得数据能够正确地传输到其他网络设备。
三、配置路由接口配置完成后,我们需要配置路由,以指定数据包的转发路径。
以下是一些常用的配置命令:1. 配置静态路由命令```baship route 192.168.2.0 255.255.255.0 192.168.1.2```以上命令将192.168.2.0/24网段的数据包通过192.168.1.2这个地址进行转发。
路由器常用命令路由器是网络中非常重要的设备,它将数据包从一个网络转发到另一个网络,实现网络之间的连接。
为了正确配置和管理路由器,掌握常用的路由器命令是非常重要的。
本文将介绍一些常用的路由器命令,帮助读者更好地理解和应用路由器。
一、登录路由器要使用路由器命令,首先需要登录到路由器的控制台。
登录路由器的方式通常是通过终端模拟器(例如SecureCRT、Xshell等)使用Telnet、SSH等协议远程登录到路由器。
常用的登录命令如下:1. Telnet IP地址:使用Telnet协议登录到路由器,其中IP地址是路由器的IP地址。
2. SSH IP地址:使用SSH协议登录到路由器,其中IP地址是路由器的IP地址。
登录成功后,输入用户名和密码即可进入路由器的控制台。
二、显示路由器信息登录到路由器后,我们可以使用一些命令来查看和分析路由器的各种信息。
下面是一些常用的显示命令:1. show ip interface brief:显示所有接口的状态和IP地址。
2. show running-config:显示当前运行的配置信息。
3. show version:显示路由器的软件版本和硬件信息。
4. show ip route:显示路由表的内容。
5. show arp:显示路由器ARP缓存表的内容。
三、配置路由器配置路由器是使用路由器命令的重要部分。
通过配置路由器,我们可以为它指定IP地址、设置路由表、启用协议等。
下面是一些常用的配置命令:1. configure terminal:进入全局配置模式。
2. interface 接口名称:进入接口配置模式,例如interface GigabitEthernet0/0/0。
3. ip address IP地址掩码:为接口配置IP地址和子网掩码。
4. no shutdown:开启接口。
5. ip route 目标网络目标子网掩码下一跳地址:添加一条静态路由。
6. hostname 主机名:设置路由器的主机名。
4_路由器配置模式及常用命令路由器是一种网络设备,用于将数据包从源地址转发到目的地址。
它是互联网的关键组成部分之一,常用于连接不同网络之间的通信。
为了使路由器能够正常运行和提供所需的服务,我们需要对其进行配置。
接下来,我将介绍路由器的配置模式及常用命令。
1.配置模式路由器一般有两种主要的配置模式,分别是用户模式(User Exec Mode)和特权模式(Privileged Exec Mode),另外还有全局配置模式(Global Configuration Mode)。
用户模式:用户模式是路由器的初始模式。
在用户模式下,用户只能查看路由器的状态和一些基本信息,如路由器型号、软件版本等。
用户模式下的命令是有限的,只能进行少量简单的操作,不能对路由器进行配置。
特权模式:特权模式需要输入特定的密码,通过认证后进入。
特权模式下具有更多的权限,可以对路由器进行进一步的配置和管理。
在特权模式下,可以执行一些常用的命令,如查看路由表、查看接口状态等。
全局配置模式:全局配置模式是对路由器进行进一步配置的模式。
在全局配置模式下,可以配置路由器的各种参数和功能,如接口配置、路由配置等。
全局配置模式下的命令相对较多,需要注意参数的正确输入。
2.常用命令以下是一些常用的路由器配置命令:2.1基本操作命令- enable:进入特权模式。
- disable:退出特权模式,返回用户模式。
- exit:退出当前配置模式。
2.2接口配置命令- show interfaces:查看接口信息。
- interface interface-name:进入指定的接口配置模式。
- ip address ip-address subnet-mask:配置接口的IP地址和子网掩码。
- no shutdown:启用接口。
- shutdown:禁用接口。
2.3路由配置命令- show ip route:查看路由表。
- ip route destination-network subnet-mask next-hop:配置静态路由。
路由器命令[Quidway]display version ;显示版本信息[Quidway]display current-configuration ;显示当前配置[Quidway]display interfaces ;显示接口信息[Quidway]display ip route ;显示路由信息[Quidway]sysnameaabbcc ;更改主机名[Quidway]super passwrod 123456 ;设置口令[Quidway]interface serial0 ;进入接口[Quidway-serial0]ip address <ip><mask|mask_len>;配置端口IP地址[Quidway-serial0]undo shutdown ;激活端口[Quidway]link-protocol hdlc ;绑定hdlc协议[Quidway]user-interface vty 0 4[Quidway-ui-vty0-4]authentication-mode password[Quidway-ui-vty0-4]set authentication-mode password simple 222[Quidway-ui-vty0-4]user privilege level 3[Quidway-ui-vty0-4]quit[Quidway]debugging hdlc all serial0 ;显示所有信息[Quidway]debugging hdlc event serial0 ;调试事件信息[Quidway]debugging hdlc packet serial0 ;显示包的信息静态路由:[Quidway]ip route-static <ip><mask>{interfacenumber|nexthop}[value][reject|blackhole]例如:[Quidway]ip route-static 129.1.0.0 16 10.0.0.2[Quidway]ip route-static 129.1.0.0 255.255.0.0 10.0.0.2[Quidway]ip route-static 129.1.0.0 16 Serial 2[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.0.0.2动态路由:[Quidway]rip ;设置动态路由[Quidway]rip work ;设置工作允许[Quidway]rip input ;设置入口允许[Quidway]rip output ;设置出口允许[Quidway-rip]network 1.0.0.0 ;设置交换路由网络[Quidway-rip]network all ;设置与所有网络交换[Quidway-rip]peer ip-address ;[Quidway-rip]summary ;路由聚合[Quidway]rip version 1 ;设置工作在版本1 [Quidway]rip version 2 multicast ;设版本2,多播方式[Quidway-Ethernet0]rip split-horizon ;水平分隔[Quidway]router id A.B.C.D ;配置路由器的ID [Quidway]ospf enable ;启动OSPF协议[Quidway-ospf]import-route direct ;引入直联路由[Quidway-Serial0]ospf enable area <area_id> ;配置OSPF区域标准访问列表命令格式如下:acl<acl-number> [match-order config|auto] ;默认前者顺序匹配。
rule [normal|special]{permit|deny} [source source-addrsource-wildcard|any]例:[Quidway]acl 10[Quidway-acl-10]rule normal permit source 10.0.0.0 0.0.0.255[Quidway-acl-10]rule normal deny source any扩展访问控制列表配置命令配置TCP/UDP协议的扩展访问列表:rule {normal|special}{permit|deny}{tcp|udp}source {<ip wild>|any}destination <ip wild>|any}[operate]配置ICMP协议的扩展访问列表:rule {normal|special}{permit|deny}icmp source {<ip wild>|any]destination {<ip wild>|any][icmp-code] [logging]扩展访问控制列表操作符的含义equal portnumber ;等于greater-than portnumber ;大于less-than portnumber ;小于not-equal portnumber ;不等range portnumber1 portnumber2 ;区间扩展访问控制列表举例[Quidway]acl 101[Quidway-acl-101]rule deny souce any destination any[Quidway-acl-101]rule permit icmp source any destination any icmp-type echo [Quidway-acl-101]rule permit icmp source any destination any icmp-type echo-reply [Quidway]acl 102[Quidway-acl-102]rule permit ip source 10.0.0.1 0.0.0.0 destination 202.0.0.1 0.0.0.0 [Quidway-acl-102]rule deny ip source any destination any[Quidway]acl 103[Quidway-acl-103]rule permit tcp source any destination 10.0.0.1 0.0.0.0 destination-port equal ftp[Quidway-acl-103]rule permit tcp source any destination 10.0.0.2 0.0.0.0 destination-port equal www[Quidway]firewall enable[Quidway]firewall default permit|deny[Quidway]int e0[Quidway-Ethernet0]firewall packet-filter 101 inbound|outbound地址转换配置举例[Quidway]firewall enable[Quidway]firewall default permit[Quidway]acl 101 ;内部指定主机可以进入e0[Quidway-acl-101]rule deny ip source any destination any[Quidway-acl-101]rule permit ip source 129.38.1.1 0 destination any[Quidway-acl-101]rule permit ip source 129.38.1.2 0 destination any[Quidway-acl-101]rule permit ip source 129.38.1.3 0 destination any[Quidway-acl-101]rule permit ip source 129.38.1.4 0 destination any[Quidway-acl-101]quit[Quidway]int e0[Quidway-Ethernet0]firewall packet-filter 101 inbound[Quidway]acl 102 ;外部特定主机和大于1024端口的数据包允许进入S0[Quidway-acl-102]rule deny ip source any destination any[Quidway-acl-102]rule permit tcp source 202.39.2.3 0 destination 202.38.160.1 0 [Quidway-acl-102]rule permit tcp source any destination 202.38.160.1 0 destination-port great-than1024[Quidway-acl-102]quit[Quidway]int s0[Quidway-Serial0]firewall packet-filter 102 inbound ;设202.38.160.1是路由器出口IP。
[Quidway-Serial0]nat outbound 101 interface ;是Easy ip,将acl 101允许的IP从本接口出时变换源地址。
内部服务器地址转换配置命令(静态nat):nat server global <ip> [port] inside <ip> port [protocol] ;global_port不写时使用inside_port[Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.1 ftp tcp[Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.2 telnet tcp [Quidway-Serial0]nat server global 202.38.160.1 inside 129.38.1.3 www tcp设有公网IP:202.38.160.101~202.38.160.103 可以使用。
;对外访问(原例题) [Quidway]nat address-group 202.38.160.101 202.38.160.103 pool1 ;建立地址池[Quidway]acl 1[Quidway-acl-1]rule permit source 10.110.10.0 0.0.0.255 ;指定允许的内部网络[Quidway-acl-1]rule deny source any[Quidway-acl-1]int serial 0[Quidway-Serial0]nat outbound 1 address-group pool1 ;在s0口从地址池取出IP 对外访问[Quidway-Serial0]nat server global 202.38.160.101 inside 10.110.10.1 ftp tcp [Quidway-Serial0]nat server global 202.38.160.102 inside 10.110.10.2 www tcp [Quidway-Serial0]nat server global 202.38.160.102 8080 inside 10.110.10.3 www tcp [Quidway-Serial0]nat server global 202.38.160.103 inside 10.110.10.4 smtpudpPPP设置:[Quidway-s0]link-protocol ppp ;默认的协议PPP验证:主验方:pap|chap[Quidway]local-user q2 password {simple|cipher} hello ;路由器1[Quidway]interface serial 0[Quidway-serial0]ppp authentication-mode {pap|chap}[Quidway-serial0]ppp chap user q1 ;pap时,没有此句pap被验方:[Quidway]interface serial 0 ;路由器2[Quidway-serial0]ppp pap local-user q2 password {simple|cipher} hellochap被验方:[Quidway]interface serial 0 ;路由器2 [Quidway-serial0]ppp chap user q2 ;自己路由器名[Quidway-serial0]local-user q1 password {simple|cipher} hello ;对方路由器名帧中继frame-relay (二分册6-61)[q1]fr switching[q1]int s1[q1-Serial1]ip address 192.168.34.51 255.255.255.0[q1-Serial1]link-protocol fr ;封装帧中继协议[q1-Serial1]fr interface-type dce[q1-Serial1]frdlci 100[q1-Serial1]frinarp[q1-Serial1]fr map ip 192.168.34.52 dlci 100[q2]int s1[q2-Serial1]ip address 192.168.34.52 255.255.255.0[q2-Serial1]link-protocol fr[q2-Serial1]fr interface-type dte[q2-Serial1]frdlci 100[q2-Serial1]frinarp[q2-Serial1]fr map ip 192.168.34.51 dlci 100帧中继监测[q1]display frlmi-info[]interface type number][q1]display fr map[q1]display frpvc-info[serial interface-number][dlcidlci-number][q1]display frdlci-switch[q1]display fr interface[q1]reset frinarp-info[q1]debugging fr all[interface type number][q1]debugging frarp[interface type number][q1]debugging fr event[interface type number][q1]debugging frlmi[interface type number]启动ftp服务:[Quidway]local-user ftp password {simple|cipher} aaa service-type ftp [Quidway]ftp server enable。