思科常用路由交換命令(一)

router(config)#interface loopback 0       配置loopback還回接口
router(config-if)#ip address 10.0.0.1 255.255.255.0  配置loopback還回地址
-------------------------------
cisco交換機:
用戶模式:
switch>
特權模式:
switch>enable
switch#
全局模式:
switch#config terminal
switch(config)#
接口配置模式:
switch(config)#interface f0/1
switch(config-if)#
line模式:
switch(config)#line console 0
switch(config-line)#
----------------------------------------------------------------
配置主機名和密碼:
switch(config)#hostname 123
123(config)#
查看交換機的配置:
123(config)#show running-config
使能口令:
123(config)#enable password 123456
加密口令:
123(config)enable secret 654321
配置console密碼:
123(config)#line console 0
123(config-line)#password 321456
123(config-line)#login(激活密碼)
123(config-line)#no password (刪除密碼)
-----------------------------------------------------------------
配置IP地址:
123(config)#interface vlan 1
123(config-if)#ip address 192.168.1.2 255.255.255.0
123(config-if)#no shutdown  (激活)
刪IP地址:123(config-if)#no ip address
配置交換機網關
123(config)#ip default-gateway 192.168.1.1
查看交換機的MAC地址表
123#show mac-address-table
-----------------------------------------------------------------
Cisco發現協議(CDP)
show cdp命令中主要包括以下幾個可以使用的命令
switch#show cdp
switch#show cdp interface f0/24
switch#show cdp neighbors
switch#show cdp neighbors detaill
switch#show cdp traffic
switch#show cdp entry *
----------------------------------------------------------------
保存交換機的配置和恢復原廠設置
123#copy running-config startup-config或
123#write兩條命令的效果都是一樣的
恢復交換機出廠值
123#erase startup-config(爲檫除清空startup-config)
123#reload(重新載入)
---------------------------------------------------------------
交換機密碼恢復
(1)拔下交換機的電源線
(2)用手按在交換機的MODE按鍵上,插上電源線
(3)看到控制檯出現,交換機啓動系統
(4)在switch:後執行flash_init命令
switch:flash_init
Initializing flash.....(啓動中
(5)查看flash中的文件:
switch:dir flash:
(6)把config.text文件改名爲config.old文件
switch:rename flash :config.text flash:config.old
(7)執行boot命令,啓動交換機:
switch:boot
(8)進入特權模式查看flash裏的文件
switch#dir flash:
(9)把文件config.old改爲 config.text文件
switch#rename flash:config.old flash:config.text
(10)把config.text複製爲系統的running-config:
switch#copy flash:config.text running-config
(11)進入配置模式重新設置密碼並存盤,密碼恢復完成
-----------------------------------------------------------------          
       虛擬局域網VLAN
建立VLAN
switch#config terminal
switch(config)#vlan 100
switch(config-vlan)name 321(改名字)
switch(config)#no vlan 100 (刪除vlan 100)
或在VLAN數據庫裏也可建立VLAN
switch#vlan database
switch(vlan)#vlan 100 name v100 (建立並改名爲V100)
查看VLAN信息的命令:
switch#show vlan brief
查看某個VLAN的信息:
switch#show vlan 100
在VLAN中添加,刪除端口
switch#interface terminal
switch(config)#interface f0/24
switch(config-if)#switchport mode access(接入鏈路)
switch(config-if)#switchport access vlan 2(加入VLAN 2)
switch(config)#interface range f0/1 - 20
switch(config-if-range)#switchport access vlan 2
(把f0/1到f0/10端口全部加到vlan2)
switch(config-if)#no switch access vlan 2(從VLAN 2中刪除)
switch(config-if)end(退出
switch(config)#default interface fastethernet0/2(還原接口都默認配置狀態)
---------------------------------------------------------------------------
配置VLAN Trunk
配置與查看命令
switch(config)#interface f0/24
switch(config-if)switchport mode trunk(配置F0/24爲中繼鏈路)
switch(config-if)switch mode assess (可以從TRUNK改爲普通鏈路)
配置接口爲動態協商模式的命令:
switch(config)#interface f0/23
switch(config-if)#switch mode dynamic desirable或auto
可以配置接口爲TRUNK動態協商模式,爲desirable或auto
使用show命令驗證接口模式:
switch#show interface f0/24 switchport
如果不需要Trunk傳送某個VLAN的數據,可以從Trunk中移除這VLAN
switch(config)#interface f0/24(因爲這是TrunK鏈路)
switch(config-if)switch trunk allowed vlan remove 100(這寫VLAN幾)
同樣,也可以在TRUNK上添加某個VLAN
switch(config)#interface f0/24
switch(config-if)switch trunk allowed vlan add 100
查看接口是否成了trunk鏈路
switch#show interface f0/24 switchport
--------------------------------------------------------------------------
ARP協議:
在Windows主機上:
c:\>arp -a 可以查看IP地址和MAC地址的對應關係
也可以手動刪除ARP表條目
c:\>arp -d 192.168.1.1
在路由器上顯示ARP緩存表
router#show ip arp
---------------------------------------------------------------------------
靜態路由與配置
其用戶模式跟交換機是一樣用的,進路由器問YES/NO,選擇NO,自己手動配置
1.配置默認路由:
注::默認路由一般用末梢網絡
router(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1 (8個0代表所有網段,192.168.1.1
代表下一跳地址,也就下一個router的IP地址
2.配置靜態路由
router(config)#ip route 192.168.1.0 255.255.255.0(目標網段的IP)  接下一跳地址172.16.1.1
配置路由器A的Fastethernet f0/0接口的IP地址:
R1#config ter
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
查看R1   F0/0接口狀態
R1#show interface f0/0
查看router的路由表:
R1#show ip route
---------------------------------------------
配置控制檯密碼:
R1(config_line)#line console 0
R1(config_line)#password 321456
R1(config_line)#login
配置特權模式密碼:
R1(config)#enable password 1230
對所有密碼加密:
R1(config)#service password-encryption

配置console的其他參數
(1)配置超時(timeout)
R1(config)#line console 0
R1(config_line)#exec-timeout 0 0
命令中的0 0 代表着永不超時,第1個0代表分鐘,第2個0代表秒,
(2)顯示同步
R1(config)#line console 0
R1(config_line)logging synchronous
(3)配置禁用DNS
R1(config)#no ip domain-lookup
查看路由器的版本信息
R1#show version
-----------------------------------------------------------------------
   路由器的密碼恢復(照書抄,沒用過)
(1)重新啓動路由器,在啓動60秒內按下Ctrl+Break鍵,使路由器進入ROM Monitor模式
(2)在提示符下輸入命令修改配置寄存器的值,然後重新啓動路由器,
rommon1>confreg 0x2142
rommon2>reset
(3)重啓動router後進入SETUP模式,選擇NO退回到EXEC模式,這時路由器原有的配置
仍然保存在startup-config中,爲使路由器恢復密碼後配置不變,應把startup-config
中的配置保存到running-config中,然後重新設置enable密碼,並把配置寄存器的值改回
0x2102(否則以後每次重啓路由器進入setup模式).命令如下
Router>enable
Router#copy startup-config running-config
Router#config terminal
Router(config)#enable password 123
Router(config)#config-regiser 0x2102
(4)保存當前配置到startup_config,然後重新啓動路由器.命令如下
router#copy running-config startup-config
Router#reload
--------------------------------------------------------------------------
配置單臂路由
router(config)#interface f0/0
router(config-if)#no shutdown(先激活f0/0接口也可以,後面激活也可以)
router(config)#interface f0/0.1(爲F0/0的子接口模式)
router(config-subif)#encapsulation dot1q 1(後面1爲VLAN1,也就是把這子
接口封裝VLAN1裏)
router(config-subif)#ip address 192.168.1.1 255.255.255.0(這IP就是VLAN1的網關地址)
router(config-subif)#no shutdown
查看:特權模式下:show ip route或show run或show interface f0/0
----------------------------------------------------------------------
配置時間:
Router#clock set 小時:分鐘:秒  日 月 年
查看:router#show clock
配置RIP動態路由
啓動RIP進程的命令(RIP是動態路由的一中協議)
router(config)#router rip
router(config-router)#version 2(設置爲RIP的版本2)
router(config-router)#no auto-summary(使用RIP2時,配置不自動彙總)
router(config-router)#network 192.168.1.0(宣告直連路由的IP網段)
router#show ip route(查看路由表)
router#show ip protocol (查看路由協議配置)
router#debug ip rip(開啓調試命令)
----------------------------------------------------------------
想要用TELNET管理cisco設備,需要進行如下配置
switch(config)#interface vlan 1 (要先配IP地址)
switch(config-if)#ip address 192.168.1.1 255.255.255.0
switch(config-if)#no shutdown
switch(config)#line vty 0 5 (後面的5是同時允許幾個用登陸)
switch(config-line)#passwor 133
switch(config-line)#login(激活)
switch(config)#enable password 123
switch(config)#service password-encryption(給所有加密,可以選)
在PC機命令提示符下
c:\>telnet 192.168.1.1
進入後password:  自己寫的密碼
---------------------------------------------------------------
備份IOS或startup-config
1,確認PC和交換機能PING通
2,打開Cisco TFTP Server的工具
3,上傳或下載交換機的IOS或配置文件
switch#copy flash tftp(從FLASH到TFTP)
switch#copy tftp flash(從TFTP到FLASH)
switch#copy nvram:starup-config tftp:
switch#copy tftp:starup-config nvram(上傳配置文件到交換機)
---------------------------------------------------------------
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章