文档库 最新最全的文档下载
当前位置:文档库 › 实验讲义2baogao

实验讲义2baogao

实验一 交换机基本配置实验

实验目的

1.掌握交换机的初始配置; 2.掌握交换机的网络设置; 3.掌握MAC 地址表

实验原理

实验环境

实验步骤

练习一:交换机的远程管理

按图配置PC1、PC2和PC3的IP 地址和子网掩码地址。

对交换机Switch1、Switch2进行配置,使得没有通过控制口连接到两个交换机上的PC 机能够远程登录到两个交换机上。

1. Switch1的配置 Swtich> enable

#进入特权视图 Switch# configure terminal

#进入系统配置视图

Switch(config)# hostname Switch1 #修改交换机的名称

Switch1(config)# enable password cisco #设置进入特权视图的口令 Switch1(config)# interface vlan 1 #进入虚网1

Switch1(config-if)# ip address 197.10.1.2 255.255.255.0 #给虚网1配置IP 地址 Switch1(config-if)# no shutdown #启动虚网

Switch1(config-if)# exit

Switch1(config)#line vty 0 4

#进入VTY0~4线路配置模式

Switch 1

PC2

197.10.1.3/24

Switch1(config-line)#login #VTY端口设置成口令验证

Switch1(config-line)#password cisco #设置VTY端口口令成cisco

Switch1(config-line)#

2. Switch2的配置

Switch> enable

Switch# configure terminal

Switch(config)# hostname Switch2

Switch2(config)# enable secret cisco #设置进入特权视图的口令(以密文显示)Switch2(config)# interface vlan 1

Switch2(config-if)# ip address 197.10.1.1 255.255.255.0

Switch2(config-if)# no shutdown

Switch2(config-if)# no shutdown #启动虚网

Switch2(config-if)# exit

Switch2(config)#line vty 0 4 #进入VTY0~4线路配置模式

Switch2(config-line)#login #VTY端口设置成口令验证

Switch2(config-line)#password cisco #设置VTY端口口令成cisco

Switch2(config-line)#

注:VTY是虚拟终端,允许其它的电脑对交换机进行远程控制,VTY支持很多远程登录协议,telnet和ssh是较为常用的两种。

尝试在PC1的控制台界面,通过telnet命令登录到Switch1和Switch2上。

练习二:交换机的MAC地址管理

对交换机Switch1的MAC地址进行配置,检查交换机的MAC地址表,能设置静态MAC,同时知道要慎重设置静态MAC地址。

1.创建新的交换机Switch1的VLAN,并将fa0/2、fa0/3加入到该VLAN中,启用该VLAN。

Switch2(config)#interface range fa0/2 - 3

Switch2(config-if-range)#switchport mode access

Switch2(config-if-range)#switchport access vlan 2

Switch2(config-if-range)#no shutdown

Switch2(config-if-range)#end

Switch2(config)#exit

Switch2#show vlan id 2

2.检查交换机的MAC地址表。

Switch2#show mac-address-table

3.PC1pingPC2和PC3,看能否ping通,并再次检查交换机的MAC地址。

4.将PC2的MAC地址和fa0/2做静态关联加入到交换机的MAC地址表中。

Switch2(config)#mac-address-table static PC2的MAC vlan 1 interface fa0/2

Switch2(config)#mac-address-table static PC3的MAC vlan 1 interface fa0/2

2通3不通

5.PC1来pingPC2和PC3,看能否ping通,并再次检查交换机的MAC地址

Mac Address Table

-------------------------------------------

Vlan Mac Address Type Ports ---- ----------- -------- -----

1 0003.e408.8801 DYNAMIC Fa0/1 1 0007.ec57.2048 STA TIC Fa0/

2 1 0060.3e59.31a1 STA TIC Fa0/2 2 0060.3e59.31a1 DYNAMIC Fa0/

3 2 0090.2b3c.8248 DYNAMIC Fa0/2 。

6.将PC2和PC3交换一下端口,然后PC1来pingPC2和PC3,看能否ping 通,并再次检查交换机的MAC 地址。

2不通 3 通 思考题:

1.为什么6步中会ping 不通?端口换了

2.静态MAC 映射表有什么缺点? 练习三:交换机端口聚合的配置

1.按拓扑图连线

2.在Switch1的配置 Switch> enable

Switch# configure terminal

Switch(config)# hostname Switch1 Switch1(config)#interface vlan 1

Switch1(config-if)# ip address 197.10.1.1 255.255.255.0 #给虚网1配置IP 地址 Switch1(config-if)# no shutdown #启动虚网 Switch1(config-if)# exit

Switch1(config)#int range fa0/1 – 2

Switch1(config-if-range)#switchport access vlan 1 #将端口fa0/1和fa0/2划分到vlan1

Switch 1

PC2

197.10.1.3/24

Switch1(config-if-range)#speed 100

Switch1(config-if-range)#duplex half

Switch1(config-if-range)#channel-group 1 mode on #设置端口聚合

Switch1(config-if-range)#end

Switch1#

3.在Switch2的配置

Switch> enable

Switch# configure terminal

Switch(config)# hostname Switch2

Switch2(config)#interface vlan 1

Switch2(config-if)# ip address 197.10.1.2 255.255.255.0 #给虚网1配置IP地址Switch2(config-if)# no shutdown #启动虚网

Switch2(config-if)# exit

Switch2(config)#int range fa0/1 – 2

Switch2(config-if-range)#switchport access vlan 1 #将端口fa0/1和fa0/2划分到vlan1 Switch2(config-if-range)#speed 100

Switch2(config-if-range)#duplex half

Switch2(config-if-range)#channel-group 1 mode on #设置端口聚合

Switch2(config-if-range)#end

Switch2#

4.查看聚合信息

(1)执行ping操作,测试连通性,产生数据包。

Switch1#ping 197.10.1.2

switch1#ping 197.10.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 197.10.1.2, timeout is 2 seconds:

..!!!

Success rate is 60 percent (3/5), round-trip min/avg/max = 31/31/31 ms

测试结果:交换机Switch1与Switch2是连通的。

(2)在交换机Switch1上查看聚合端口信息

Switch1#show interface port-channel 1

Switch1#show interface fa0/1

switch1#show interf fa0/1

FastEthernet0/1 is up, line protocol is up (connected)

Hardware is Lance, address is 0002.1636.1401 (bia 0002.1636.1401)

BW 100000 Kbit, DLY 1000 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

Keepalive set (10 sec)

Half-duplex, 100Mb/s

input flow-control is off, output flow-control is off

ARP type: ARPA, ARP Timeout 04:00:00

Last input 00:00:08, output 00:00:05, output hang never

Last clearing of "show interface" counters never

Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo

Output queue :0/40 (size/max)

5 minute input rate 0 bits/sec, 0 packets/sec

5 minute output rate 0 bits/sec, 0 packets/sec

956 packets input, 193351 bytes, 0 no buffer

Received 956 broadcasts, 0 runts, 0 giants, 0 throttles

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort

0 watchdog, 0 multicast, 0 pause input

0 input packets with dribble condition detected

2357 packets output, 263570 bytes, 0 underruns

0 output errors, 0 collisions, 10 interface resets

0 babbles, 0 late collision, 0 deferred

0 lost carrier, 0 no carrier

0 output buffer failures, 0 output buffers swapped out

Switch1#show interface vlan 1

switch1#show interf vlan 1

Vlan1 is up, line protocol is up

Hardware is CPU Interface, address is 0090.21cb.95da (bia 0090.21cb.95da) Internet address is 197.10.1.1/24

MTU 1500 bytes, BW 100000 Kbit, DLY 1000000 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

ARP type: ARPA, ARP Timeout 04:00:00

Last input 21:40:21, output never, output hang never

Last clearing of "show interface" counters never

Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo

Output queue: 0/40 (size/max)

5 minute input rate 0 bits/sec, 0 packets/sec

5 minute output rate 0 bits/sec, 0 packets/sec

1682 packets input, 530955 bytes, 0 no buffer

Received 0 broadcasts (0 IP multicast)

0 runts, 0 giants, 0 throttles

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

563859 packets output, 0 bytes, 0 underruns

0 output errors, 23 interface resets

0 output buffer failures, 0 output buffers swapped out

(3)在交换机Switch2上查看聚合端口信息

Switch2#show interface port-channel 1

Switch2#show interface fa0/1

switch2#show interface fa0/1

FastEthernet0/1 is up, line protocol is up (connected)

Hardware is Lance, address is 00d0.ff78.e801 (bia 00d0.ff78.e801)

BW 100000 Kbit, DLY 1000 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

Keepalive set (10 sec)

Half-duplex, 100Mb/s

