?以下是交換機配置的詳細步驟指南,適用于Cisco交換機,其他品牌需調整命令:
1. 初始連接與基本配置
- 連接方式:使用Console線連接交換機,通過終端軟件(如PuTTY)登錄。
- 波特率:9600,數據位8,停止位1,無奇偶校驗。
Switch> enable
Switch# configure terminal
Switch(config)# hostname OfficeSwitch
?2. 配置管理IP和默認網關
OfficeSwitch(config)# interface vlan 1
OfficeSwitch(config-if)# ip address 192.168.1.2 255.255.255.0
OfficeSwitch(config-if)# no shutdown
OfficeSwitch(config-if)# exit
OfficeSwitch(config)# ip default-gateway 192.168.1.1
?3. 創建VLAN并命名
OfficeSwitch(config)# vlan 10
OfficeSwitch(config-vlan)# name Employees
OfficeSwitch(config-vlan)# exit
OfficeSwitch(config)# vlan 20
OfficeSwitch(config-vlan)# name Guests
OfficeSwitch(config-vlan)# exit
4. 配置訪問端口(Access Ports)
- 端口1-10分配給VLAN 10:
OfficeSwitch(config)# interface range GigabitEthernet0/1-10
OfficeSwitch(config-if-range)# switchport mode access
OfficeSwitch(config-if-range)# switchport access vlan 10
OfficeSwitch(config-if-range)# no shutdown
OfficeSwitch(config-if-range)# exit
- 端口11-20分配給VLAN 20:
?5. 配置Trunk端口(連接路由器)
OfficeSwitch(config)# interface GigabitEthernet0/24
OfficeSwitch(config-if)# switchport mode trunk
OfficeSwitch(config-if)# switchport trunk allowed vlan 1,10,20
OfficeSwitch(config-if)# no shutdown
OfficeSwitch(config-if)# exit
?
驗證命令
- 查看VLAN配置:
show vlan brief
- 檢查端口狀態:
show interfaces status
- 驗證Trunk配置:
show interfaces trunk
- 測試SSH連接:從遠程設備使用
ssh admin@192.168.1.2
注意事項
- 安全建議:禁用Telnet(
transport input none
),啟用SSHv2(ip ssh version 2
)。 - 端口安全:可選配置限制MAC地址(如
switchport port-security maximum 1
)。 - 固件升級:定期檢查并更新交換機操作系統。
?
?