#config terminal
(config)# service password-encryption 5、保存以上设置 >enable
#copy running-config strat-config
例2:设置交换机的各种密码
SW1>en SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#enable password myenable SW1(config)#line console 0 SW1(config-line)#password myline SW1(config-line)#login SW1(config-line)#line vty 0 4 SW1(config-line)#password myvty SW1(config-line)#login SW1(config-line)#exit SW1(config)#
四、配置IP地址及默认网关
例3:设置VLAN的IP地址及交换机的默认网关
Switch>en Switch#config t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#interface vlan 1 Switch(config-if)#ip address 192.168.1.2 255.255.255.0 Switch(config-if)#exit Switch(config)#interface vlan 2 Switch(config-if)#ip address 192.168.2.2 255.255.255.0 Switch(config-if)#exit Switch(config)#ip default-gateway 192.168.1.1 Switch(config)# 五、管理MAC地址表
switch#show mac-address-table 显示MAC地址列表
switch#clear mac-address-table dynamic 清除动态MAC地址列表
Switch(config)#mac-address-table static 0005.5ed3.c4b1 vlan 1 interface fastethernet 0/1 Switch#show mac
Mac Address Table
------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0005.5ed3.c4b1 STATIC Fa0/1 六、配置端口安全
switchport 用于端口配置,命令选项有:
access Set access mode characteristics of the interface mode Set trunking mode of the interface native Set trunking native characteristics when interface is in trunking mode nonegotiate Device will not engage in negotiation protocol on this interface port-security Security related command trunk Set trunking characteristics of the interface voice Voice appliance attributes switch(config-if)switchport port-security
switch(config-if)switchport port-security maximum 4
例4:设置 Switch>en Switch#config t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#interface f0/2 Switch(config-if)#switchport mode access Switch(config-if)#switchport port-security Switch(config-if)#switchport port-security maximum 4 Switch(config-if)#exit Switch(config)#interface f0/2 Switch(config-if)#switchport port-security ? mac-address Secure mac address maximum Max secure addresses violation Security violation mode Switch(config-if)#switchport port-security mac-address 000d.bd8c.6ccd Switch(config-if)#switchport port-security violation shutdown Switch(config-if)# 七、一个配置实例
图1 实例拓扑图
图10
图11
图12
图13 保存对交换机的配置
练习题:
相关推荐: