# 電腦網路實習 Lab1 ## :heavy_exclamation_mark:操作模式介紹 > 在Cisco設備的命令行介面(CLI)中,不同的提示符號代表了用戶當前所處的操作模式。每種模式都有其特定的用途和可以執行的命令範圍。以下是你問的提示符號的含意: > > - `switch>`:這是**用戶模式**(User EXEC mode)的提示符。在這個模式下,用戶可以查看設備的狀態,但不能進行配置。這個模式提供了一些基本的命令來檢測設備的運行狀態,例如查看路由表、介面狀態等。 > > - `switch#`:這是**特權模式**(Privileged EXEC mode)的提示符。進入這個模式後,用戶可以執行更高級的命令,包括查看配置、測試網絡連接、重啟設備等。這個模式提供了比用戶模式更多的控制和查詢能力,並且是進入配置模式的前提。 > > - `switch(config)#`:這是**全局配置模式**(Global Configuration mode)的提示符。在這個模式下,用戶可以對設備進行全面的配置,包括設置系統級別的參數,如接口配置、路由協議配置、VLAN配置等。這個模式允許用戶修改設備的運行配置。 > > - `switch(config-if)#`:這是**接口配置模式**(Interface Configuration mode)的提示符。當你進入一個特定的接口進行配置時,CLI會切換到這個模式。在這個模式下,用戶可以對特定的網絡接口進行配置,如設置IP地址、子網掩碼、啟用或禁用接口等。這個模式專注於對單個接口的配置。 ## 手把手教學(精簡版) ### Instruction ```bash= 1. 設置特權模式密碼 enable configure terminal enable secret <你的密碼> 2. 設置一個新的VLAN並將一個介面加入這個新的VLAN vlan 2 name new_vlan // 可加可不加 exit interface fastEthernet 0/2 switchport access vlan 2 exit 3. 為VLAN設置IP地址 interface vlan 2 ip address 192.168.4.1 255.255.255.0 exit 4. 直接在交換機端口上設置端口安全 interface fastEthernet 0/2 switchport mode access switchport port-security switchport port-security mac-address sticky end // 檢查 show running-config show vlan brief show port-security interface fastEthernet 0/2 ``` ## 老師寫的 ### Instruction ```bash= // 1. 設置特權模式密碼 enable configure terminal enable secret <你的密碼> // 2. 設置一個新的VLAN並將一個介面加入這個新的VLAN vlan 2 exit interface fastEthernet 0/2 switchport access vlan 2 exit // 3. 為VLAN設置IP地址 interface vlan 2 ip address 192.168.4.1 255.255.255.0 do show vlan // 等於show vlan brief do show run // 等於show running-config exit // 4. 直接在交換機端口上設置端口安全 interface fastEthernet 0/2 switchport mode access switchport port-security switchport port-security mac-address sticky end // 給老師檢查 show port-security interface fastEthernet 0/2 show running-config show vlan brief ``` ## Result 1. show running-config ![image](https://hackmd.io/_uploads/BJ8gW-IT6.png) ![image](https://hackmd.io/_uploads/rki4--LTp.png) --- 2. show vlan brief ![image](https://hackmd.io/_uploads/Hkfig-UTT.png) --- 3. show port-security interface fa0/2 ![image](https://hackmd.io/_uploads/Hk75ZZLTa.png)