交换机基本配置——实验

使用模拟器:IOU
使用设备:一台三层交换机,两台路由器

实验拓扑:
在这里插入图片描述
实验步骤:

1)配置主机名:

Switch>enable
Switch#configure terminal
Switch(config)#hostname SW1    更改主机名为SW1

给路由器配置地址(用于测试)

R1(config)#interface ethernet 0/1
R1(config-if)#ip address 172.16.0.1 255.255.255.0
R1(config-if)#no shutdown 
R2(config)#interface ethernet 0/1
R2(config-if)#ip address 172.16.0.2 255.255.255.0
R2(config-if)#no shutdown

2)配置基本安全措施

SW1(config)#enable secret 123     设置密码为123
SW1(config)#service password-encryption     加密交换机上所有明文口令(MD5加密)
SW1(config)#line vty 0 4    开启VTY端口0~4
SW1(config-line)#password cisco    设置登入密码为cisco
SW1(config-line)#login    开启远程登录密码验证
SW1(config)#line console 0    进入终端控制口
SW1(config-line)#password cisco123    设置console口密码为cisco123
SW1(config-line)#login    开启远程登陆验证

注:
1.VTY(虚拟类型终端)是虚拟终端口,用于远程登录的虚拟端口
2.login 与login local的区别:login仅为开启远程登录验证;login local需要本地配置用户名和密码才能进行验证

3)接口基本配置
交换机接口默认为开启;对于交换机的以太网接口,可配置双工模式和接口速度

SW1(config)#interface ethernet 0/1
SW1(config-if)#duplex ?    (配置接口双模模式)
	auto  Enable AUTO duplex configuration(自动检测双工模式)
	full  Force full duplex operation(全双工)
	half  Force half-duplex operation(半双工)
SW1(config-if)#speed ?   (配置交换机的接口速度)
	10    Force 10 Mbps operation(10Mbps)
	100   Force 100 Mbps operation(100Mbps)
	auto  Enable AUTO speed configuration(自动检测接口速度)
SW1(config-if)#mdix auto    (开启介质检测功能,这样接口上使用什么线缆都无所谓了)
SW1(config-if)#description 后接描述字段    (对该接口的描述,不影响功能)

4)配置管理地址

SW1(config)#interface vlan 1    (进入VLAN 1 接口)
SW1(config-if)#ip address 172.16.0.100 255.255.255.0
SW1(config-if)#no shutdown 
SW1(config)#ip default-gateway 172.16.0.254    (定义网关)

5)配置SSH

SW1(config)#ip domain-name ccnpcisco.com    (添加域名名称)
SW1(config)#crypto key generate     (生成密钥)
	The name for the keys will be: SW1.ccnpcisco.com
	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]: 
	密钥长度可在360~2048之间,密钥越长安全性越高,然而性能越差;默认为512位
	% Generating 512 bit RSA keys, keys will be non-exportable...[OK]

SW1(config)#line vty 0 4        
SW1(config-line)#login local 
SW1(config)#username test secret cisco(配置用户和密码)

6)管理接口和错误条件
当交换机接口上出现错误时,默认交换机会关闭接口,管理员需要在故障排除后执行”shutdown“或”no shutdown“将接口重新打开。可使用命令将接口自动恢复

SW1(config)#errdisable detect cause ?
	all              Enable error detection on all cases
	 arp-inspection   Enable error detection for arp inspection
	dhcp-rate-limit  Enable error detection on dhcp-rate-limit
	dtp-flap         Enable error detection on dtp-flapping
	gbic-invalid     Enable error detection on gbic-invalid
	l2ptguard        Enable error detection on l2protocol-tunnel
	link-flap        Enable error detection on linkstate-flapping
	loopback         Enable error detection on loopback
	pagp-flap        Enable error detection on pagp-flapping

配置在何种情况下将接口自动关闭,默认为all

SW1(config)#errdisable recovery cause ?

配置在什么情况下自动恢复接口,默认不会自动恢复接口;同时也可查看各种引起接口关闭的原因

SW1(config)#errdisable recovery interval ? 
 <30-86400>  timer-interval(sec)

当接口配置错误时,间隔多久会进行自动恢复(需要看上一步配置了何种情况下会自动恢复)

实验调试:
1)查看各个接口的IP地址、状态等信息

SW1#show ip interface brief 
Interface              IP-Address      OK? Method Status                Protocol
Ethernet0/0            unassigned      YES unset  up                    up      
Ethernet0/1            unassigned      YES unset  up                    up      
Ethernet0/2            unassigned      YES unset  up                    up      
Ethernet0/3            unassigned      YES unset  up                    up      
Vlan1                  172.16.0.100    YES manual up                    up      

2)telnet

R1#telnet 172.16.0.100
Trying 172.16.0.100 ... 
*Dec 13 13:51:12.820: ether_vencap:(1975)
Open


User Access Verification

Username: test
Password: 
SW1>en

3)SSH

R1#ssh -l test 172.16.0.100
Password: 

SW1>

4)监控MAC地址表

SW1#show mac address-table 
      Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  1    0203.e900.0210    DYNAMIC     Et0/1
  1    0203.e900.0310    DYNAMIC     Et0/2
Total Mac Addresses for this criterion: 2

显示交换机学习到的MAC地址

SW1#show mac address-table ?
	address     address keyword   (显示特定MAC地址信息)
	aging-time  aging-time keyword    (显示MAC地址的超时时间)
	count       count keyword    (显示MAC地址表的统计信息)
	duplicate   duplicate mac    (显示重复的MAC地址)
	dynamic     dynamic entry type    (显示动态学习的MAC地址表)
	interface   interface keyword    (显示特定接口的MAC地址表)
	multicast   multicast info for selected wildcard     (显示特定组播的MAC地址表)
	static      static entry type    (显示静态学习到的MAC地址表)
	vlan        VLAN keyword	(显示特定VLAN的MAC地址表)

猜你喜欢

转载自blog.csdn.net/qq_41137136/article/details/85011228