Cisco 路由器常用命令

Cisco 路由器常用命令

1 Exec commands:

<1-99> 恢復一個會話
bfe 手工應急模式設置
clear 復位功能
clock 管理系統時鐘
configure 進入設置模式
connect 打開一個終端
copy 從tftp服務器拷貝設置文件或把設置文件拷貝到tftp服務器上
debug 調試功能
disable 退出優先命令狀態
disconnect 斷開一個網絡連接
enable 進入優先命令狀態
erase 擦除快閃內存
exit 退出exce模式
help 交互幫助系統的描述
lat 打開一個本地傳輸連接
lock 鎖定終端
login 以一個用戶名登錄
logout 退出終端
mbranch 向樹形下端分支跟蹤多路由廣播
mrbranch 向樹形上端分支跟蹤反向多路由廣播
name-connection 給一個存在的網絡連接命名
no 關閉調試功能
pad 打開X.29 PAD連接
ping 發送回顯信息
ppp 開始點到點的連接協議
reload 停機並執行冷啓動
resume 恢復一個活動的網絡連接
rlogin 打開遠程註冊連接
rsh 執行一個遠端命令
send 發送信息到另外的終端行
setup 運行setup命令
show 顯示正在運行系統信息
slip 開始SLIP協議
start-chat 在命令行上執行對話描述
systat 顯示終端行的信息
telnet 遠程登錄
terminal 終端行參數
test 測試子系統內存和端口
tn3270 打開一個tin3270連接
trace 跟蹤路由到目的地
undebug 退出調試功能
verify 驗證檢查閃爍文件的總數
where 顯示活動的連接
which-route 執行OSI路由表查找並顯示結果
write 把正在運行的設置寫入內存、網絡、或終端
x3 在PAD上設置X.3參數
xremote 進入xremote模式

2 #show ?

access-expression 顯示訪問控制表達式
access-lists 顯示訪問控制表
apollo Apollo 網絡信息
appletalk Apple Talk 信息
arap 顯示Appletalk 遠端通道統計
arp 地址解析協議表
async 訪問路由接口的終端行上的信息
bridge 前向網絡數據庫
buffers 緩衝池統計
clns CLNS網絡信息
clock 顯示系統時鐘
cmns 連接模式網絡服務信息
compress 顯示壓縮狀態
configuration 非易失性內存的內容
controllers 端口控制狀態
debugging 調試選項狀態
decnet DEC網絡信息
dialer 撥號參數和統計
dnsix 顯示Dnsix/DMPP信息
entry 排隊終端入口
extended 擴展端口信息
flash 系統閃爍信息
flh-log 閃爍裝載幫助日誌緩衝區
frame-relay 幀中繼信息
history 顯示對話層歷史命令
hosts IP域名,查找方式,名字服務,主機表
interfaces 端口狀態和設置
ip IP信息
ipx Novell IPX信息
isis IS-IS路由信息
keymap 終端鍵盤映射
lat DEC LAT信息
line 終端行信息
llc2 IBM LLC2 環路信息
lnm IBM 局網管理
local-ack 本地認知虛環路
memory 內存統計
netbios-cache NetBios命名緩衝存貯器內存
node 顯示已知LAT節點
ntp 網絡時間協議
processes 活動進程統計
protocols 活動網絡路由協議
queue 顯示隊列內容
queueing 顯示隊列設置
registry 功能註冊信息
rhosts 遠程主機文件
rif RIF存貯器入口
route-map 路由器信息
sdlle 顯示sdlc-llc2轉換信息
services 已知LAT服務
sessions 遠程連接信息
smds SMDS信息
source-bridge 源網橋參數和統計
spanning-tree 跨越樹形拓樸
stacks 進程堆棧應用
standby 熱支持協議信息
stun STUN狀態和設置
subsystem 顯示子系統
tcp TCP連接狀態
terminal 顯示終端設置
tn3270 TN3270 設置
translate 協議轉換信息
ttycap 終端容易表
users 顯示終端行的信息
version 系統硬、軟件狀態
vines VINES信息
whoami 當前終端行信息
x25 X.25信息
xns XNS信息
xermote Xremote統計

3 #config ?

