首先准备机器:五台PC机、一台三层交换机、两台二层交换机、三台路由器。 配置:IP地址:PC0:192.168.10.1 网关:192.168.10.254 PC1:192.168.10.2 网关:192.168.10.254 PC2:192.168.10.3 网关:192.168.10.254 PC3:192.168.20.1 网关:192.168.20.254 PC4:192.168.30.1 网关:192.168.30.254

VLAN:PC0、PC1、PC2为VLAN10 PC3为VLAN20 PC4为VLAN30

拓扑结构如下图所示:

首先在SW1上创建VLAN20 ,并且给两个端口划分VLAN 。

SW1(config)#vlan SW1(config)#vlan 20 SW1(config-vlan)# SW1(config)#interface fastEthernet 0/1 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 20

SW1(config)#interface fastEthernet 0/2 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 20

在R1上,Gig0/0配置PC3的网关地址,并且给路由器的Gig0/1口配置IP地址。

R1(config)#interface gigabitEthernet 0/0 R1(config-if)#ip address 192.168.20.254 255.255.255.0 R1(config-if)#no shutdown

R1(config)#interface gigabitEthernet 0/1 R1(config-if)#ip address 192.168.40.1 255.255.255.0 R1(config-if)#no shutdown

在R2上,Gig0/0、Gig0/1配置IP地址,Gig0/2配置PC0、PC1、PC2的网关地址。

R2(config)#interface gigabitEthernet 0/0 R2(config-if)#ip address 192.168.40.2 255.255.255.0 R2(config-if)#no shutdown

R2(config)#interface gigabitEthernet 0/1 R2(config-if)#ip address 192.168.50.1 255.255.255.0 R2(config-if)#no shutdown

R2(config)#interface gigabitEthernet 0/2 R2(config-if)#ip address 192.168.10.254 255.255.255.0 R2(config-if)#no shutdown

在R3上,Gig0/0配置PC4的网关地址,并且给路由器的Gig0/1口配置IP地址。

R1(config)#interface gigabitEthernet 0/0 R1(config-if)#ip address 192.168.30.254 255.255.255.0 R1(config-if)#no shutdown

R1(config)#interface gigabitEthernet 0/1 R1(config-if)#ip address 192.168.50.2 255.255.255.0 R1(config-if)#no shutdown

在SW3上创建VLAN30,并且给两个端口划分VLAN。

SW3(config)#vlan 30 SW3(config-vlan)# SW3(config)#interface fastEthernet 0/1 SW3(config-if)#switchport mode access SW3(config-if)#switchport access vlan 30

SW3(config)#interface fastEthernet 0/2 SW3(config-if)#switchport mode access SW3(config-if)#switchport access vlan 30

在SW2上创建VLAN10,并且给四个端口划分VLAN。

SW2(config)#vlan 10 SW2(config)#interface fastEthernet 0/1 SW2(config-if)#switchport mode access SW2(config-if)#switchport aCcess vlan 10

SW2(config)#interface fastEthernet 0/2 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 10

SW2(config)#interface fastEthernet 0/3 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 10

SW2(config)#interface fastEthernet 0/4 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 10

基本配置做完后,还是在路由器上准备做RIP配置。

首先在R1上操作;

R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network 192.168.20.0 R1(config-router)#network 192.168.40.0

R2上RIP配置;

R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network 192.168.10.0 R2(config-router)#network 192.168.40.0 R2(config-router)#network 192.168.50.0

R3上RIP配置;

R3(config)#router rip R3(config-router)#version 2 R3(config-router)#no auto-summary R3(config-router)#network 192.168.50.0 R3(config-router)#network 192.168.30.0

在三台路由器上查看是否配置成功,在系统用户下键入:

R3#show ip route

查看路由器已经学习到了路由条目,说明配置成功了。需要在PC上看是否可以ping通。 如下图所示:

如图所示: