思科常用命令

操作模式

  1. 用戶模式。提示符:">",進入命令:初始模式。
  2. 特權模式。提示符:"#",進入命令:enable 退出命令:disable
  3. 全局配置模式。提示符:"(config)#",進入命令:configure terminal 退出命令:exit
  4. 其他配置模式。如接口模式:提示符:"(config-if)#",進入:interface type number 退出:exit

常用命令

設置系統日曆:R1#clock set 8:43:00 12 june 2008
       R1(config)#clock timezone GMT +8 (設置時區爲北京時間東八區)

命令行幫助:任何情況輸入“?”獲取幫助。
測試網絡連通性:ping ip地址
測試中間經過設備:traceroute ip地址

查看硬件軟件信息:R1>show version
查看運行配置文件:R1# show run
查看保存的配置文件:R1# show startup-config
查看接口狀態: R1# show interface
查看接口與IP相關的信息:R1# show ip interface
       R1# show ip interface brief
查看路由表:R1# show ip route
查看路由協議:R1# show ip protocols
配置保存:
保存運行配置文件:R1# copy running-config startup
       或者R1# write(用運行配置文件覆蓋啓動配置文件)
刪除啓動配置文件:R1#erase startup-config


配置路由器

配置路由器密碼:
(1)配置Console端口密碼:
   R1(config)# line console 0
   R1(config-line)# password cisco
   R1(config-line)# login
(2)配置從用戶模式切換到特權模式的使能密碼:
   R1(config)# enable password cisco
   R1(config)# enable secret cisco123 (另外可以配置祕密使能密碼)
(3)配置遠程登錄密碼(VTY,虛擬終端類型)默認不允許遠程訪問
   R1(config)#line vty 0 4
   R1(config-line)#password cisco
   R1(config-line)#login

配置路由器接口IP:
R1(config)# interface s1/1
R1(config-if)# ip address 12.1.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit
配置路由器接口secondary地址:
R1(config)# interface s1/1
R1(config-if)# ip address 12.1.1.1 255.255.255.0
R1(config-if)# ip address 13.1.1.1 255.255.255.0 secondary
R1(config-if)# no shutdown
R1(config-if)# exit
取消接口的多個IP地址:R1(config-if)# no ip address [ip] [子網掩碼]
刪除接口下的所有IP:R1(config-if)# no ip address

配置主機名列表:
R1(config)#ip host abc 12.1.1.2 (配置完後遠程登錄可以用telnet abc代替主機IP)
查看路由器上配置的主機名列表: show host
配置DNS服務器:ip name-server dns 服務器的IP地址

配置靜態路由
R1(config)#ip route 目標網絡 掩碼 下一跳路由器直連接口的IP或本路由器外出接口 管理距離 [permanent]
使用permanent參數,不管發生什麼意外情況,該靜態路由不會從路由表消失。
前面加no刪除該靜態路由。

默認路由:用來轉發不在路由列表中列出的遠端目的網絡的數據包
R1(config)#ip route 0.0.0.0 0.0.0.0 下一跳路由地址

動態路由
1. RIPv1協議配置
R1(config)# router rip  啓動路由選擇進程
R1(config-router)#network 11.0.0.0  宣告各接口的直連網絡
R1(config-router)#network 12.0.0.0

配置默認路由(默認網關):R1(config)# ip route 0.0.0.0 0.0.0.0 23.1.1.3
             R1(config)# ip default-network 23.0.0.0  默認網絡,僅支持有類網絡後面要寫網絡的主類地址

負載均衡:R1(config-router)#maximum-paths 6
關閉快速交換使用進程交換:R1(config)#no ip cef

禁用水平分割:R1(config-if)# no ip split-horizon


2. RIPv2協議配置
R1(config)# router rip
R1(config-router)# version 2
R1(config-router)#network 主類網絡號


3. OSPF協議配置
R1(config)#router ospf 1
R1(config-router)#network IP子網 反掩碼 area 0


配置DHCP服務器

R1(config)#ip dhcp excluded-address 192.168.1.1 把網關排出地址池
R1(config)#ip dhcp pool poolname 配置DHCP地址池名字
R1(dhcp-config)#network 192.168.1.0/24 分配網段地址
R1(dhcp-config)#default-router 192.168.1.1 指定網關
R1(dhcp-config)#dns-server 202.102.3.141 指定DNS服務器
R1(dhcp-config)#lease 8 IP地址租期是8天,默認無限期
R1(dhcp-config)#domain-name test.com 設定主機域名,可不設此項
R1(dhcp-config)#exit

配置DHCP中繼:
R3(config)#int fa 0/0 配置與DHCP客戶端最近的以太網接口
R3(config-if)#ip helper-address 23.1.1.2 把收到的DHCP廣播包裝發給DHCP服務器23.1.1.2

常用:ipconfig/release釋放先前獲取的IP
  ipconfig/renew重新獲取IP


配置NAT

配置靜態NAT:
(1) 指定外部端口。端口設置狀態下輸入:ip nat outside
(2) 指定內部端口。端口設置狀態下輸入:ip nat inside
(3) 在內部本地地址與內部合法地址之間建立靜態地址轉換。全局配置狀態下輸入:
ip nat inside source static 內部本地地址 內部合法地址

配置動態NAT:
(1) 指定外部端口。端口設置狀態下輸入:ip nat outside
(2) 指定內部端口。端口設置狀態下輸入:ip nat inside
(3) 全局配置模式下定義內部合法地址池:ip nat pool 地址池名稱 起始IP地址 終止IP地址 子網掩碼
(4) 全局配置模式下定義一個access-list規則以允許哪些內部地址可以進行動態地址轉換:
access-list 表號 permit 源地址 通配符
(5) 全局配置模式下,將由access-list指定的內部本地地址與內部合法地址池進行地址轉換:
ip nat inside source list ACL表號 pool 內部合法地址池名字 [overload] 加上overload參數表示配置NAT超載

**配置端口映射:
將外網對218.1.1.1的TCP80端口的訪問轉換成對內部IP192.168.1.1的80端口訪問:
**R1(config)#ip nat inside source static tcp 192.168.1.1 80 218.1.1.1 80
外網端爲動態IP時的NAT配置:
R1(config)#ip nat inside source list 1 int fa0/0 overload 不用創建地址池,直接借用接口fa0/0的IP,默認路由還是需要配的


交換機基本配置

配置默認網關:SW1(config)# ip default-gateway 1.1.1.1

開啓http服務:SW1(config)# ip http server
關閉http服務:SW1(config)#no ip http server

查看ARP表:show arp
查看MAC地址表:show mac-address-table

vlan配置:參考思科交換機VLAN配置
查看vlan:show vlan

訪問控制列表ACL:參考思科交換機ACL配置

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