Memory 從非易失性內存設置
Network 從TFTP網絡主機設置
Overwrite-network 從TFTP網絡主機設置覆蓋非易失性內存
Terminal 從終端設置

4 Configure commads:

Access-list 增加一個訪問控制域
Apollo Apollo全局設置命令
appletalk Appletalk 全局設置命令
arap Appletalk遠程進出協議
arp 設置一個靜態ARP入口
async-bootp 修改系統啓動參數
autonomous-system 本地所擁有的特殊自治系統成員
banner 定義註冊顯示信息
boot 修改系統啓動時參數
bridge 透明網橋
buffers 調整系統緩衝池參數
busy-message 定義當連接主機失敗時顯示信息
chat-s cript 定義一個調制解調器對話文本
clns 全局CLNS設置子命令
clock 設置時間時鐘
config-register 定義設置寄存器
decnet 全局DEC網絡設置子命令
default-value 缺省字符位值
dialer-list 創建一個撥號清單入口
dnsix-nat 爲審計提供DMDM服務
enable 修改優先命令口令
end 從設置模式退出
exit 從設置模式退出
frame-relay 全局幀中繼設置命令
help 交互幫助系統的描述
hostname 設置系統網絡名
iterface 選擇設置的端口
ip 全局地址設置子命令
ipx Novell/IPX全局設置命令
keymap 定義一個新的鍵盤映射
lat DEC本地傳輸協議
line 設置終端行
lnm IBM局網管理
locaddr-priority-list 在LU地址上建立優先隊列
logging 修改註冊(設備)信息
login-string 定義主機指定的註冊字符串
map-class 設置靜態表類
map-list 設置靜態表清單
menu 定義用戶接口菜單
mop 設置DEC MOP服務器
netbios NETBIOS通道控制過濾
no 否定一個命令或改爲缺省設置
ntp 設置NTP
priority-list 建立特權列表
prompt 設置系統提示符
queue-list 建立常規隊列列表
rcmd 遠程命令設置命令
rcp-enable 打開Rep服務
rif 源路由進程
router-map 建立路由表或進入路由表命令模式
router 打開一個路由進程
rsh-enable 打開一個RSH服務
sap-priority-list 在SAP或MAC地址上建立一個優先隊列
service 修改網絡基本服務
snmp-server 修改SNMP參數
state-machine 定義一個TCP分配狀態的機器
stun STUN全局設置命令
tacacs-server 修改TACACS隊列參數
terminal-queue 終端隊列命令
tftp-server 爲網絡裝載請求提供TFTP服務
tn3270 tn3270設置命令
translate 解釋全局設置命令
username 建立一個用戶名及其權限
vines VINES全局設置命令
x25 X.25 的第三級
x29 X.29 命令
xns XNS 全局設置命令
xremote 設置Xremote

5 (config)#ip

Global IP configuration subcommands:
Accounting-list 選擇保存IP記帳信息的主機
Accounting-threshold 設置記帳入口的最大數
accounting-transits 設置通過入口的最大數
alias TCP端口的IP地址取別名
as-path BGP自治系統路徑過濾
cache-invalidate-delay 延遲IP路由存貯池的無效
classless 跟隨無類前向路由規則
default-network 標誌網絡作爲缺省網關候選
default-gateway 指定缺省網(如果沒有路由IP)
domain-list 完成無資格主機的域名
domain-lookup 打開IP域名服務系統主機轉換
domain-name 定義缺省域名
forward-protocol 控制前向的、物理的、直接的IP廣播
host 爲IP主機表增加一個入口
host-routing 打開基於主機的路由(代理ARP和再定向)
hp-host 打開HP代理探測服務
mobile-host 移動主機數據庫
multicast-routing 打開前向IP
name-server 指定所用名字服務器的地址
ospf-name-lookup 把OSPF路由作爲DNS名顯示
pim PIM 全局命令
route 建立靜態路由
routing 打開IP路由
security 指定系統安全信息
source-route 根據源路由頭的選擇處理包
subnet-zero 允許子網0子網
tcp 全局TCP參數

