1. 程式人生 > >思科交換機基本配置實例講解(123)

思科交換機基本配置實例講解(123)

系統 face 模擬 action 千兆 詳解 終端 輸出 打開終端

1、基本概念介紹

IOS: 互聯網操作系統,也就是交換機和路由器中用的操作系統

VLAN: 虛擬lan

VTP: VLAN TRUNK PROTOCOL

DHCP: 動態主機配置協議

ACL: 訪問控制列表

三層交換機:具有三層路由轉發能力的交換機

本教程中“#”後的藍色文字為註釋內容。

2、密碼、登陸等基本配置

本節介紹的內容為cisco路由器或者交換機的基本配置,在目前版本的cisco交換機或路由器上的這些命令是通用的。本教程用的是cisco的模擬器做的介紹,一些具體的端口顯示或許與你們實際的設備不符,但這並不影響基本配置命令的執行。

Cisco 3640 (R4700) processor (revision 0xFF) with 124928K/6144K bytes of memory.

Processor board ID 00000000

R4700 CPU at 100MHz, Implementation 33, Rev 1.2

2 Ethernet interfaces

8 Serial interfaces

DRAM configuration is 64 bits wide with parity enabled.

125K bytes of NVRAM.

8192K bytes of processor board System flash (Read
/Write) --- System Configuration Dialog --- Would you like to enter the initial configuration dialog? [yes/no]: n

# 此處我們選擇no,不進入他的初始化配置向導

Press RETURN to get started!      

# 選擇no以後,提示你按回車鍵開始,此處我們需要按回車鍵

*Mar  1 00:43:56.591: %IP-5-WEBINST_KILL: Terminating DNS process

*Mar  1 00:43
:58.379: %SYS-5-RESTART: System restarted -- Cisco IOS Software, 3600 Software (C3640-JK9O3S-M), Version 12.3(14)T7, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2006 by Cisco Systems, Inc. Compiled Wed 22-Mar-06 21:46 by pwade *Mar 1 00:43:58.411: %SNMP-5-COLDSTART: SNMP agent on host Router is undergoing a cold start

Router>

# 等顯示穩定後,出現最初的提示符,註意提示符是“>”,目前所處的狀態稱為用戶模式。

Router>

Router>en

# 如果在當前狀態下沒有重復的命令,我們可以用“TAB”鍵來補齊這條命令,主要目的是為了便於閱讀

Router>enable

# 從用戶模式(user mode)進入到特權模式(exec mode),註意提示符的變化,提示符變為“#”

Router#conf t

Router#configure terminal

