cisco 2960 交換機 安裝配置基礎

cisco 2960 交換機 安裝配置基礎

新設備配置內容:
1. interface vlan 1 的ip,gateway
conf t
int vlan 1
ip address xx.xx.xx.xx 255.255.255.0
ip default-gateway ip-address
no shutdown
exit
2.en的密碼
3.line vty 0-4 telnet的密碼
4.wr存盤
show interface vlan 1
show run
將F0/1-10端口加入到VLAN20中,對應以下命令 
interface range f0/1 -10 
switchport mode acccess 
switchport access vlan 20 
注意,f0/1後面有個空格,然後纔是-10
cisco 2950 常用配置命令 
產品相關命令
1、配置IP地址
交換機要能夠被網管,必須給它標識一個管理IP地址,默認情況下CISCO交換機的VLAN 1爲管理VLAN,爲該VLAN配上IP 地址,交換機就可以被網管了。命令如下:
a、進入全局模式: Switch#configure terminal
b、進入VLAN 1接口模式:Switch(config)#interface vlan 1
c、配置管理IP地址:Switch(config-if) # ip address [A.B.C.D] [mask]
如果當前VLAN 不是管理VLAN ,只需要將上面第b處命令的vlan的號碼換成管理VLAN的號碼即可。
2、打開SNMP協議
a、進入全局模式: Switch#configure terminal
b、配置只讀的Community,產品默認的只讀Community名爲public
Switch(config)#snmp-server community public ro
c、配置可寫的Community,產品默認的可寫Community名爲private
Switch(config)#snmp-server community private rw
3、更改SNMP的Community密碼
a、將設備分組,並使能支持的各種SNMP版本
Switch(config)#snmp-server group qycx123 v1
Switch(config)#snmp-server group qycx 123 v2c
Switch(config)#snmp-server group qycx123 v3 noauth
b、分別配置只讀和可寫community 如:
Switch(config)#snmp-server community qycx123 ro
Switch(config)#snmp-server community qycx123 rw
4、保存交換機配置
Switch#copy run start
常用命令
1、設置交換機密碼
a、更改遠程TELNNET密碼
Switch#configure terminal
Switch(config)#line vty 0 4
Switch(config-line)#password qycx123
Switch(config-line)#login
Switch(config-line)#exit
b、更改進入全局配置模式時的密碼
Switch#configure terminal
Switch(config)#enable secret qycx123
2、創建並劃分VLAN
a、創建VLAN
Switch#vlan database
Switch(vlan)#vlan 99 name office
(創建vlan 99 並命名爲office)
b、將端口劃分至vlan
Switch(config)#interface fastEthernet 0/8
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 99
(將8號快速以太口劃分至vlan 99)
3、常用調試命令
a、顯示所有配置命令:Switch#show run
b、顯示所有接口狀態:Switch#show ip int brief
c、顯示所有VLAN的信息:Switch#show vlan brief
Cisco之line vty線路使用
2007-12-08 13:11
Cisco的設備管理有很多種方式,如Console、HTTP、TTY、VTY或其它網管軟件,但我們遠程管理較爲常用的一種方式肯定是VTY方式。  
VTY在Cisco的不同系列產品中,都有一定數量的VTY線路可用,但具體數目則不盡相同。有些路由器交換機產品只有五條線路可用(line vty 0 4),有些交換機路由器設備則提供了十多條,甚至達一千多條,但默認情況下不一定全部啓用。如果您想看一下自己的設備具體支持多少條線路,只需在全局模式下使用命令show line ; show line vty 0 ?即可查看該設備支持多少條線路。
VTY線路的啓用/關閉:
VTY線路的啓用只能按順序進行,你不可能啓用line vty 10,而不啓用line vty 9。如果想啓用line vty 9,那麼你可以在全局模式(或line模式)下輸入命令line vty 9 ,如:
(config)#line vty 9
這樣系統會自動啓用前面的0-8線路。當然也可以直接輸入line vty 0 9直接啓用10條線路。
如果不想開啓這麼多條線路供用戶使用,那麼只須在全局模式下使用no line vty m [n]命令就可以關閉第m後的線路,此時n這個數值可有可無,因爲系統只允許開啓連續的線路號,取消第m號線路會自動取消其後的所有線路。
VTY線路的協議選用:
VTY線路支持多種協議:
acercon Remote console for ACE-based blade
lat DEC LAT protocol
mop DEC MOP Remote Console Protocol
nasi NASI protocol
pad X.3 PAD
rlogin Unix rlogin protocol
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
udptn UDPTN async via UDP protocol