路由器在計算機網絡中有着舉足輕重的地位,是計算機網絡的橋樑。通過它不僅可以連通不同的網絡,還能選擇數據傳送的路徑,並能阻隔非法的訪問。
  路由器的配置對初學者來說,並不是件十分容易的事。現將路由器的一般配置和簡單調試介紹給大家,供朋友們在配置路由器時參考,本文以Cisco2501爲例。
  Cisco2501有一個以太網口(AUI)、一個Console口(RJ45)、一個AUX口(RJ45)和兩個同步串口,支持DTE和DCE設備,支持 EIA/TIA-232、 EIA/TIA-449、 V.35 、X.25和EIA-530接口。
  一.配置
  1.配置以太網端口
  # conf t(從終端配置路由器)
  # int e0(指定E0口)
  # ip addr ABCD XXXX(ABCD 爲以太網地址,XXXX爲子網掩碼)
  # ip addr ABCD XXXX secondary(E0口同時支持兩個地址類型。如果第一個爲 A類地址,則第二個爲B或C類地址)
  # no shutdown(激活E0口)
  # exit
  完成以上配置後,用ping命令檢查E0口是否正常。如果不正常,一般是因爲沒有激活該端口,初學者往往容易忽視。用no shutdown命令激活E0口即可。
  2.X.25的配置
  # conf t
  # int S0(指定S0口)
  # ip addr ABCD XXXX(ABCD 爲以太網S0 的IP地址,XXXX爲子網掩碼)
  # encap X25-ABC(封裝X.25協議。ABC指定X.25爲DTE或DCE操作,缺省爲DTE)
  # x25 addr ABCD(ABCD爲S0的X.25端口地址,由郵電局提供)
  # x25 map ip ABCD XXXX br(映射的X.25地址。ABCD爲對方路由器(如:S0)的IP 地址,XXXX爲對方路由器(如:S0)的X.25端口地址)
  # x25 htc X(配置最高雙向通道數。X的取值範圍1-4095,要根據 郵電局實際提供的數字配置)
  # x25 nvc X(配置虛電路數,X不可超過郵電局實際提供的數否則將影響數據的正常傳輸)
  # exit
  S0端口配置完成後,用no shutdown命令激活E0口。如果ping S0端口正常,ping 映射的X.25 IP地址即對方路由器端口IP地址不通,則可能是以下幾種情況引起的:1)本機X.25地址配置錯誤,重新與郵局覈對(X.25地址長度爲13位);2)本機映射IP地址或X.25地址配置錯誤,重新配置正確;3)對方IP地址或X.25地址配置錯誤;4)本機或對方路由配置錯誤。
  能夠與對方通訊,但有丟包現象。出現這種情況,一般有以下幾種可能:1)線路情況不好,或網卡、RJ45插頭接觸不良;2)x25 htc最高雙向通道數X的取值範圍和x25nvc 虛電路數X超出郵電局實際提供的數字。最高雙向通道數和虛電路數這兩個值越大越好,但絕對不能超出郵電局實際提供的數字,否則就會出現丟包現象。
  3.專線的配置
  # conf t
  # int S2(指定S2口)
  # ip addr ABCD XXXX(ABCD 爲S2 的IP地址,XXXX爲子網掩碼)
  # exit
  專線口配置完成後,用no shutdown命令激活S2口即可。
  4.幀中繼的配置
  # conf t
  # int s0
  # ip addr ABCD XXXX (ABCD 爲S0 的IP地址,XXXX爲子網掩碼)
  # encap frante_relay (封裝frante_relay 協議)
  # no nrzi_encoding (NRZI=NO)
  # frame_relay lmi_type q933a (LMI使用Q933A標準.LMI(Local management Interface) 有3種:ANSI:T1.617、CCITTY:Q933A和Cisco特有的標準)
  # fram-relay intf-typ ABC(ABC爲幀中繼設備類型,它們分別是DTE設備、DCE交換機或NNI(網絡接點接口)支持)
  # frame_relay interface_dlci 110 br(配置DLCI(數據鏈路連接標識符))
  # frame-relay map ip ABCD XXXX broadcast (建立幀中繼映射。ABCD爲對方IP地址,XXXX爲本地DLCI號,broadcast允許廣播向前轉發或更新路由)
  # no shutdown (激活本端口)
  # exit
  幀中繼S0端口配置完成後,用ping命令檢查S0口。如果不正常,通常是因爲沒有激活該端口,用no shutdown命令激活S0口即可。如果ping S0端口正常,ping 映射的IP地址不正常,則可能是幀中繼交換機或對方配置錯誤,需要綜合排查。
  5.配置同步/異步口(適用於2522)
  # conf t
  # int s2
  # ph asyn (配置S2爲異步口)
  # ph sync (配置S2爲同步口)
  6.動態路由的配置
  # conf t
  # router eigrp 20 (使用EIGRP路由協議。常用的路由協議有RIP、IGRP、IS-IS等)
  # passive-interface serial0 (若S0與X.25相連,則輸入本條指令)
  # passive-interface serial1 (若S1與X.25相連,則輸入本條指令)
  # network ABCD (ABCD爲本機的以太網地址)
  # network XXXX (XXXX爲S0的IP地址)
  # no auto-summary
  # exit
  7.靜態路由的配置
  # ip router ABCD XXXX YYYY 90 (ABCD爲對方路由器的以太網地址,XXXX 爲子網掩碼,YYYY爲對方對應的廣域網端口地址)
  # dialer-list 1 protocol ip permail
  二. 綜合調試
  當路由器全部配置完畢後,可進行一次綜合調試。
  1.首先將路由器的以太網口和所有要使用的串口都激活。方法是進入該口,執行no shutdown。
  2.將和路由器相連的主機加上缺省路由(中心路由器的以太地址)。方法是在Unix系統的超級用戶下執行:router add default XXXX 1(XXXX爲路由器的E0口地址)。每臺主機都要加缺省路由,否則,將不能正常通訊。
  3.ping本機的路由器以太網口,若不通,可能以太網口沒有激活或不在一個網段上。ping廣域網口,若不通,則沒有加缺省路由。ping對方廣域網口,若不通,路由器配置錯誤。ping主機以太網口,若不通,對方主機沒有加缺省路由。
  4.在專線卡X.25主機上加網關(靜態路由)。方法是在Unix系統的超級用戶下執行:router add X.X.X.X Y.Y.Y.Y 1(X.X.X.X爲對方以太網地址,Y.Y.Y.Y爲對方廣域網地址)。
  5.使用Tracert對路由進行跟蹤,以確定不通網段

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)/* 在串口中配置 */&n! bsp;

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 ad dress 網絡地址 掩碼

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 目標網? 綰?nbsp;掩碼 端口號

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 ro! ute x.121地址 接口 x.121映射地址

