| 模式 | 提示符 | 進入命令 | 退出命令 |
|---|---|---|---|
| ROM Monitor | switch: | 斷電重啟/斷電恢復 | boot |
| 用戶模式 | Switch> | 預設登入 | disable / exit |
| 特權模式 | Switch# | enable | disable / exit |
| 全局配置 | Switch(config)# | configure terminal | exit / end |
| 介面配置 | Switch(config-if)# | interface | exit |
| VLAN配置 | Switch(vlan)# | vlan database | exit |
| 線路配置 | Switch(config-line)# | line console 0 / vty 0 4 | exit |
! 主機名
hostname SW-CORE-01
! 特權加密密碼 (推薦)
enable secret Cisco@123
! 控制台線路密碼
line console 0
password Console@123
login
logging synchronous
exec-timeout 5 0
! VTY遠程管理 (0-4共5條會話)
line vty 0 4
password Vty@123
login
transport input ssh
exec-timeout 10 0
! 進入VLAN數據庫模式 (舊版IOS) / 現代IOS直接全局下創建
vlan 10
name MGMT
exit
! 介面加入VLAN
interface FastEthernet0/1
switchport mode access
switchport access vlan 10
! Trunk幹線配置
interface GigabitEthernet1/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20,30
switchport trunk native vlan 999
! VTP域配置
vtp domain ENTERPRISE
vtp mode server
vtp password Vtp@Secret
vtp version 2
interface Vlan10
ip address 192.168.10.2 255.255.255.0
no shutdown
exit
ip default-gateway 192.168.10.1
show running-config ! 當前生效配置
show vlan brief ! VLAN摘要
show interfaces status ! 所有端口狀態速覽
show interfaces Gi1/1 ! 指定端口詳細
show vtp status ! VTP狀態
show spanning-tree ! 生成樹狀態
write memory / copy run start ! 保存配置
nameif ethernet0 outside security0
nameif ethernet1 inside security100
nameif ethernet2 dmz security50
interface ethernet0 auto
interface ethernet1 100full
interface ethernet2 100full
ip address inside 192.168.1.1 255.255.255.0
ip address outside 203.0.113.1 255.255.255.252
ip address dmz 172.16.1.1 255.255.255.0
! 定義全局地址池 (PAT)
global (outside) 1 203.0.113.2-203.0.113.10 netmask 255.255.255.248
! 內網所有主機PAT到外網
nat (inside) 1 0.0.0.0 0.0.0.0
! DMZ網段PAT
nat (dmz) 1 172.16.1.0 255.255.255.0
! 內網Web服務器映射到公網IP
static (inside,outside) 203.0.113.3 192.168.1.10 netmask 255.255.255.255
! DMZ郵件服務器
static (dmz,outside) 203.0.113.4 172.16.1.10 netmask 255.255.255.255
route outside 0.0.0.0 0.0.0.0 203.0.113.2 1
route inside 10.0.0.0 255.0.0.0 192.168.1.254 1
router bgp 65001
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 203.0.113.0 mask 255.255.255.0
neighbor 203.0.113.2 remote-as 65002
neighbor 203.0.113.2 description ISP-UPLINK
neighbor 203.0.113.2 password Bgp@Secret
neighbor 203.0.113.2 timers 30 90
username BRANCH-R1 password Branch@123
!
interface Serial0/0/0
encapsulation ppp
ppp authentication chap pap
ppp chap hostname HQ-R1
ppp chap password HQ@Secret
提示:本手冊針對經典IOS/PIX語法,新版IOS-XE、ASA、NX-OS命令有差異,請參考對應版本官方命令參考手冊。