在某一個接口上使用什麼協議可以使用命令:transport {input|ouput}來進行定義:
(config)#line vty 0
(config-line)#transport ? //查看支持哪種方式的協議定義
input Define which protocols to use when connecting to the terminal server
output Define which protocols to use for outgoing connections
preferred Specify the preferred protocol to use

(config-line)#transport input ? //查看在輸入方向上支持的協議
acercon Remote console for ACE-based blade
all All protocols
lat DEC LAT protocol
mop DEC MOP Remote Console Protocol
nasi NASI protocol
none No protocols
pad X.3 PAD
rlogin Unix rlogin protocol
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
udptn UDPTN async via UDP protocol
(config-line)#transport output ? //查看在輸出方向上支持的協議
acercon Remote console for ACE-based blade
all All protocols
lat DEC LAT protocol
mop DEC MOP Remote Console Protocol
nasi NASI protocol
none No protocols
pad X.3 PAD
rlogin Unix rlogin protocol
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
udptn UDPTN async via UDP protocol
(config-line)#transport preferred //定義協議的優先次序
查看某一線路當前支持的協議可以使用命令show line vty m:
#show line vty 9
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
10 VTY - - - - - 0 0 0/0 -
Line 10, Location: "", Type: ""
Length: 24 lines, Width: 80 columns
Baud rate (TX/RX) is 9600/9600
Status: No Exit Banner
Capabilities: none
Modem state: Idle
Group codes: 0
Special Chars: Escape Hold Stop Start Disconnect Activation
^^x none - - none 
Timeouts: Idle EXEC Idle Session Modem Answer Session Dispatch
00:10:00 never none not set
Idle Session Disconnect Warning
never
Login-sequence User Response
00:00:30
Autoselect Initial Wait
not set
Modem type is unknown.
Session limit is not set.
Time since activation: never
Editing is enabled.
History is enabled, history size is 10.
DNS resolution in show commands is enabled
Full user help is disabled
Allowed input transports are lat pad mop telnet rlogin ssh nasi.
Allowed output transports are lat pad mop telnet rlogin ssh nasi.
Preferred transport is lat.

No output characters are padded
No special data dispatching characters
VTY線路的使用:
VTY線路啓用後,並不能直接使用,必須對其進行下面簡單的配置才允許用戶進行登錄。
1、配置登錄密碼
如果想成功登錄到設備,必須在line線路下使用命令password來定義登錄密碼,否則無法成功登錄(注:如果全局已經啓用了相關認證如AAA,則在此不必配置密碼)
注意:在此你配置的密碼是保存在配置文件中的,即使你啓用service password-encryption功能,它加密的方式也是一種可逆的加密,很容易破解,所以在使用過程中儘可能配置一個不同於特權模式中的密碼。
2、登錄驗證
默認情況下,在line vty線路中,默認情況下使用的是系統默認的登錄方式(要看你是否在全局啓用了AAA等),如果你需要在登錄時指定認證模式,你可以使用login authentication命令進行指定。如果你想在登錄時不需要用戶輸入密碼,則可以使用no lgoin命令進行指定(當然這很危險)
特權模式的使用:
通過VTY線路登錄後,會進入用戶模式,如果你需要進行特權模式,那麼你必須配置登錄特權模式的認證。
使用案例:
不同的線路上,可以配置不同的協議,如在line vty 0上配置telnet,在line vty 1上配置ssh,這樣當SSH用戶登錄時,系統會讓line vty 0空閒,而使用line vty 1進行連接。
應用:在line vty 0-1上配置使用telnet協議,使用動態訪問列表,在網絡中進行嚴格的控制,以便只有網絡管理人員纔可以使用特殊通信;在2-10上配置SSH協議,用來進行設備管理。
Cisco 2960交換機中如何綁定IP與MAC地址