2) FrameRelay

Frame-relay local-dlci IP網絡號

Frame-relay map 協議地址

Frame-relay lmi-type ansi


路由器命令
router>         用戶模式
1:進入特權模式  enable
router > enable
router #

2:進入全局配置模式  configure terminal
router > enable
router #c onfigure terminal
router (conf)#

3:交換機命名 hostname routera    以routerA爲例
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routera (conf)#

4:配置使能口令  enable password cisco    以cisco爲例
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routerA (conf)# enable password cisco

5:配置使能密碼  enable secret ciscolab    以cicsolab爲例
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routerA (conf)# enable secret ciscolab

6:進入路由器某一端口 interface fastehernet 0/17           以17端口爲例
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routerA (conf)# interface fastehernet 0/17
routerA (conf-if)#
進入路由器的某一子端口 interface fastethernet 0/17.1       以17端口的1子端口爲例
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routerA (conf)# interface fastehernet 0/17.1

7:設置端口ip地址信息
router > enable
router #c onfigure terminal
router(conf)#hostname routerA
routerA(conf)# interface fastehernet  0/17                以17端口爲例
routerA (conf-if)#ip address 192.168.1.1 255.255.255.0      配置交換機端口ip和子網掩碼
routerA (conf-if)#no shut                              是配置處於運行中
routerA (conf-if)#exit

8:查看命令  show
router > enable
router # show version  察看系統中的所有版本信息
show interface vlan 1  查看交換機有關ip 協議的配置信息
show running-configure 查看交換機當前起作用的配置信息
show interface fastethernet 0/1  察看交換機1接口具體配置和統計信息
show mac-address-table        查看mac地址表
show mac-address-table aging-time  查看mac地址表自動老化時間
       show controllers serial + 編號    查看串口類型
       show ip router      查看路由器的路由表

