思科交换机配置
?
一、思科交換機基本配置命令
1:進入特權模式 enable
switch> enable
switch#
?
2:進入全局配置模式 configure terminal
switch> enable
switch#c onfigure terminal
switch(conf)#
?
3:交換機命名 hostname aptech2950 以 aptech2950 為例
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch-2950
aptech2950(conf)#
?
4:配置使能口令 enable password cisco 以 cisco 為例
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# enable password cisco
?
5:配置使能密碼 enable secret ciscolab 以 cicsolab 為例
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# enable secret ciscolab
?
6:創(chuàng)建多個vlan
1、創(chuàng)建多個VLAN
Switch>enable????(進入特權模式)
Switch#vlan data? ? (進入vlan配置模式)
Switch(vlan)#vlan 10 name?IT? ? (劃分vlan10,名稱為IT)
Switch(vlan)#vlan 20 name?HR? ? (劃分vlan20,名稱為HR)
Switch(vlan)#vlan 30 name FIN? ?(劃分vlan30,名稱為FIN)
Switch(vlan)#vlan 40 name?LOG? ? (劃分vlan40,名稱為LOG)
Switch(vlan)#exit
?
7:設置 vlan 1
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# interface vlan 1
aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0 配置交換機端口 ip 和子網(wǎng)掩碼
?
aptech2950(conf-if)#no shut 是配置處于運行中
aptech2950(conf-if)#exit
aptech2950(conf)#ip default-gateway 192.168.254 設置網(wǎng)關地址
?
8:進入交換機某一端口 interface fastehernet 0/17 以 17 端口為例
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# interface fastehernet 0/17
aptech2950(conf-if)#
?
9:查看命令 show
switch> enable
switch# show version 察看系統(tǒng)中的所有版本信息
show interface vlan 1 查看交換機有關 ip 協(xié)議的配置信息
show running-configure 查看交換機當前起作用的配置信息
show interface fastethernet 0/1 察看交換機 1 接口具體配置和統(tǒng)計信息
show mac-address-table 查看 mac 地址表
show mac-address-table aging-time 查看 mac 地址表自動老化時間
?
10:交換機恢復出廠默認恢復命令
switch> enable
switch# erase startup-configure
switch# reload
?
11:雙工模式設置
switch> enable
switch#c onfigure terminal
switch2950(conf)#hostname aptch-2950
aptech2950(conf)# interface fastehernet 0/17 以 17 端口為例
aptech2950(conf-if)#duplex full/half/auto 有 full , half, auto 三個可選
項
?
11:cdp 相關命令
switch> enable
switch# show cdp 查看設備的 cdp 全局配置信息
show cdp interface fastethernet 0/17 查看 17 端口的 cdp 配置信息
show cdp traffic 查看有關 cdp 包的統(tǒng)計信息
show cdp nerghbors 列出與設備相連的 cisco 設備
?
?
12:交換機 telnet 遠程登錄設置:
switch>en
switch#c onfigure terminal
switch(conf)#hostname aptech-2950
aptech2950(conf)#enable password cisco 以 cisco 為特權模式密碼
aptech2950(conf)#interface fastethernet 0/1 以 17 端口為 telnet 遠程登錄端口
aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0
aptech2950(conf-if)#no shut
aptech2950(conf-if)#exit
aptech2950(conf)line vty 0 4 設置 0-4 個用戶可以 telnet 遠程登陸
aptech2950(conf-line)#login
aptech2950(conf-line)#password edge 以 edge 為遠程登錄的用戶密碼
主機設置:
ip 192.168.1.2 主機的 ip 必須和交換機端口的地址在同一網(wǎng)絡
段
netmask 255.255.255.0
gate-way 192.168.1.1 網(wǎng)關地址是交換機端口地址
運行:
telnet 192.168.1.1
進入 telnet 遠程登錄界面
password : edge
aptech2950>en
password: cisco
aptech#
?
?
二、利用三層交換機,實現(xiàn)不同vlan間互相通信
上面我們了解了思科交換機的基本配置命令,下面我們來看下配置案例。
?
案例如下:
pc1與pc2由于阻絕在了兩個不同的交換機里,且在不同的vlan中,是無法通信的,那怎么辦呢?
?
S3550-24(三層交換機)1臺、S2126交換機1臺、pc1在vlan10里,pc2在vlan20里,如下圖所示。
? ? ? ? ? ? ? ?
VLAN間通信實驗拓撲結構圖
?
?
?配置如下:
1、在交換機SwitchA上創(chuàng)建VLAN 20,并將F0/15口劃分到VLAN 20中。
SwitchA>enable
SwitchA#configure terminal?
SwitchA(config)#vlan20????????????//創(chuàng)建VLAN 20
SwitchA(config-vlan)#name vlan20? ? //將VLAN 20 命名為vlan20
SwitchA(config)#interface f0/15???????//進入F0/15接口配置模式
SwitchA(config-if)#switchport access vlan 20????//將F0/15端口劃入VLAN 20
SwitchA #showvlan id 20????//驗證已創(chuàng)建了VLAN 20并已將F0/15端口劃入VLAN 20中。
?
2、在交換機SwitchA上與SwitchB相連的端口(此處為F0/24端口)定義為tag vlan 模式。
SwitchA>enable
SwitchA#configure terminal?
SwitchA (config)#interface f0/24???????????? //進入接口配置模式
SwitchA (config-if)#switchport mode trunk???? //將F0/24口設置為tag vlan模式
SwitchA (config)#show interfaces f0/24 switch? //驗證F0/24口已被設置為tag vlan模式
?
?
3、在交換機SwitchB上創(chuàng)建VLAN 10,并將F0/5端口劃入VLAN 10中。
SwitchA>enable
SwitchA#configure terminal?
SwitchB(config)#vlan 10? ? ? ? ? ? ? ? ? //創(chuàng)建VLAN 10
SwitchB (config-vlan)#name vlan10? ? //將VLAN 10 命名為vlan
SwitchB (config)#interface f0/5??????//進入F0/5接口配置模式
SwitchB (config-if)#switchport access vlan10??? !將F0/5端口劃入VLAN 10
SwitchB #show vlan id 10? ? ??//驗證已創(chuàng)建了VLAN 10并已將F0/5端口劃入VLAN 10中
?
?
4、在交換機SwitchB上與SwitchA相連的端口(此處為F0/24端口)定義為tag vlan 模式。
?
SwitchA>enable
SwitchA#configure terminal?
SwitchB (config)#interface f0/24????????????//進入接口配置模式
SwitchB (config-if)#switchport mode trunk?????//將F0/24口設置為tag vlan模式
SwitchB (config)#show interfaces f0/24 switch //驗證F0/24口已被設置為tag vlan模式。
?
5、設置三層交換機VLAN 間通訊,開啟三層交換機的路由功能
SwitchA>enable
SwitchA#configure terminal?
SwitchA(config)#ip routing??????????//開啟三層交換機的路由功能
?
SwitchA(config) #interface vlan 10?????//創(chuàng)建虛擬接口vlan10
SwitchA(config-if) #ip address 192.168.10.254 255.255.255.0???//配置vlan10的虛擬接口ip地址
SwitchA(config) #interface vlan 20????//創(chuàng)建虛擬接口vlan20
?配置vlan20的虛擬接口ip地址
SwitchA(config-if) #ip address 192.168.20.254 255.255.255.0???//配置vlan20的虛擬接口ip地址
?
5、配置默認網(wǎng)關
將PC1的默認網(wǎng)關設置為192.168.10.254,將PC2的默認網(wǎng)關設置為192.168.20.254
?
?如此,pc1與pc2便可以相互通
?
END
?
?
總結
- 上一篇: 一小时学会Ansible自动化运维
- 下一篇: 9月PMP考试起用新考纲,这些变化你了解