(說明:#在特權模式下輸入configure terminal進入全局配置模式(global configuration mode),在這之下輸入的命令叫做全局命令,一旦輸入,將對整個router產生即時影響。如下,註意提示符的變化:)

Router(config)#exit # 請註意提示符發生了改變,當前的模式據叫做全局配置模式。

Router#conf

*Mar 1 00:44:26.491: %SYS-5-CONFIG_I: Configured from console by console t # 在輸入命令的過程中,IOS會出現一些即時提示。

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#exit # 退出當前的全局配置模式的命令是exit

Router#conf t # 重新進入到全局配置模式

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#

*Mar 1 00:44:35.591: %SYS-5-CONFIG_I: Configured from console by consolehos

# 這行是路由器(交換機)出現的一些即時提示。

Router(config)#hostname test

# 這條命令用來更改當前設備的名字(名字中可包含設備的樓層、用途等信息),主要是為了將來便於區分設備。

test(config)#

# 回車後我們就會發現,但前的設備的名字已經發生了改變,變成了test了。

test(config)#enable pass

# 這條命令用來配置設備的登陸密碼,用tab鍵補齊後,再下一行顯示完整命令。

test(config)#enable password cisco # 我們輸入這臺設備的登陸密碼為 cisco

test(config)#end # 我們退回到全局配置模式,校驗一下剛才輸入的密碼

test#sh r

# 此命令的完整寫法是show running-start,此處的sh r用的是省略的寫法,因無其他重復的命令所以可以被執行。

Building configuration...
Current configuration : 1559 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname test                # 註意此處顯示的是我們配置的設備的名字
!
boot-start-marker
boot-end-marker
!
enable password cisco          
# 此處顯示的是剛才我們配置的enable密碼,註意此時是用明文顯示的,有點不安全。
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
ip subnet-zero
!

# 到這一行其實並未全部顯示完配置的內容,我們可以按鍵盤上的任意鍵來終止繼續顯示。在顯示的過程中通過按回車鍵可以逐行顯示,按空格鍵可以一頁一頁的顯示。這些操作可在實際的設備中體會。

test#conf t # 重新進入到全局配置模式

test(config)#service pass

test(config)#service password-encryption # 利用這條命令給密碼加密顯示。

test(config)#end

test#sh r # 退出到全局配置模式後,驗證剛才的配置。

Building configuration...

Current configuration : 1565 bytes
!
version 12.3

service timestamps debug datetime msec

service timestamps log datetime msec

service password-encryption
!
hostname test
!
boot-start-marker
boot-end-marker
!
enable password 7 070C285F4D06      

# 註意此處剛才明文顯示的密碼已經變成加密顯示了,這樣從一定程度上保證了密碼的安全。
!
no aaa new-model
!
resource policy
!
memory-size iomem 5
ip subnet-zero
!
# 驗證完畢後按任何一個鍵中斷顯示,下面的內容說明終端登陸密碼的配置。

test#conf t

Enter configuration commands, one per line. End with CNTL/Z.

test(config)#no service password-encryption

# 可利用這條命令(前面加no)來去掉密碼加密功能,cisco的所有命令都可以通過這種方式來禁止。

test(config)#line con

test(config)#line console 0 # 利用這條命令來配置用超級終端登陸時的一些參數。

test(config-line)#pass

test(config-line)#password cisco # 添加密碼,此處我們配置的密碼為cisco

test(config-line)#loggi

test(config-line)#logging ?

# 在任何情況下如果你忘記了命令的相關參數可以用?來獲得提示和幫助

synchronous Synchronized message output

test(config-line)#logging sy

test(config-line)#logging synchronous

# 在我們進行配置時,IOS會產生一些即時的提示信息,而這些信息會沖亂我們的光標顯示,用這條命令可以將光標規矩在下一行,即使出現了一些即時的提示。

test(config-line)#exit # 退出當前console口的參數配置

test(config)#line vt? # telnet登陸時相關參數的配置,此處用了?來尋求提示。

 <0-134>  First Line number

  aux      Auxiliary line

  console  Primary terminal line

  tty      Terminal controller

  vty      Virtual terminal

  x/y      Slot/Port for Modems

test(config)#line vty 0 4

# 我們配置虛擬終端的0到4,也就是同時允許5個用戶可以telnet到這臺設備上來。

test(config-line)#pass

test(config-line)#password cisco

# 我們配置telnet時的密碼為cisco,如果此處我們不設置密碼,那麽用telnet來登陸的時候並不會以空密碼登陸,而是會給你提示說:相關密碼沒有設置,禁止登陸。所以我們為了能遠程telnet到這臺設備,此處的密碼一定要設置好。

test(config-line)#login # 這條命令是允許通過telnet來登錄

test(config-line)#exit # 退出當前配置模式到全局配置模式。

test(config)#

test(config)#

test#conf s

# 我們在做配置的時候,會出現輸入錯誤的情況,在這種情況下ios會以為你輸入的是一個域名

Translating "s"...domain server (255.255.255.255)

# 那麽ios會做長時間的搜尋,試圖找到這個域名對應的ip地址.......

Translating "s"...domain server (255.255.255.255)

# 這段時間是比較長的,那麽我們如何禁用它的這個功能呢?

% Unknown command or computer name, or unable to find computer address

test#conf t

Enter configuration commands, one per line. End with CNTL/Z.

test(config)#no ip domain-lookup # 在全局配置模式下,將ip域名的搜尋功能關閉就可以了。

test(config)#end

test#conf

*Mar 1 01:40:46.895: %SYS-5-CONFIG_I: Configured from console by console

test#conf x # 將上述功能關閉以後,再有輸入錯誤的情況會直接提示你輸入錯誤。

^

% Invalid input detected at ‘^‘ marker.

test#

test(config)#ip domain-name 202.102.128.68

# 如果有必要將設備配置上DNS功能的話就用這條命令。

### 基本配置完畢後我們驗證一下所有的配置###

test#sh run

Building configuration...
Current configuration : 1693 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption                # 密碼加密顯示功能打開
!
hostname test
!
boot-start-marker
boot-end-marker
!
enable password 7 070C285F4D06       # 密碼被加密顯示了
!
no aaa new-model
!
resource policy
!
memory-size iomem 5

ip subnet-zero
!
!
ip cef   

no ip domain lookup                           # 關閉了域名查找功能

no ip dhcp use vrf connected

!
!
no ip ips deny-action ips-interface

!

no ftp-server write-enable

!

no crypto isakmp ccm
!
(略……)

ip http server

no ip http secure-server

ip classless

!        
control-plane
!
line con 0

 exec-timeout 0 0
 password 7 094F471A1A0A       # 用超級終端登陸的密碼,也同樣被加密顯示
 logging synchronous
line aux 0
line vty 0 4
 password 7 00071A150754         # 用telnet登陸的密碼,也同樣被加密顯示
 login
!
!
end

 

3、cisco設備端口配置詳解

User Access Verification

# 從dos提示符下運行telnet ip地址,就會連接到相應的交換機或者路由器

Password: # 輸入配置號的telnet密碼,也就是上節提到的vtp中的密碼

test>en # 進入特權模式

Password: # 輸入特權模式密碼,也就是上節提到的enable密碼。註意這些密碼在輸入的時候屏幕是不顯示的。

test#

test#

test#sh ip int brief # 查看當前所有端口狀態,包括vlan和實際的物理接口狀態

Interface IP-Address OK? Method Status Protocol

# 這行列示的各種狀態的名稱

FastEthernet1 unassigned YES NVRAM down down

Vlan1 192.168.113.254 YES NVRAM up up

# vlan1的狀態是active

Vlan2                  172.16.0.2       YES NVRAM  up                    up     

Vlan10                 192.168.101.254  YES NVRAM  up                    up     

Vlan20                 192.168.102.254  YES NVRAM  up                    up     

Vlan30                 192.168.103.254  YES NVRAM  up                    up     

Vlan40                 192.168.104.254  YES NVRAM  up                    up     

Vlan50                 192.168.105.254  YES NVRAM  up                    up     

Vlan60                 192.168.106.254  YES NVRAM  up                    up     

Vlan70                 192.168.107.254  YES NVRAM  up                    up     

Vlan80                 192.168.108.254  YES NVRAM  up                    up     

Vlan100                192.168.110.254  YES NVRAM  up                    up     

Vlan110                192.168.111.254  YES NVRAM  up                    up     

Vlan120                192.168.112.254  YES NVRAM  up                    up     

Vlan150                192.168.100.254  YES NVRAM  up                    up     

Vlan160                192.168.115.254  YES NVRAM  up                    up     

GigabitEthernet1/1        unassigned      YES unset     up                    up

# 物理接口gi1/1也是active狀態

GigabitEthernet1/2     unassigned      YES unset  down                  down   

GigabitEthernet1/3     unassigned      YES unset  down                  down   

GigabitEthernet1/4     unassigned      YES unset  down                  down   

GigabitEthernet1/5     unassigned      YES unset  down                  down   

GigabitEthernet1/6     unassigned      YES unset  down                  down   

GigabitEthernet1/7     unassigned      YES unset  down                  down    

GigabitEthernet1/8     unassigned      YES unset  down                  down   

GigabitEthernet1/9     unassigned      YES unset  down                  down   

# 說明:通過上述命令即可以查看當前設備所有狀態的情況也可以查看端口的表示方式。在此例中我們登陸的是一臺cisco4503的三層交換機;其中GigabitEthernet1/1,表示的是這臺交換機上的第1塊業務板的第1個端口,並且此端口是個千兆端口;而GigabitEthernet3/19表示的是這臺交換機上的第3塊業務版的第19個端口,並且此端口也是一個千兆端口,其他的端口以此類推。千兆端口的名稱為:GigabitEthernet,百兆端口的名稱為:FastEthernet。

test# conf t

# 進入到全局配置模式。要想對端口、vlan、路由等操作一定要到全局配置模式中來。

Enter configuration commands, one per line. End with CNTL/Z.

test(config)#inter

test(config)#interface gi1/2

# 通過此命令可進去端口配置模式,此處我們進入的是GigabitEthernet1/2口,gi1/2為簡寫。

test(config-if)#?

#回車後進入到端口配置模式,註意提示符的變化,輸入?尋求在這個模式著那個的幫助。

Interface configuration commands:

  access-group            Access group configuration

  arp                     Set arp type (arpa, probe, snap) or timeout

  auto                    Configure Automation

  backup                  Modify backup parameters

  bandwidth               Set bandwidth informational parameter

  bgp-policy              Apply policy propogated by bgp community string

  carrier-delay           Specify delay for interface transitions

  cdp                     CDP interface subcommands

  channel-group           Etherchannel/port bundling configuration

  channel-protocol        Select the channel protocol (LACP, PAgP)

  dampening               Enable event dampening

  default                 Set a command to its defaults

  delay                   Specify interface throughput delay

  description             Interface specific description

  dot1x                   Interface Config Commands for 802.1x

  duplex                  Configure duplex operation.

  exit                    Exit from interface configuration mode

  flow-sampler            Attach flow sampler to the interface

  flowcontrol             Configure flow operation.

  help                    Description of the interactive help system

  ip                      Interface Internet Protocol config commands

  isis                    IS-IS commands

  iso-igrp                ISO-IGRP interface subcommands

  keepalive               Enable keepalive

  l2protocol-tunnel       Tunnel Layer2 protocols

  lacp                    LACP interface subcommands

  load-interval           Specify interval for load calculation for an interface

  logging                 Configure logging for interface

  loopback                Configure internal loopback on an interface

  mac                     MAC interface commands

  macro                   Command macro

  max-reserved-bandwidth  Maximum Reservable Bandwidth on an Interface

  mtu                     Set the interface Maximum Transmission Unit (MTU)

  no                      Negate a command or set its defaults

  pagp                    PAgP interface subcommands

  power                   Power configuration

  qos                     QoS configuration

  rmon                    Configure Remote Monitoring on an interface

  service-policy          Configure QoS Service Policy

  shutdown                Shutdown the selected interface

  snmp                    Modify SNMP interface parameters

  spanning-tree           Spanning Tree Subsystem

  speed                   Configure speed operation.

  storm-control           storm configuration

  switchport              Set switching mode characteristics

  timeout                 Define timeout values for this interface

  transmit-interface      Assign a transmit interface to a receive-only interface

  tx-queue                Configure interface transmit queue

  udld                    Configure UDLD enabled or disabled and ignore global UDLD setting

  vlan-range              config vlan

test(config-if)#spe

test(config-if)#speed ?

# 我們可指定這個端口的速度,比如這個端口接的是一個百兆的收發器,我們就可以強制將此端口設置成100M

10 Force 10 Mbps operation # 強制此端口為10M

100 Force 100 Mbps operation # 強制此端口為100M

1000 Force 1000 Mbps operation # 強制此端口為1000M

auto Enable AUTO speed configuration # 允許速度自動協商

test(config-if)#speed 100

# 通過此命令就可將此端口強制設成100M,默認的狀態下是auto。

test(config-if)#dup

test(config-if)#duplex ? # 用此命令可配置此端口的雙工模式,有3個選項供選擇

auto Enable AUTO duplex configuration # 自動配置此端口的雙工模式

full Force full duplex operation # 強制此端口為全雙工模式

half Force half-duplex operation # 強制此端口為半雙工模式

test(config-if)#duplex auto

test(config-if)#end # 用end命令可直接退回到特權模式,用exit是一層一層的退出。

test#ter

test#terminal moni

test#terminal monitor

# 打開終端監控。當用telnet登陸的時候默認是不顯示各端口的實時變化情況的,打開這個功能就能實時的看到這臺交換機上哪個端口up,哪個端口down,這對於排錯的時候是很有幫助的。

test#conf t

Enter configuration commands, one per line. End with CNTL/Z.

test(config)#int gi1/2 # 重新回到端口配置模式

test(config-if)#shut # 此命令可手工關閉此端口

test(config-if)#no shut # 此命令為打開此端口

test(config-if)#switchport access vlan ?

# 這條命令可配置此端口屬於哪個vlan,當然此vlan要事先建好。

<1-4094> VLAN ID of the VLAN when this port is in access mode

dynamic When in access mode, this interfaces VLAN is controlled by VMPS

test(config-if)#switchport access vlan 100

# 我們配置此端口屬於vlan100,如果此端口事先屬於其他vlan那麽,會從其他vlan退出

test(config-if)#exit

test(config)#int rang # 亦可成批的配置端口,利用這個命令

test(config)#int range gi 1/1 - 5

# 表示同時對gi1/1到gi1/5這5個端口進行操作,註意命令“1 - 5”,之間有空格。

test(config-if-range)#switchport access vlan 100 # 可同時配置這5個端口屬於vlan100

test(config-if-range)#shutdown # 可同時關閉這5個端口

test(config-if-range)#no shutdown # 可同時啟用這5個端口

test(config-if-range)#exit

test(config-if)#end

test#

test#sh int gi1/2 # 在特權模式中,可查看單個端口的狀態

GigabitEthernet1/2 is down, line protocol is down (notconnect)

# 這行說明此端口當前的狀態是down的

  Hardware is GigabitEthernetPort, address is 001a.6db4.a3c1 (bia 001a.6db4.a3c1)   

# 此端口的MAC地址

  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive set (10 sec)

  Auto-duplex, Auto-speed, link type is auto, media type is 10/100/1000-TX         

# 此端口的模式為10/100/1000-TX

  input flow-control is off, output flow-control is off

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input never, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/2000/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     0 packets input, 0 bytes, 0 no buffer

     Received 0 broadcasts (0 multicast)

     0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

     0 input packets with dribble condition detected

     0 packets output, 0 bytes, 0 underruns

     0 output errors, 0 collisions, 0 interface resets

     0 babbles, 0 late collision, 0 deferred

     0 lost carrier, 0 no carrier

     0 output buffer failures, 0 output buffers swapped out

test#sh int gi1/1

GigabitEthernet1/1 is up, line protocol is up (connected)   

# 這行表明此端口是up的,並且連有網線。

  Hardware is GigabitEthernetPort, address is 001a.6db4.a3c0 (bia 001a.6db4.a3c0)

  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive set (10 sec)

  Full-duplex, 1000Mb/s, link type is auto, media type is 10/100/1000-TX

  input flow-control is off, output flow-control is off

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input never, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/2000/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 1293000 bits/sec, 426 packets/sec

  5 minute output rate 2410000 bits/sec, 528 packets/sec

     273591244 packets input, 142285545179 bytes, 0 no buffer

     Received 0 broadcasts (0 multicast)

     0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored       # 沒有輸入錯誤,表明鏈路狀態良好

     0 input packets with dribble condition detected

     335026620 packets output, 223732323465 bytes, 0 underruns  # 輸出數據包統計

     0 output errors, 0 collisions, 0 interface resets

     0 babbles, 0 late collision, 0 deferred

     0 lost carrier, 0 no carrier

     0 output buffer failures, 0 output buffers swapped out

test#wr # 保存剛才的配置結果

思科交換機基本配置實例講解(123)