9:cdp相關命令
router > enable
router # show cdp    查看設備的cdp全局配置信息
show cdp interface fastethernet 0/17    查看17端口的cdp配置信息
show cdp traffic     查看有關cdp包的統計信息
show cdp nerghbors  列出與設備相連的cisco設備

10:csico2600的密碼恢復
重新啓動路由器,在啓動過程中按下win+break鍵,使路由器進入rom monitor
在提示符下輸入命令修改配置寄存器的值,然後重新啓動路由器
remmon1>confreg 0x2142
remmon2>reset
重新啓動路由器後進入setup模式,選擇“no”,退回到exec模式,此時路由器原有的配置仍然保存在startup-config中,爲使路由器恢復密碼後配置不變把startup-config中配置保存到running-config中,然後重新設置enable密碼,並把配置寄存器改回0x2102:
router>enable
router#copy startup-config running-config
router#c onfigure terminal
router(conf)#enable password cisco
router(conf)#c onfig-register 0x2102
保存當前配置到startup-config , 重新啓動路由器。
router #copy running-config startup-config
router #reload

11:路由器telnet遠程登錄設置:
router>en
router #c onfigure terminal
router (conf)#hostname routerA
routerA (conf)#enable password cisco          以cisco爲特權模式密碼
routerA (conf)#interface fastethernet 0/1        以17端口爲telnet遠程登錄端口
routerA (conf-if)#ip address 192.168.1.1 255.255.255.0
routerA (conf-if)#no shut
routerA (conf-if)#exit
routerA (conf)line vty 0 4                   設置0-4 個用戶可以telnet遠程登陸
routerA (conf-line)#login
routerA (conf-line)#password edge            以edge爲遠程登錄的用戶密碼
主機設置:
ip         192.168.1.2               主機的ip必須和交換機端口的地址在同一網絡段
netmask    255.255.255.0
gate-way   192.168.1.1               網關地址是交換機端口地址
運行:
telnet 192.168.1.1
進入telnet遠程登錄界面
password : edge               
routera>en
password: cisco
routera#

12:配置路由器的標識   banner $……………$
在全局配置的模式下利用“banner”命令可以配置路由器的提示信息,所有連接到路由器的終端都會收到。
router>en
router #c onfigure terminal
router (conf)#hostname routerA
routerA(conf)#banner motd $This is aptech company’  router ! Please don’t change the configuration without permission!$

13:配置接口標識     description ………
接口標識用於區分路由器的各個接口。
router>en
router #c onfigure terminal
router (conf)#hostname routerA
routerA(conf)#interface fastethernet 0/1      以0/1 接口爲例
routerA(conf-if)# description this is a fast Ethernet port used to connecting the company’s intranet!       

14:配置超時 
超時適用於設置在多長時間沒有對console進行配置,自動返回exec會話時間。默認爲10分鐘。
router>en
router #c onfigure terminal
router (conf)#hostname routerA
routerA(conf)#line console 0
routerA(conf-if)#e xec-timeout 0 0             第一個“0”代表分鐘,第二個“0”代表秒

15:配置串口參數 
兩臺路由器通過串口連接需要一個做爲DTE,一個做爲DCE。DCE設備要向DTE設備提供時鐘頻率和帶寬。
DCE配置:
router>en
router #c onfigure terminal
router (conf)#hostname routerA
routerA(conf)#interface serial 0/0
routerA(conf_if)#clock rate 64000           提供時鐘頻率爲64000
routerA(conf_if)#bandwidth 64             提供帶寬爲64
DTE配置:路由器串口配置ip地址
router>en
router #c onfigure terminal
router (conf)#hostname routerB
routerB(conf)#interface serial 0/0
routerB(conf_if)#ip address 192.168.1.1 255.255.255.0