input flow-control is off, output flow-control is off

ARP type: ARPA, ARP Timeout 04:00:00

Last input 00:00:08, output 00:00:05, output hang never

Last clearing of "show interface" counters never

Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo

Output queue :0/40 (size/max)

5 minute input rate 0 bits/sec, 0 packets/sec

5 minute output rate 0 bits/sec, 0 packets/sec

956 packets input, 193351 bytes, 0 no buffer

Received 956 broadcasts, 0 runts, 0 giants, 0 throttles

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort

0 watchdog, 0 multicast, 0 pause input

0 input packets with dribble condition detected

2357 packets output, 263570 bytes, 0 underruns

0 output errors, 0 collisions, 10 interface resets

0 babbles, 0 late collision, 0 deferred

0 lost carrier, 0 no carrier

0 output buffer failures, 0 output buffers swapped out

Switch2#show interface vlan 1

switch2#show interface vlan 1

Vlan1 is up, line protocol is up

Hardware is CPU Interface, address is 0001.c7a0.5315 (bia 0001.c7a0.5315) Internet address is 197.10.1.2/24

MTU 1500 bytes, BW 100000 Kbit, DLY 1000000 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

ARP type: ARPA, ARP Timeout 04:00:00

Last input 21:40:21, output never, output hang never

Last clearing of "show interface" counters never

Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo

Output queue: 0/40 (size/max)

5 minute input rate 0 bits/sec, 0 packets/sec

5 minute output rate 0 bits/sec, 0 packets/sec

1682 packets input, 530955 bytes, 0 no buffer

Received 0 broadcasts (0 IP multicast)

0 runts, 0 giants, 0 throttles

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

563859 packets output, 0 bytes, 0 underruns

0 output errors, 23 interface resets

0 output buffer failures, 0 output buffers swapped out

(4)查看MAC地址转发表

Switch1#show mac-address-table

Mac Address Table

-------------------------------------------

Vlan Mac Address Type Ports

---- ----------- -------- -----

1 0060.2f71.7b6d DYNAMIC Po1

1 00d0.ff78.e801 DYNAMIC Po1

1 00d0.ff78.e80

2 DYNAMIC Po1

5.将fa0/1端口关闭,再进行测试

(1)将Switch1的fa0/1端口关闭

Switch1#conf t

Switch1(config)#int fa0/1

Switch1(config-if)#shutdown

Switch1(config-if)#end

Switch1#

(2)测试连通性

Switch1#ping 197.10.1.2

switch1#ping 197.10.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 197.10.1.2, timeout is 2 seconds: .....

Success rate is 0 percent (0/5)

(3)查看MAC地址转发表

Switch1#show mac-address-table

Mac Address Table

-------------------------------------------

Vlan Mac Address Type Ports

---- ----------- -------- -----

1 0060.2f71.7b6d DYNAMIC Po1

1 00d0.ff78.e801 DYNAMIC Po1

1 00d0.ff78.e80

2 DYNAMIC Po1 (4)查看port-channel1端口地址

Switch1#show interface port-channel 1

实验二交换机VLAN配置

实验目的

1掌握在交换机上创建/删除VLAN的方法;

2掌握VLAN接口配置的方法;

3了解并掌握交换机VLAN的性质。

实验学时

4学时

实验类型

综合型

实验内容

1 通过VLAN的配置进行信息隔离;

2 测试属于同一个VLAN的机器可以连通,不同VLAN的机器在第二层不能连通。实验原理

以太网交换技术的一个主要方面是VLAN(Virtual Local Network,虚拟局域网),它使用交换机将工作站和服务器聚集在逻辑概念的组中,既是一种通过将局域网内的设置逻辑地而不是物理地划分成一个个网段,从而实现虚拟工作组的技术。在一个VLAN中的设备在第二层只能够与同一个VLAN中的设备通信,这样一个交换式的网络工作起来就像是许多互不相连的单独的局域网一样。IEEE与1999年颁布了用以标准化的VLAN实现方案的IEEE802.1Q协议标准草案。

一个VLAN是一组网络设备和服务的集合,它不受限于一个物理分段和一台交换机。VLAN 的优势在于:它对交换式网络进行逻辑分段,可根据组织的功能、工程组及应用等因素将设备或用户组成一个群体,而无须考虑它们所在的物理位置。而VLAN内部的广播和单播流量不会被转发到其他VLAN中,从而有助于控制网络流量,减少设备投资,简化网络管理,提高网络安全性。

