三層交換機的配置命令
步驟一:給交換機配置IP地址
S2724G#conf
S2724G(config)#int vlan 1
S2724G(config-if)#ip addess 192.168.0.100 255.255.255.0
----給VLAN 1配置IP地址
S2724G(config-if)#no shutdown ----激活該VLAN接口
S2724G(config-if)#exit
S2724G(config)#ip default-gateway 192.168.0.1 ----指定交換機的網(wǎng)關(guān)地址
步驟二:創(chuàng)建VLAN
S2724G#conf
S2724G(config)#vlan 10 ----創(chuàng)建VLAN 10
S2724G(config-vlan)#exit
S2724G(config)# vlan 20 ----創(chuàng)建VLAN 20
S2724G(config-vlan)#exit
步驟三:把相應(yīng)接口指定到相應(yīng)的VLAN中
S2724G(config)#int gi 0/10
S2724G(config-if)#switch access vlan 10
----把交換機的第10端口劃到VLAN 10中
S2724G(config-if)#exit
S2724G(config)#int gi 0/20
S2724G(config-if)#switch access vlan 20
----把交換機的第20端口劃到VLAN 20中
S2724G(config-if)#exit
S2724G(config)#int gi 0/24
S2724G(config-if)#switch mode trunk
----設(shè)置24口為Trunk模式(與三層交換機的連接口
S2724G(config-if)#
步驟四:保存配置
S2724G(config-if)#end
S2724G#write
模式轉(zhuǎn)換命令
用戶模式----特權(quán)模式,使用命令“enable”
特權(quán)模式----全局配置模式,使用命令“config t”
全局配置模式----接口模式,使用命令“interface+接口類型+接口號”
全局配置模式----線控模式,使用命令“l(fā)ine+接口類型+接口號”
注:
用戶模式:查看初始化的信息。
特權(quán)模式:查看所有信息、調(diào)試、保存配置信息
全局模式:配置所有信息、針對整個路由器或交換機的所有接口
接口模式:針對某一個接口的配置
線控模式:對路由器進行控制的接口配置
(2)配置命令
show running config 顯示所有的配置
show versin 顯示版本號和寄存器值
shut down 關(guān)閉接口
no shutdown 打開接口
ip add +ip地址 配置IP地址
secondary+IP地址 為接口配置第二個IP地址
show interface+接口類型+接口號 查看接口管理性
show controllers interface 查看接口是否有DCE電纜
show history 查看歷史記錄
show terminal 查看終端記錄大小
hostname+主機名 配置路由器或交換機的標(biāo)識
config memory 修改保存在NVRAM中的啟動配置
exec timeout 0 0 設(shè)置控制臺會話超時為0
service password-encryptin 手工加密所有密碼
enable password +密碼 配置明文密碼
ena sec +密碼 配置密文密碼
line vty 0 4/15 進入telnet接口
password +密碼 配置telnet密碼
line aux 0 進入AUX接口
password +密碼 配置密碼
line con 0 進入CON接口
password +密碼 配置密碼
bandwidth+數(shù)字 配置帶寬
no ip address 刪除已配置的IP地址
show startup config 查看NVRAM中的配置信息
copy run-config atartup config 保存信息到NVRAM
write 保存信息到NVRA
erase startup-config 清除NVRAM中的配置信息
show ip interface brief 查看接口的謫要信息
banner motd # +信息 + # 配置路由器或交換機的描素信息
description+信息 配置接口聽描素信息
vlan database 進入VLAN數(shù)據(jù)庫模式
vlan +vlan號+ 名稱 創(chuàng)建VLAN
switchport access vlan +vlan號 為VLAN為配接口
interface vlan +vlan號 進入VLAN接口模式
ip add +ip地址 為VLAN配置管理IP地址
vtp+service/tracsparent/client 配置SW的VTP工作模式
vtp +domain+域名 配置SW的VTP域名
vtp +password +密碼 配置SW的密碼
switchport mode trunk 啟用中繼
no vlan +vlan號 刪除VLAN
show spamming-tree vlan +vlan號 查看VLA怕生成樹議
2. 路由器配置命令
ip route+非直連網(wǎng)段+子網(wǎng)掩碼+下一跳地址 配置靜態(tài)/默認路由
show ip route 查看路由表
show protocols 顯示出所有的被動路由協(xié)議和接口上哪些協(xié)議被設(shè)置
show ip protocols 顯示了被配置在路由器上的路由選擇協(xié)議,同時給出了在路由選擇協(xié)議中使用
的定時器
等信息
router rip 激活RIP協(xié)議
network +直連網(wǎng)段 發(fā)布直連網(wǎng)段
interface lookback 0 激活邏輯接口
passive-interface +接口類型+接口號 配置接口為被動模式
debug ip +協(xié)議 動態(tài)查看路由更新信息
undebug all 關(guān)閉所有DEBUG信息
router eigrp +as號 激活EIGRP路由協(xié)議
network +網(wǎng)段+子網(wǎng)掩碼 發(fā)布直連網(wǎng)段
show ip eigrp neighbors 查看鄰居表
show ip eigrp topology 查看拓撲表
show ip eigrp traffic 查看發(fā)送包數(shù)量
router ospf +process-ID 激活OSPF協(xié)議
network+直連網(wǎng)段+area+區(qū)域號 發(fā)布直連網(wǎng)段
show ip ospf 顯示OSPF的進程號和ROUTER-ID
encapsulation+封裝格式 更改封裝格式
no ip admain-lookup 關(guān)閉路由器的域名查找
ip routing 在三層交換機上啟用路由功能
show user 查看SW的在線用戶
clear line +線路號 清除線路
3. 三層交換機配置命令
配置一組二層端口
configure terminal 進入配置狀態(tài)
nterface range {port-range} 進入組配置狀態(tài)
配置三層端口
configure terminal 進入配置狀態(tài)
interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-
channel port-channel-number} 進入端口配置狀態(tài)
no switchport 把物理端口變成三層口
ip address ip_address subnet_mask 配置IP地址和掩碼
no shutdown 激活端口
例:
Switch(config)# interface gigabitethernet0/2
Switch(config-if)# no switchport
Switch(config-if)# ip address 192.20.135.21 255.255.255.0
Switch(config-if)# no shutdown
配置VLAN
configure terminal 進入配置狀態(tài)
vlan vlan-id 輸入一個VLAN號, 然后進入vlan配態(tài),可以輸入一個新的VLAN號或舊的來進行修改
name vlan-name 可選)輸入一個VLAN名,如果沒有配置VLAN名,缺省的名字是VLAN號前面用0填滿
的4位數(shù),如VLAN0004是VLAN4的缺省
名字
mtu mtu-size (可選) 改變MTU大小
例
Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# end
或
Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit
將端口分配給一個VLAN
configure terminal 進入配置狀態(tài)
interface interface-id 進入要分配的端口
switchport mode access 定義二層口
switchport access vlan vlan-id 把端口分配給某一VLAN
例
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#
配置VLAN trunk
configure terminal 進入配置狀態(tài)
interface interface-Id 進入端口配置狀態(tài)
switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封裝ISL 或 802.1Q 或
自動協(xié)商
switchport mode {dynamic {auto | desirable} | trunk} 配置二層trunk模式。
dynamic auto—自動協(xié)商是否成為trunk
dynamic desirable—把端口設(shè)置為trunk如果對方端口是trunk, desirable, 配置Native VLAN
?。?02.1q)
或自動模式,trunk—設(shè)置端口為強制的trunk方式,而不理會對方端口是否為trunk
switchport access vlan vlan-id 可選) 指定一個缺省VLAN, 如果此端口不再是trunk
switchport trunk native vlan vlan-id 指定802.1Q native VLAN號
例:
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# end
定義TRUNK允許的VLAN
configure terminal子 進入配置狀態(tài)
interface interface-id 進入端口配置
switchport mode trunk 配置二層口為trunk
switchport trunk allowed vlan {add | all | except | remove} vlan-list可選) 配置trunk允
許的VLAN.使用add, all, except, remove關(guān)健字
no switchport trunk allowed vlan 允許所有VLAN通過
例
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport trunk allowed vlan remove 2
Switch(config-if)# end
配置Native VLAN(802.1q)
configure terminal 進入配置狀態(tài)
interface interface-id 進入配置成802.1qtrunk的端口
switchport trunk native vlan vlan-Id 配置native VLAN號
no switchport trunk native vlan 端口配置命令回到缺省的狀態(tài)
配置基于端口權(quán)值的負載均衡
configure terminal 進入Switch 1配置狀態(tài)
vtp domain domain-name 配置VTP域
vtp mode server 將Switch 1配置成VTP server.
show vtp status 驗證VTP的配置
show vlan 驗證VLAN
configure terminal 進入配置狀態(tài)
interface fastethernet 0/1 進入F0/1端口
switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk
評論