16:靜態路由的配置
配置路由器A的主機名和接口參數
router>enable
router#c onfigure terminal
router(conf)#hostname routerA
routerA(conf)#interface fastethernet 0/1           路由器A的1端口爲兩路由器的連接端口
routerA(conf-if)#ip address 192.168.2.1 255.255.255.0
routerA(conf-if)#no shutdown
routerA(conf-if)#exit
routerA(conf)# interface fastethernet 0/0          路由器A的0端口爲與主機的連接端口
routerA(conf-if)#ip address 192.168.1.2 255.255.255.0
routerA(conf-if)#no shutdown
主機A的ip地址爲 192.168.1.1
255.255.255.0
192.168.1.2
配置路由器B的主機名和接口參數
router>enable
router#c onfigure terminal
router(conf)#hostname routerB
routerB(conf)#interface fastethernet 0/0           路由器B的0端口爲兩路由器的連接端口
routerB(conf-if)#ip address 192.168.2.2 255.255.255.0
routerB(conf-if)#no shutdown
routerB (conf-if)#exit
routerB(conf)# interface fastethernet 0/1           路由器B的1端口爲與主機的連接端口
routerB(conf-if)#ip address 192.168.3.1 255.255.255.0
主機B的ip地址爲 192.168.3.2
255.255.255.0
192.168.3.1

配置路由器A的靜態路由表
routerA(conf)#ip router 192.168.3.0  255.255.255.0  192.168.2.2
配置路由器B的靜態路由表
routerA(conf)#ip router 192.168.1.0  255.255.255.0  192.168.2.1

在routerA和routerB上配置默認路由
routerA(conf)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
routerA(conf)#ip classless
routerB(conf)#ip route 0.0.0.0 0.0.0.0 192.168.2.1
routerB(conf)#ip classless

在routerA和routerB上配置動態路由(RIP)
routerA(conf)#router rip
routerA(conf)#network 192.168.1.0
routerA(conf)#network 192.168.2.0
routerB(conf)# router rip
routerB(conf)#network 192.168.2.0
routerB(conf)#network 192.168.3.0

 

2. 路由器支持的命令:
路由器顯示命令:
router#show run ;顯示配置信息
router#show interface ;顯示接口信息
router#show ip route ;顯示路由信息
router#show cdp nei ;顯示鄰居信息
router#reload ;重新起動
路由器口令設置:
router>enable ;進入特權模式
router#config terminal ;進入全局配置模式
router(config)#hostname ;設置交換機的主機名
router(config)#enable secret xxx ;設置特權加密口令
router(config)#enable password xxb ;設置特權非密口令
router(config)#line console 0 ;進入控制檯口
router(config-line)#line vty 0 4 ;進入虛擬終端
router(config-line)#login ;要求口令驗證
router(config-line)#password xx ;設置登錄口令xx
router(config)#(Ctrl+z) ;
返回特權模式
router#exit ;返回命令
路由器配置:
router(config)#int s0/0 ;進入Serail接口
router(config-if)#no shutdown ;激活當前接口
router(config-if)#clock rate 64000 ;設置同步時鐘
router(config-if)#ip address ;設置IP地址
router(config-if)#ip address second ;設置第二個IP
router(config-if)#int f0/0.1 ;進入子接口
router(config-subif.1)#ip address ;設置子接口IP
router(config-subif.1)#encapsulation dot1q ;綁定vlan中繼協議
router(config)#config-register 0x2142 ;跳過配置文件
router(config)#config-register 0x2102 ;正常使用配置文件
router#reload ;重新引導
路由器文件操作:
router#copy running-config startup-config ;保存配置
router#copy running-config tftp ;保存配置到tftp
router#copy startup-config tftp ;開機配置存到tftp
router#copy tftp flash: ;下傳文件到flash
router#copy tftp startup-config ;下載配置文件

ROM狀態:
Ctrl+Break ;進入ROM監控狀態
rommon>confreg 0x2142 ;跳過配置文件
rommon>confreg 0x2102 ;恢復配置文件
rommon>reset ;重新引導
rommon>copy xmodem: flash: ;從console傳輸文件

rommon>IP_ADDRESS=10.65.1.2 ;設置路由器IP
rommon>IP_SUBNET_MASK=255.255.0.0 ;設置路由器掩碼
rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP服務器IP
rommon>TFTP_FILE=c2600.bin ;指定下載的文件
rommon>tftpdnld ;從tftp下載
rommon>dir flash: ;查看閃存內容
rommon>boot ;引導IOS