請問:在2960交換機中如何進行端口MAC地址綁定,並同時綁定IP與MAC地址? 
網友1:
conf t
arp 192.168.1.1 0000.1001.2200 arpa fa0/1 
網友2:
IP地址與MAC地址的關係: IP地址是根據現在的IPv4標準指定的,不受硬件限制長度4個字節。而 MAC地址卻是用網卡的物理地址,保存在網卡的EPROM裏面,與硬件有關係,長度爲6個字節。
在交換式網絡中,交換機維護一張MAC地址表,並根據MAC地址,將數據發送至目的計算機。 爲什麼要綁定MAC與IP 地址:IP地址的修改非常容易,而MAC地址存儲在網卡的EEPROM中,而且網卡的MAC地址是唯一確定的。因此,爲了防止內部人員進行非法IP盜用 (例如盜用權限更高人員的IP地址,以獲得權限外的信息),可以將內部網絡的IP地址與MAC地址綁定,盜用者即使修改了IP地址,也因MAC地址不匹配而盜用失敗:而且由於網卡MAC地址的唯一確定性,可以根據MAC地址查出使用該MAC地址的網卡,進而查出非法盜用者。
在Cisco中有以下三種方案可供選擇,方案1和方案2實現的功能是一樣的,即在具體的交換機端口上綁定特定的主機的MAC地址(網卡硬件地址),方案3是在具體的交換機端口上同時綁定特定的主機的MAC地址(網卡硬件地址)和IP地址。
1.方案1——基於端口的MAC地址綁定
思科2950交換機爲例,登錄進入交換機,輸入管理口令進入配置模式,敲入命令:
Switch#config terminal
#進入配置模式
Switch(config)# Interface fastethernet 0/1
#進入具體端口配置模式
Switch(config-if)#Switchport port-secruity
#配置端口安全模式
Switch(config-if )switchport port-security mac-address MAC(主機的MAC地址)
#配置該端口要綁定的主機的MAC地址
Switch(config-if )no switchport port-security mac-address MAC(主機的MAC地址)
#刪除綁定主機的MAC地址
注意:
以上命令設置交換機上某個端口綁定一個具體的MAC地址,這樣只有這個主機可以使用網絡,如果對該主機的網卡進行了更換或者其他PC機想通過這個端口使用網絡都不可用,除非刪除或修改該端口上綁定的MAC地址,才能正常使用。
注意:
以上功能適用於思科2950、3550、4500、6500系列交換機
2.方案2——基於MAC地址的擴展訪問列表
Switch(config)Mac access-list extended MAC10
#定義一個MAC地址訪問控制列表並且命名該列表名爲MAC10
Switch(config)permit host 0009.6bc4.d4bf any
#定義MAC地址爲0009.6bc4.d4bf的主機可以訪問任意主機
Switch(config)permit any host 0009.6bc4.d4bf
#定義所有主機可以訪問MAC地址爲0009.6bc4.d4bf的主機
Switch(config-if )interface Fa0/20
#進入配置具體端口的模式
Switch(config-if )mac access-group MAC10 in
#在該端口上應用名爲MAC10的訪問列表(即前面我們定義的訪問策略)
Switch(config)no mac access-list extended MAC10
#清除名爲MAC10的訪問列表
此功能與應用一大體相同,但它是基於端口做的MAC地址訪問控制列表限制,可以限定特定源MAC地址與目的地址範圍。
注意:
以上功能在思科2950、3550、4500、6500系列交換機上可以實現,但是需要注意的是2950、3550需要交換機運行增強的軟件鏡像(Enhanced Image)。
3.方案3——IP地址的MAC地址綁定
只能將應用1或2與基於IP的訪問控制列表組合來使用才能達到IP-MAC 綁定功能。
Switch(config)Mac access-list extended MAC10
#定義一個MAC地址訪問控制列表並且命名該列表名爲MAC10
Switch(config)permit host 0009.6bc4.d4bf any
#定義MAC地址爲0009.6bc4.d4bf的主機可以訪問任意主機
Switch(config)permit any host 0009.6bc4.d4bf
#定義所有主機可以訪問MAC地址爲0009.6bc4.d4bf的主機
Switch(config)Ip access-list extended IP10
#定義一個IP地址訪問控制列表並且命名該列表名爲IP10
Switch(config)Permit 192.168.0.1 0.0.0.0 any
#定義IP地址爲192.168.0.1的主機可以訪問任意主機
Permit any 192.168.0.1 0.0.0.0
#定義所有主機可以訪問IP地址爲192.168.0.1的主機
Switch(config-if )interface Fa0/20
#進入配置具體端口的模式
Switch(config-if )mac access-group MAC10 in
#在該端口上應用名爲MAC10的訪問列表(即前面我們定義的訪問策略)
Switch(config-if )Ip access-group IP10 in
#在該端口上應用名爲IP10的訪問列表(即前面我們定義的訪問策略)
Switch(config)no mac access-list extended MAC10
#清除名爲MAC10的訪問列表
Switch(config)no Ip access-group IP10 in
#清除名爲IP10的訪問列表
上述所提到的應用1是基於主機MAC地址與交換機端口的綁定,方案2是基於MAC地址的訪問控制列表,前兩種方案所能實現的功能大體一樣。如果要做到IP 與 MAC地址的綁定只能按照方案3來實現,可根據需求將方案1或方案2與IP訪問控制列表結合起來使用以達到自己想要的效果。
注意:以上功能在思科2950、3550、4500、6500系列交換機上可以實現,但是需要注意的是2950、3550需要交換機運行增強的軟件鏡像(Enhanced Image)。
後注:從表面上看來,綁定MAC地址和IP地址可以防止內部IP地址被盜用,但實際上由於各層協議以及網卡驅動等實現技術,MAC地址與IP地址的綁定存在很大的缺陷,並不能真正防止內部IP地址被盜用。
交換機支持的命令
1. linux 命令:
PCA login: root ;使用root用戶
password: linux ;口令是linux
# shutdown -h now ;同init 0 關機
# logout
# login
# ifconfig ;顯示IP地址
# ifconfig eth0 <ip address> netmask <netmask> ;設置IP地址
# ifconfig eht0 <ip address> netmask <netmask> down ; 刪除IP地址
# route add 0.0.0.0 gw <ip>
# route del 0.0.0.0 gw <ip>
# route add default gw <ip> ;設置網關
# route del default gw <ip> ;刪除網關
# route ;顯示網關
# ping <ip>
# telnet <ip>