VLAN的主要目的就是划分广播域。VLAN的划分方法有以下几种:

1)基于端口来划分VLAN

它是根据以太网交换机端口来划分广播域,即交换机某些端口连接的主机在一个广播域内,而另一些端口连接的主机在另一个广播域内,VLAN和端口连接的主机无关。

2)基于MAC地址来划分VLAN

它是根据连接在交换机上主机的MAC地址来划分广播域,即某个主机属于哪个VLAN,只与它的MAC地址有关,与它连接在哪个端口或IP地址都没有关系。

3)基于协议来划分VLAN

它是根据网络主机使用的网络协议来划分广播域,即主机属于哪一个VLAN决定于它所运行的网络协议(如IP协议或IPX协议),而与其他因素都没有关系。

4)基于子网来划分VLAN

它是根据网络主机使用的IP地址所在的网络子网来划分广播域,IP地址属于同一子网的主机属于一个广播域,而与其他因素无关。

通常情况下,基于端口来划分VLAN是最普遍使用的方法之一,也是目前所有交换机都

支持的一种划分方法。

由于不同因素的影响,交换机中的VLAN 数目不定,这些因素包括流量模式、应用程序的类型、网络管理的需求及分组特点等。在缺省情况下,所有的端口都属于VLAN1,VLAN1用于管理本交换机,只有对VLAN 才可以设置IP 地址,对以太网端口不能设置IP 地址。网管软件可通过VLAN1的IP 地址来管理该交换机。

3层交换机(即路由交换机)可以在不同VLAN 之间转发数据,在转发数据时,可根据自身的路由表来进行。2层交换机不支持在VLAN 之间转发数据。VLAN 一般与路由器或路由交换机配合使用,以便在第3层互连全网的多个VLAN 。在第2层使用不同VLAN 相互隔离的目的,是为了缩小广播域的大小,提高安全性并方便管理。但若在第3层也进行隔离,则会改变互连全网内所有主机的初衷,所以在高层最终还是要让不同VLAN 之间能互相通信。

实验步骤

练习一:单交换机上的VLAN 划分 1 组建实验环境 1)组网环境 1台二层交换机,PC 机4台,Console 配置电缆1根。

2)网络拓扑图

PC-A VLAN2 192.168.20.2/24

PC-B VLAN3 192.168.20.3/24

2 具体配置

在配置前,请先使用“erase startup-config ”、“no vlan 2-1001”等命令清除以前的

配置信息,并重启交换机。

1)创建超级终端,通过控制台端口进入Switch1。 2)交换机VLAN 配置 由于交换机在清除配置信息时,其所设置的VLAN 在vlan database 中仍在,在进行配置前,先将以前配置的VLAN 从数据库中清除,以保证配置的正确性。其命令如下: Switch1#vlan database

Switch1(vlan)#no vlan vlan-id name Switch1(vlan)#no vlan vlan-id

清除VLAN 的另一种方法:在特权EXEC 模式下,用命令delete vlan.dat 文件,该文件

包含VLAN 的配置信息,再重启交换机。 (1)在交换机上创建VLAN Switch>enable

Switch#config terminal

Enter configguration commands,one per line.End with CTRL+Z Switch(config)#hostname Switch1

Switch1(config)#exit

Switch1#vlan database

Switch1(vlan)#vlan 2 name work1 VLAN2 modified: Name:work1

Switch1(vlan)#vlan 3 name work2 VLAN3 modified: Name:work2 Switch1(vlan)#exit APPLY completed. Exiting …… (2)配置VLAN 端口 Switch1#config terminal

Switch1(config)#interface range fa0/1-2

Switch1(config-if-range)#switchport mode access

Switch1(config-if-range)# interface fa0/1 Switch1(config-if)#switchport access vlan 2

Switch1(config-if)# interface fa0/2

Switch1(config-if)#switchport access vlan 3

Switch1(config-if)#end

Switch1#

(3)设置PC 机地址,测试其连通性

练习二:两个交换机上的VLAN 划分 1 组建实验环境 1)组网环境

1台3层交换机,1台2层交换机,4台PC 机,交叉网线1根,直通网线4根,配置电缆2根。 2)网络拓扑图

Fa0/3

Fa0/3

PC-A VLAN10 192.168.10.2/24

PC-B VLAN20