靜態路由:
ip route ;命令格式
router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;靜態路由舉例
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;默認路由舉例
動態路由:
router(config)#ip routing ;啓動路由轉發
router(config)#router rip ;啓動RIP路由協議。
router(config-router)#network ;設置發佈路由
router(config-router)#negihbor ;點對點幀中繼用。
幀中繼命令:
router(config)#frame-relay switching ;使能幀中繼交換
router(config-s0)#encapsulation frame-relay ;使能幀中繼
router(config-s0)#fram-relay lmi-type cisco ;設置管理類型
router(config-s0)#frame-relay intf-type DCE ;設置爲DCE
router(config-s0)#frame-relay dlci 16 ;
router(config-s0)#frame-relay local-dlci 20 ;設置虛電路號
router(config-s0)#frame-relay interface-dlci 16 ;
router(config)#log-adjacency-changes ;記錄鄰接變化
router(config)#int s0/0.1 point-to-point ;設置子接口點對點
router#show frame pvc ;顯示永久虛電路
router#show frame map ;顯示映射
基本訪問控制列表:
router(config)#access-list permit|deny
router(config)#interface ;default:deny any
router(config-if)#ip access-group in|out ;defaultut

例1:
router(config)#access-list 4 permit 10.8.1.1
router(config)#access-list 4 deny 10.8.1.0 0.0.0.255
router(config)#access-list 4 permit 10.8.0.0 0.0.255.255
router(config)#access-list 4 deny 10.0.0.0 0.255.255.255
router(config)#access-list 4 permit any
router(config)#int f0/0
router(config-if)#ip access-group 4 in

擴展訪問控制列表:
access-list permit|deny icmp [type]
access-list permit|deny tcp [port]
例3:
router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo
router(config)#access-list 101 permit ip any any
router(config)#int s0/0
router(config-if)#ip access-group 101 in
例3:
router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80
router(config)#access-list 102 permit ip any any
router(config)#interface s0/1
router(config-if)#ip access-group 102 out

刪除訪問控制例表:
router(config)#no access-list 102
router(config-if)#no ip access-group 101 in

路由器的nat配置
Router(config-if)#ip nat inside ;當前接口指定爲內部接口
Router(config-if)#ip nat outside ;當前接口指定爲外部接口
Router(config)#ip nat inside source static [p] [port]
Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1
Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80
Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0
Router(config)#ip nat inside source list 1 pool p1
Router(config)#ip nat inside destination list 2 pool p2
Router(config)#ip nat inside source list 2 interface s0/0 overload
Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary
Router#show ip nat translation
rotary 參數是輪流的意思,地址池中的IP輪流與NAT分配的地址匹配。
overload參數用於PAT 將內部IP映射到一個公網IP不同的端口上。
外部網關協議配置
routerA(config)#router bgp 100
routerA(config-router)#network 19.0.0.0
routerA(config-router)#neighbor 8.1.1.2 remote-as 200

配置PPP驗證:
RouterA(config)#username password
RouterA(config)#int s0
RouterA(config-if)#ppp authentication {chap|pap}


3.PIX防火牆命令
Pix525(config)#nameif ethernet0 outside security0 ;命名接口和級別
Pix525(config)#interface ethernet0 auto ;設置接口方式
Pix525(config)#interface ethernet1 100full ;設置接口方式
Pix525(config)#interface ethernet1 100full shutdown
Pix525(config)#ip address inside 192.168.0.1 255.255.255.0
Pix525(config)#ip address outside 133.0.0.1 255.255.255.252

Pix525(config)#global (if_name) natid ip-ip ;定義公網IP區間
Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 ;例句
Pix525(config)#global (outside) 1 133.0.0.1 ;例句
Pix525(config)#no global (outside) 1 133.0.0.1 ;去掉設置

Pix525(config)#nat (if_name) nat_id local_ip [netmark]
Pix525(config)#nat (inside) 1 0 0
內網所有主機(0代表0.0.0.0)可以訪問global 1指定的外網。
Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0
內網172.16.5.0/16網段的主機可以訪問global 1指定的外網。

Pix525(config)#route if_name 0 0 gateway_ip [metric] ;命令格式
Pix525(config)#route outside 0 0 133.0.0.1 1 ;例句
Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句

Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8
表示內部ip地址192.168.0.8,訪問外部時被翻譯成133.0.0.1全局地址。

Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8
中間區域ip地址172.16.0.8,訪問外部時被翻譯成133.0.0.1全局地址。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章