2. 交換機支持的命令:
交換機基本狀態:
switch: ;交換機的ROM狀態
rommon> ;路由器的ROM狀態
hostname> ;用戶模式
hostname# ;特權模式
hostname(config)# ;全局配置模式
hostname(config-if)# ;接口狀態

交換機口令設置:
switch>enable ;進入特權模式
switch#config terminal ;進入全局配置模式
switch(config)#hostname <hostname> ;設置交換機的主機名
switch(config)#enable secret xxx ;設置特權加密口令
switch(config)#enable password xxa ;設置特權非密口令
switch(config)#line console 0 ;進入控制檯口
switch(config-line)#line vty 0 4 ;進入虛擬終端
switch(config-line)#login ;允許登錄
switch(config-line)#password xx ;設置登錄口令xx
switch#exit ;返回命令

交換機VLAN設置:
switch#vlan database ;進入VLAN設置
switch(vlan)#vlan 2 ;建VLAN 2
switch(vlan)#no vlan 2 ;刪vlan 2
switch(config)#int f0/1 ;進入端口1
switch(config-if)#switchport access vlan 2 ;當前端口加入vlan 2
switch(config-if)#switchport mode trunk ;設置爲幹線
switch(config-if)#switchport trunk allowed vlan 1,2 ;設置允許的vlan
switch(config-if)#switchport trunk encap dot1q ;設置vlan 中繼
switch(config)#vtp domain <name> ;設置發vtp域名
switch(config)#vtp password <word> ;設置發vtp密碼
switch(config)#vtp mode server ;設置發vtp模式
switch(config)#vtp mode client ;設置發vtp模式