192.168.20.2/24 PC-C VLAN10

192.168.10.4/24 Fa0/2

PC-D

VLAN20

192.168.20.4/24

2 具体配置步骤

在配置前,请先使用“erase sartup-config ”、“no vlan 2-1001”等命令清除以前的配置信息,并重启动交换机。 1)创建交换机的VLAN 并对端口进行设置 (1)设置交换机1的多个VLAN 并设置端口Trunk 属性 Switch>enable #进入用户特权模式

Switch#config terminal #进入配置界面

Enter configuration commands,one per line.End with CNTR/Z.

Switch(config)#hostname Switch1 #设置交换机主机名为Switch1

Switch1(config)#exit

Switch1#vlan database #进入VLAN设置界面

Switch1(vlan)#vlan 10 name work1 #创建vlan10其名称为work1

VLAN 10 modified:

Name:work1

Switch1(vlan)#vlan 20 name work2

VLAN 20 modified:

Name:work2

Switch1(vlan)#exit

APPLY completed.

Exiting...

Switch1#config terminal

Switch1(config)#interface range fa0/1-2 #进入组配置界面

Switch1(config-if-range)#switchport mode access #设置组中个端口的端口模式Switch1(config-if-range)#interface fa0/1

Switch1(config-if)#switchport access vlan 10 #将一个端口加入到VLAN10 Switch1(config-if)#interface fa0/2

Switch1(config-if)#switchport access vlan 20

Switch1(config-if)#interface fa0/3

Switch1(config-if)#switchport trunk encapsulation dot1q

#启用802.1Q Trunk封装协议

Switch1(config-if)#switchport mode trunk #将端口设置为Trunk

Switch1(config-if)#switchport trunk allowed vlan remove 2-1001,1006-4094 #在允许透传的VLAN中删除不必要的VLAN,要根据具体交换机所支持的VLAN情况确定Switch1(config-if)#switchport trunk allowed vlan add 10,20 #在通过该端口透传的允许VLAN中加入VLAN10和VLAN20

Switch1(config-if)#end

Switch1#

(2)设置交换机2的多个VLAN并设置端口Trunk属性

Switch>enable #进入用户特权模式

Switch#config terminal #进入配置界面

Enter configuration commands,one per line.End with CNTR/Z.

Switch(config)#hostname Switch1 #设置交换机主机名为Switch2

Switch2(config)#exit

Switch2#vlan database #进入VLAN设置界面

Switch2(vlan)#vlan 10 name work1 #创建vlan10其名称为work1

VLAN 10 modified:

Name:work1

Switch1(vlan)#vlan 20 name work2

VLAN 20 modified:

Name:work2

Switch2(vlan)#exit

APPLY completed.

Exiting...

Switch2#config terminal

Switch2(config)#interface range fa0/1-2 #进入组配置界面

Switch2(config-if-range)#switchport mode access #设置组中个端口的端口模式

Switch2(config-if-range)#interface fa0/1

Switch2(config-if)#switchport access vlan 10 #将一个端口加入到VLAN10

Switch2(config-if)#interface fa0/2

Switch2(config-if)#switchport access vlan 20

Switch2(config-if)#interface fa0/3

Switch2(config-if)#switchport trunk encapsulation dot1q

#启用802.1Q Trunk封装协议

Switch2(config-if)#switchport mode trunk #将端口设置为Trunk

Switch2(config-if)#switchport trunk allowed vlan remove 2-1001

#在允许透传的VLAN中删除不必要的VLAN,要根据具体交换机所支持的VLAN情况确定Switch2(config-if)#switchport trunk allowed vlan add 10,20

#在通过该端口透传的允许VLAN中加入VLAN10和VLAN20

Switch2(config-if)#end

Switch2#

2)设置连接的PC机地址

3)测试Trunk属性的工作状态

(1)查看交换机端口分配情况

Switch1#show interface stauts

Switch2#show interface stauts

从两交换机的端口分配情况可知,两交换机的fa0/1端口属于vlan10,fa0/2端口属于vlan20,fa0/3端口被设置成Trunk属性端口,3个端口都已经连通。

(2)查看Trunk属性端口信息

①交换机1上的Trunk属性端口信息

Switch1#show interface trunk

从上面的输出信息可以看到,交换机1的fa0/3端口的Trunk属性设置情况。

②交换机2上的Trunk属性端口信息

Switch2#show interface trunk

