萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 路由器知識 >> 路由器設定 >> Cisco 思科路由器

思科路由器 VLAN IP 配置與常用基礎命令速查

VLAN (Virtual Local Area Network) 將物理網絡劃分為邏輯廣播域,提升安全性與管理靈活性。本文詳細演示思科路由器配置 VLAN 子接口 IP 的 5 步法,並附贈路由器/交換機 IP 配置、靜態/默認/浮動路由等高頻命令速查表。

一、 VLAN 子接口 IP 配置 5 步法

場景:在 FastEthernet 4/0 物理接口下創建 VLAN 333 子接口,IP 192.168.1.13/24

! 1. 進入物理接口
host1(config)# interface fastEthernet 4/0

! 2. 封裝協議 (通常為 802.1Q)
host1(config-if)# encapsulation dot1Q 333

! 3. 創建子接口 (編號習慣與 VLAN ID 一致)
host1(config-if)# interface fastEthernet 4/0.333

! 4. 指定 VLAN ID (封裝命令已隱含,此行視具體 IOS 版本而定)
host1(config-subif)# encapsulation dot1Q 333

! 5. 配置 IP 地址
host1(config-subif)# ip address 192.168.1.13 255.255.255.0
host1(config-subif)# no shutdown

注意: 原文 encapsulation vlan 及 vlan id 333 非標準 Cisco IOS 命令,實際應用中請使用 encapsulation dot1Q <vlan-id>。


二、 網絡設備基礎配置命令速查

1. 路由器接口 IP 配置

router(config)# interface fastethernet 0/1
router(config-if)# ip address 192.168.1.100 255.255.255.0
router(config-if)# no shutdown

2. 三層交換機 SVI 配置

switch(config)# interface vlan 1
switch(config-if)# ip address 192.168.1.100 255.255.255.0
switch(config-if)# no shutdown

3. 靜態路由

router(config)# ip route 192.168.1.0 255.255.255.0 192.168.10.1

4. 默認路由 (網關)

router(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.1

5. 浮動路由 (備用鏈路,AD=50)

router(config)# ip route 192.168.1.0 255.255.255.0 192.168.10.1 50
router(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.1 50

6. 交換機默認網關 (便於遠程管理)

switch(config)# ip default-gateway 192.168.2.254

7. 輔助 IP 地址 (單接口多網段)

switch(config-if)# ip address 192.168.1.1 255.255.255.0 secondary

三、 實戰提示

  • 子接口編號無強制規範,建議與 VLAN ID 一致,便於運維
  • 路由器採用「單臂路由」做 VLAN 間路由時,物理接口不配 IP,僅子接口配 IP
  • 浮動路由 AD 值須大於主路由協議 AD (OSPF=110, RIP=120, 靜態=1)
  • 配置變更後務必 write memory 或 copy running-config startup-config 保存
copyright © 萬盛學電腦網 all rights reserved