查看版本信息
show version
启用 root
en
全局配置模式
conf t
设置密码
enable secret <password>
设置横幅广告
banner motd #
设置静态路由
ip route 0.0.0.0 0.0.0.0 192.168.1.1 255.255.255.0
启用密码加密
service password-encryption
显示正在运行的配置
do show run <- on global config
show run <- on other mode
设置主机名
hostname example
远程管理
使用IP地址设置交换机以进行远程管理
- 默认管理界面是
vlan1
int vlan1
- 设置 vlan1 的 IPv4 地址
ip address 192.168.1.137 255.255.255.0
设置默认网关
# make sure we go back to the gloabl config to run this
ip default-gateway 192.169.1.1
设置用于远程管理的 IP 域名
ip domain-name example.com
生成 RSA 密钥
example(config)#crypto key generate rsa
The name for the keys will be:
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 1024
example(config)#
在这里,如果我们看一下接口,我们可以找到一个名为 near the end 的新接口do show run
line vty 0 4
...
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
!
!
end
得到这个之后,我们可以输入来访问这个接口line vty 0 4
line vty 0 4
设置 ssh
进入后,我们可以做line vty 0 4
line vty 0 4
transport input ssh
login local
password <password>
exit
line con 0
logging synchronous
login local
exit
username admin password password
确保已启用 SSH
sh ip ssh
创建 VLAN
例如,如果我们想在开关 en 中创建一个,我们可以键入 (确保我们在全局配置中)vlan 10
vlan 10
为 VLAN 分配名称
name example
查看创建的 VLAN
我们可以键入以查看创建的 VLANshow vlan
example#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig0/1, Gig0/2
10 example active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
10 enet 100010 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
--More--
为 VLAN 分配接口
在查看时,我们还可以看到可用的端口。我们可以通过以下方式转到其中一个接口/端口vlans
int Fa0/1
- 通过键入
switchport mode access
- 将端口分配给 VLAN
switchport access vlan 10
type 和no shutdown
exit
查看 VLAN 配置
如果我们通过键入来查看 VLAN,我们可以看到端口 1 确实与 VLAN 10 相关联(示例)do show vlan
10 example active Fa0/1
为 VLAN 分配 IP 地址
int vlan 10
ip address 192.168.1.1 255.255.255.0
exit
查看分配的 IP 地址
我们可以返回 en 并键入
show ip interface brief
example#show ip interface brief
Interface IP-Address OK? Method Status Protocol
...
Vlan1 unassigned YES manual administratively down down
Vlan10 192.168.1.1 YES manual up down
最后,我们可以看到分配给 vlan 10 的 IP 地址
在 VLAN 之间设置 IP 路由
转到全局配置
ip routing
重新加载/保存配置
reload
技巧
如果我们处于不同的级别,例如全局配置,我们不能像 root 命令那样运行,但我们可以在命令前面附加,这样我们就可以在任何地方运行它,无论什么例子,甚至无论如何都可以在全局配置上工作
show vlan
do
do show vlan