从上面的输出信息可以看到,交换机1的fa0/3端口的Trunk属性设置情况。

(3)PC机互相执行ping操作并测试连通性

在PC-A上:c:\>ping 192.168.10.4

在PC-B上:c:\>ping 192.168.20.4

练习三:VLAN间的路由

1 组建实验环境

1)组网环境

1台2层交换机,1台路由器,3台PC 机,直通网线4根,配置电缆2根。

2)网络拓扑图

PC-A VLAN10 192.168.10.2/24

PC-B VLAN20 192.168.20.2/24

PC-C VLAN30

192.168.30.2/24

Fa0/0.2:192.168.20.1/24

2 具体配置步骤

1)创建交换机的VLAN 并设置其端口及属性

Switch>enable

#进入用户特权模式

Switch#config terminal #进入配置界面

Enter configuration commands,one per line.End with CNTR/Z. Switch(config)#hostname Switch1 #设置交换机主机名为Switch1 Switch1(config)#exit Switch1#vlan database

#进入VLAN 设置界面

Switch1(vlan)#vlan 10 name work1

#创建vlan10其名称为work1

VLAN 10 modified: Name:work1

Switch1(vlan)#vlan 20 name work2 VLAN 20 modified:

Name:work2

Switch1(vlan)#vlan 30 name work3 VLAN 30 modified: Name:work3 Switch1(vlan)#exit

APPLY completed. Exiting...

Switch1#config terminal

Switch1(config)#interface range fa0/1-3

#进入组配置界面

Switch1(config-if-range)#switchport mode access #设置组中个端口的端口模式 Switch1(config-if-range)#interface fa0/1 Switch1(config-if)#switchport access vlan 10 #将一个端口加入到VLAN10

Switch1(config-if)#interface fa0/2

Switch1(config-if)#switchport access vlan 20 Switch1(config-if)#interface fa0/3

Switch1(config-if)#switchport access vlan 30

Switch1(config-if)#interface fa0/6

Switch1(config-if)#switchport mode trunk #将端口设置为Trunk

Switch1(config-if)#switchport trunk allowed vlan remove 2-1001 #在允许透传的VLAN中删除不必要的VLAN,要根据具体交换机所支持的VLAN情况确定Switch1(config-if)#switchport trunk allowed vlan add 10,20,30 #在通过该端口透传的允许VLAN中加入VLAN10和VLAN20

Switch1(config-if)#end

Switch1#

2)设置路由器子接口

Router>enable #进入用户特权模式

Router #config terminal #进入配置界面

Enter configuration commands,one per line.End with CNTR/Z.

Router(config)#hostname Router1

Router1(config)#intrface fa0/0

Router1(config-if)#interface fa0/0.1

Router1(config-subif)#encapsulation dot1q 10

#在fa0/0.1子接口里传输VLAN10的帧

Router1(config-subif)#ip address 192.168.10.1 255.255.255.0

Router1(config-if)#interface fa0/0.2

Router1(config-subif)#encapsulation dot1q 20

#在fa0/0.2子接口里传输VLAN10的帧

Router1(config-subif)#ip address 192.168.20.1 255.255.255.0

Router1(config-if)#interface fa0/0.3

Router1(config-subif)#encapsulation dot1q 30

#在fa0/0.3子接口里传输VLAN10的帧

Router1(config-subif)#ip address 192.168.30.1 255.255.255.0

Router1(config-subif)#exit

Router1(config)#interface fa0/0

Router1(config-if)#no shutdown

Router1(config-subif)#end

Router1#

3)查看路由器各子接口工作状态

(1)查看fa0/0.1子接口信息

Router1#show interface fa0/0.1

(2)查看其他两个子接口信息

Router1#show interface fa0/0.2

Router1#show interface fa0/0.3

4)查看路由信息

Router1#show ip route

5)测试Trunk属性的工作状态

(1)核实VLAN的端口划分

Router1#show interface trunk

(2)PC机互相执行ping操作并测试连通性C:\>ping 192.168.10.1

C:\>ping 192.168.20.1

C:\>ping 192.168.30.1

实验三路由器基本操作与配置

实验目的

1掌握路由器口令的设置和恢复、配置文件备份、IOS备份和升级方法;

2掌握配置路由器的以太网接口方法;

3掌握配置路由器串行接口方法;

4掌握配置路由器还回接口方法;

5 掌握路由器接口配置方法。

实验学时

4学时