交換機設置IP地址:
switch(config)#interface vlan 1 ;進入vlan 1
switch(config-if)#ip address <IP> <mask> ;設置IP地址
switch(config)#ip default-gateway <IP> ;設置默認網關
switch#dir flash: ;查看閃存

交換機顯示命令:
switch#write ;保存配置信息
switch#show vtp ;查看vtp配置信息
switch#show run ;查看當前配置信息
switch#show vlan ;查看vlan配置信息
switch#show interface ;查看端口信息
switch#show int f0/0 ;查看指定端口信息


3. 路由器支持的命令:
路由器顯示命令:
router#show run ;顯示配置信息
router#show interface ;顯示接口信息
router#show ip route ;顯示路由信息
router#show cdp nei ;顯示鄰居信息
router#reload     ;重新起動

路由器口令設置:
router>enable ;進入特權模式
router#config terminal ;進入全局配置模式
router(config)#hostname <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> <netmask> ;設置IP地址
router(config-if)#ip address <ip> <netmask> second ;設置第二個IP
router(config-if)#int f0/0.1 ;進入子接口
router(config-***if.1)#ip address <ip> <netmask> ;設置子接口IP
router(config-***if.1)#encapsulation dot1q <n> ;綁定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:<sname> flash:<dname> ;從console傳輸文件
Cisco 2960設置管理地址問題
我這裏有個2960,準備配置管理地址,配置應該沒有問題,可是就是無法連通,在此臺2960上也無法Ping通網關,相關配置如下
interface GigabitEthernet0/2
switchport mode trunk
spanning-tree link-type point-to-point
interface Vlan241
ip address 192.168.241.53 255.255.255.0
no ip redirects
no ip unreachables
no ip proxy-arp
no ip route-cache
!
ip default-gateway 192.168.241.1
交換機工作正常,但是使用Show inter vlan241,發現接口處於Down狀態,使用No shutdown 命令也沒有用,不知道怎麼回事情?是不是和VTP有關?謝謝! 
網友1;
方法兩個:
1、把你見vlan號給刪除,給vlan1配置ip地址
2、修改你配置vlan的native vlan 
網友2:
cisco的vlan1默認爲管理vlan,只要給它配各地址就行了 
網友3:
1.show vlan看本交換機有沒有VLAN241
如果沒有可以手工添加上去
或者啓用VTP學習
2.show int g0/2 trunk信息
網友4:
1、show vlan brief 看一下有沒有這個vlan
2、如果數據vlan和管理vlan分開,看看上聯的trunk起來沒有 
網友5:
29交換機管理VLAN默認就是VLAN1,你的問題有兩種方法:
1、取消VLAN241的IP地址
interface vlan 1
ip add 192.168.241.53 255.255.255.0
2、是將VLAN241設置成管理VLAN
interface vlan 241
ip add 192.168.241.53 255.255.255.0
management-----------是將該VLAN設置成管理VLAN
你任選一種就可以的

 

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