实验类型

综合型

四实验内容

1 路由器口令设置与恢复;

2 配置文件备份和IOS备份;

3 路由器常规配置命令;

4 配置Ethernet接口;

5 配置Serial串行接口;

6 创建并配置Loopback接口。

实验原理

1 配置寄存器

Cisco路由器有一个被称为虚拟配置登记表的16位寄存器,该寄存器驻留在NVRAM 中,用于指定路由器启动的次序、使路由器忽略内存中的内容(恢复密码)以及设置波特率等。寄存器的值通常用十六进制数来表示。

利用配置命令config-register可以改变配置寄存器的值。

Router(config)#config-register 0x0101

寄存器各位的具体含义。第0~3位是启动字段,它用于选取该路由器的启动特性。如值为0(0000),进入ROM监控模式;如值为1(0001),指定从ROM中启动;如值为2(0010)~F(1111),则参照在NVRAM配置文件中用命令boot sysem指定的顺序。第6位可以用来恢复密码,该位设为1的时候,会在启动的时候忽略NVRAM中的配置信息而将用户带入初始配置对话模式中,与之相关的常用配置寄存器的值为0x2142。第8位设为1,使得路由器忽略键,若该位为0,使用键可以在系统启动后正常运行时中断系统。但不论该位是否为0,总能在系统启动时用+组合键使系统进入ROM监控模式。第10位能够改变广播的类型。第5,11和12位用来设置路由器的波特率(bit/s),路由器的出厂波特率一般设为9600bit/s,其第5,11和12位都设为0,通过修改这几位的值可以修改波特率,波特率的可选范围在区间1200~115200bi/s。

2 路由器工作模式

1)ROM监控模式

路由器启动时,如果系统没有加载任何的IOS镜像文件,或者按下+组合键,此时路由器就进入ROM监控模式,ROM监控模式的提示符是:

rommon>

2)用户执行模式

如果路由器成功加载了一份完整的IOS代码,那么对路由器的第一级访问模式就是用户执行模式。在用户执行模式下,用户可以显示系统信息、执行基本的测试以及设置终端参数等,但该模式下无法查看配置文件及更改信息。该模式下的命令提示符如下:Router>

3)特权执行模式

特权执行模式即enable模式,在这一级别中,用户具有更改和配置路由器的所有权限。在用户执行模式下执行enable命令进入特权执行模式,特权执行模式下的提示符如下:Router#

3)配置模式

在enable模式下,利用命令config terminal可以进入配置模式,在配置模式下可以对接口、路由协议和线路等进行配置:

Router#config terminal

Router(config)#

3 路由器的接口

Cisco路由器上具有丰富大道接口,主要分为物理接口与虚拟接口,接口帮助路由器在不同的网段之间路由分组和桥接帧,并提供到各种传输介质的连接点。常用的接口主要有:

●串行接口

●以太网接口

●语音接口

在采样IOS软件的Cisco路由器上,所有的接口都有自己的名字和编号,编号都是从零开始的。Cisco2600系列以上的路由器大都采用模块化接口,因此,一个接口的编号至少包括两个数字,中间用正斜杠(/)分隔。其中,第一个数字代表插槽,第二个数字代表接口处理器的端口编号。比如一个Cisco2621XM型路由器的一个接口:FastEthernet0/1。FastEthernet是接口类型,即快速以太网接口,0表示第一个插槽,1表示该插槽内第二个以太接口。而串行接口的插槽有时也从1开始编号,如Cisco7200系列路由器的一个串行接口Serial1/0,1表示路由器上第一个插槽,0表示该插槽内的第一个接口。

4 路由器的端口

Cisco路由器上常见的端口主要有控制台端口(Console口)和辅助端口(AUX端口)等。

1)控制台端口

几乎所有的路由器都安装了控制台端口。控制台端口提供了一个EIA/TIA-232(以前称作RS-232)异步串行接口,使我们能够与路由器通信。至于同控制台建立哪种形式的物理连接,则取决于路由器的型号。有些路由器采用一个DB-25母线连接器(DB25F),有些则采用RJ-45连接器。通常,较小的路由器采用RJ-45控制台;连接器,而较大路由器采用DB-25控制台连接器。

2)辅助端口

大多数Cisco路由器都配备了一个“辅助端口”(Auxiliary Port),它与控制台端口类似,提供了一个EIA/TIA-232异步串行接口,使我们能够与路由器通信。辅助端口通常用来连接Modem,以实现对路由器的远程管理。AUX端口连接的远程通信链路平时并不连通,它的主要作用是在网络主线失效后被启用,作为备份线路工作。

实验步骤

1 组建实验环境 1)组网环境

3台Cisco 路由器,交换机1台,PC 机1台。

2)网络拓扑图

S0/0

S1/1

RTA

192.168.1.1/24

RTC

S1/0

PC-A

192.168.1.2/24 RTB

192.168.2.2/24

DTE

E0/0

HDLC

DCE

LAN

192.168.3.1/24

192.168.3.2/24

DTE

PPP

S1/0

Clock rate=2016kbps

2 具体配置步骤

配置路由器接口,使用的是仿真终端(PC 机)上的超级终端仿真程序,通过路由器控制口建立EXEC 会话,然后执行相关命令。 1) 口令设置和恢复 (1)口令设置

控制台(Console )、辅助端口(AUX )和虚拟控制终端线路(VTY )都可以设置各自的

口令。命令login 设置路由器需要输入密码才能进入,命令password 用来设置密码。 控制台用命令line console 0进行配置,下面是对控制台进行口令设置: Router(config)#line console 0

Router(config-line)#password p501

Router(config-line)#login

辅助端口用命令line aux 0进行配置,下面是对辅助端口进行口令配置:

Router(config)#line aux 0

Router(config-line)#password p502 Router(config-line)#login 辅助端口常用于电话拨号备份线路,一般情况下用户不能从AUX 口登录进入路由器配置界面,所以一般不需要上面的口令设置。 大多数的路由器都有5条终端线路,线路0到线路4.终端线路用命令line vty 0 4进行配置。下面是对终端线路进行口令配置: Router(config)#line vty 0 4

Router(config-line)#password p503

Router(config-line)#login

注意:如果没有为VTY 使用password 命令设置密码,但是启用了login 命令,那么Telnet

访问是不允许的。路由器都会返回一条password no set 的信息然后断开Telnet 会话。如果没有使用login 命令,那么用户可以在没有密码输入提示的情况下进行访问。 设置特权执行模式密码有两种方法。一种是采用enable secret 命令,另一种是采用enable

password命令。enable secret命令对密码进行加密,因而具有更高的安全性。如果两条命令同时存在的话,enable secret命令会覆盖enable password命令。

用命令copy running-config startup-config保存配置文件,然后用命令show running-config 查看口令信息。

(2)口令恢复

路由器的口令恢复是在路由器启动的时候按下中断键进入ROM监控模式,将路由器设置为忽略配置文件,然后重启路由器,在初始化配置对话模式上选择“no”,最后读取或者重新修改口令即可。

整个操作步骤如下:

①关掉路由器的电源,然后打开电源。

②按下+组合键,路由器进入ROM监控模式。在rommon>提示符下,键入命令config 0x2142修改配置寄存器,使得路由器下一次启动时不加载NVRAM中的配置文件。如果用户不熟悉配置寄存器的值的含义,可以直接键入confreg,然后回车,以交互的方式设置路由器在启动时忽略NVRAM配置文件。

rommon>confreg

然后按提示输入n/y。

Rommon 2>reset

③在Router>提示符下输入“enable”进入特权执行模式。用命令show running-config 查看,发现口令设置已忽略。

④使用命令config memory或copy startup-config running-config将启动配置信息拷贝到运行配置中。注意,不要输入命令config terminal,否则NVRAM中的配置信息会被覆盖。

⑤键入命令“write terminal”或“show running-config”可以查看到原先的口令配置信息。用户根据需要可以对口令进行更改。

⑥可以用命令show version查看配置寄存器的值,该命令输出的最后一行信息为:

Configuration register is 0x2142

目前配置寄存器的值为0x212,该值使路由器启动时忽略配置文件。输入命令“config terminal”进入配置模式,然后输入命令“config-register 0x2102”设置路由器在下次启动时读入配置文件。

⑦按下+退出配置模式,利用命令write memory或copy running-config startup-config保存更改信息。

⑧重新启动路由器并验证口令信息。

2)配置文件备份和IOS备份

(1)配置文件备份

Router#copy nvram:starup-config tftp

(2)IOS备份

Router#show flash

Router#copy flash:xxx tftp://ip地址

3)IOS升级

4)路由器常规配置命令

(1)配置主机名

相关文档