构建交换路由网络——综合应用

一、实验要求

1、所有设备按照拓扑图标注重新命名;

2、所有IP地址按照拓扑图标注进行配置;

3、三层交换机coresw的f0/22口必须关掉交换功能才能配置IP地址,关掉交换功能的命令:coresw(config-if)#no switchport;

4、OSPF区域1,需要对172.16.1.0 255.255.255.0网络进行子网划分:

    VLAN 10用01开头的网段,PC4用自己子网的最小的IP地址,子接口f0/0.1用自己子网的最大的IP地址;

      VLAN 20用10开头的网段,PC5用自己子网的最小的IP地址,子接口f0/0.2用自己子网的最大的IP地址;

5、路由重发布时,往RIP里发布metric 2

 二.实验步骤

步骤一:配置交换机,使内部局域网连通;

(1)划分Vlan

SW1: 

Switch>en
Switch>enable 
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#host
Switch(config)#hostname SW1
SW1(config)#vlan 10
SW1(config-vlan)#name renwen
SW1(config-vlan)#vlan 20
SW1(config-vlan)#name qiche
SW1(config-vlan)#exit
SW1(config)#int f0/1
SW1(config-if)#switchport mode access 
SW1(config-if)#switchport access vlan 10
SW1(config-if)#exit
SW1(config)#int f0/2
SW1(config-if)#switchport mode access 
SW1(config-if)#switchport access vlan 20
SW1(config-if)#exit
SW1(config)#int f0/24
SW1(config-if)#switchport mode trunk 
SW1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up

 SW2同理:

        int f0/1-->f0/3

        int f0/2-->f0/4

对三层交换机进行操作: 

Switch>en
Switch>enable 
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#no ip domain-lookup //防止报错等待很久
Switch(config)#hostname coresw
coresw(config)#int range f0/23,f0/24
coresw(config-if-range)#switchport trunk encapsulation dot1q //对trunk进行封装
coresw(config-if-range)#switchport mode trunk 
coresw(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/23, changed state to up

coresw(config-if-range)#exit
coresw(config)#int f0/22  //连接交换机的接口
coresw(config-if)#no switchport 
coresw(config-if)#ip address 10.1.1.1 255.255.255.0
coresw(config-if)#no shutdown 

对PC操作,配置网关 

valn 10(192.168.1.254)

vlan 20(192.168.2.254)

物理接口配置完成,需要在三层交换机上配置逻辑接口:创建vlan;给vlan配置网关

coresw(config)#vlan 10
coresw(config-vlan)#name renwen
coresw(config-vlan)#vlan 20 
coresw(config-vlan)#name qiche
coresw(config)#int vlan 10
coresw(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

coresw(config-if)#ip address 192.168.1.254 255.255.255.0
coresw(config-if)#exit
coresw(config)#int vlan 20
coresw(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

coresw(config-if)#ip address 192.168.2.254 255.255.255.0
coresw(config-if)#exit
coresw(config)#

 此时,相同vlan下的相同网段可以ping通(pc0<--->pc2;pc1<--->pc3)

要想使得不同vlan下的相同网段可以通信,需要在三层交换机下执行:

        coresw(config)#ip routing

此时,show ip route可以看见三层交换机下有两段直连网络,证明不同vlan下的不同网段也可以通信:

C 192.168.1.0/24 is directly connected, Vlan10

C 192.168.2.0/24 is directly connected, Vlan20

步骤二:配置路由器及相关协议; 

对R1操作:

Router>en
Router>enable 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R1
R1(config)#int f0/0
R1(config-if)#ip add
R1(config-if)#ip address 10.1.1.2 255.255.255.0
R1(config-if)#no shutdown 
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#exit
R1(config)#int s2/0
R1(config-if)#clock rate 64000
R1(config-if)#ip address 20.1.1.1 255.255.255.0
R1(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R1(config-if)#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up

R2同理:

Router>en
Router>enable 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R2
R2(config)#int s2/0
R2(config-if)#ip address 20.1.1.2 255.255.255.0
R2(config-if)#no shutdown 
R2(config-if)#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up

R2(config-if)#exit
R2(config)#int s3/0
R2(config-if)#clock rate 64000
R2(config-if)#ip address 30.1.1.1 255.255.255.0
R2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Serial3/0, changed state to down
R2(config-if)#
%LINK-5-CHANGED: Interface Serial3/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial3/0, changed state to up

对R3的操作:

Router>en
Router>enable 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R3
R3(config)#int s3/0
R3(config-if)#ip address 30.1.1.2 255.255.255.0
R3(config-if)#no shutdown 
R3(config-if)#
%LINK-5-CHANGED: Interface Serial3/0, changed state to up

R3(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial3/0, changed state to up

R3(config-if)#exit
R3(config)#int f0/0
R3(config-if)#no shutdown 

R3(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R3(config-if)#exit
R3(config)#int f0/0.1
R3(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to up

R3(config-subif)#

 

 

R3操作:

        逻辑子接口---f0/0.1:需要先对它进行封装R3(config-subif)#encapsulation dot1Q 10

R3(config)#int f0/0.1
R3(config-subif)#encapsulation dot1Q 10
R3(config-subif)#ip address 172.16.1.126 255.255.255.192
R3(config-subif)#exit
R3(config)#int f0/0.2
R3(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up

R3(config-subif)#encapsulation dot1Q 20
R3(config-subif)#ip address 172.16.1.190 255.255.255.192
R3(config-subif)#no shutdown 

对SW3操作:

Switch>en
Switch>enable 
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW3
SW3(config)#vlan 10
SW3(config-vlan)#vlan 20
SW3(config-vlan)#exit
SW3(config)#int f0/1
SW3(config-if)#switchport mode access 
SW3(config-if)#switchport access vlan 10
SW3(config-if)#exit
SW3(config)#int f0/2
SW3(config-if)#switchport mode access 
SW3(config-if)#switchport access vlan 20
SW3(config-if)#exit
SW3(config)#int f0/24
SW3(config-if)#switchport mode trunk 

SW3(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up

SW3(config-if)#

宣告网段rip

查看R1路由表:  
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0
     20.0.0.0/24 is subnetted, 1 subnets
C       20.1.1.0 is directly connected, Serial2/0

R1(config)#router rip 
R1(config-router)#version 2
R1(config-router)#network 10.1.1.0
R1(config-router)#no auto-summary //关闭自动汇总
R1(config-router)#

 查看三层交换机与R1有交叉重合的地方,才能相互通信,并宣布rip协议      

                10.0.0.0/24 is subnetted, 1 subnets

        C 10.1.1.0 is directly connected, FastEthernet0/22

        C 192.168.1.0/24 is directly connected, Vlan10

        C 192.168.2.0/24 is directly connected, Vlan20

coresw(config)#router rip 
coresw(config-router)#version 2
coresw(config-router)#network 10.1.1.0
coresw(config-router)#network 192.168.1.0
coresw(config-router)#network 192.168.2.0
coresw(config-router)#no auto-summary 
coresw(config-router)#exit

   对于三层交换机来说路由表没有发生改变,但是R1发生改变了:       

                10.0.0.0/24 is subnetted, 1 subnets

        C 10.1.1.0 is directly connected, FastEthernet0/0

                20.0.0.0/24 is subnetted, 1 subnets

        C 20.1.1.0 is directly connected, Serial2/0

        R 192.168.1.0/24 [120/1] via 10.1.1.1, 00:00:09, FastEthernet0/0

         R 192.168.2.0/24 [120/1] via 10.1.1.1, 00:00:09, FastEthernet0/0

此时,rip部分完成配置

OSPF部分:

R1:

R1(config)#router ospf 10
R1(config-router)#network 20.1.1.0 0.0.0.255 area 0

R2(左侧区域为0,右侧区域为1):

                20.0.0.0/24 is subnetted, 1 subnets

        C 20.1.1.0 is directly connected, Serial2/0

                30.0.0.0/24 is subnetted, 1 subnets

        C 30.1.1.0 is directly connected, Serial3/0

R2(config)#router ospf 10
R2(config-router)#network 20.1.1.0 0.0.0.255 area 0
R2(config-router)#network 30.1.1.0 0.0.0.255 area 1
R2(config-router)#

R3:

                30.0.0.0/24 is subnetted, 1 subnets

        C 30.1.1.0 is directly connected, Serial3/0

                172.16.0.0/26 is subnetted, 2 subnets

        C 172.16.1.64 is directly connected, FastEthernet0/0.1----->网络号

        C 172.16.1.128 is directly connected, FastEthernet0/0.2----->网络号(所以子网掩码用反码)

R3(config)#router ospf 10
R3(config-router)#network 30.1.1.0 0.0.0.255 area 1
05:35:15: %OSPF-5-ADJCHG: Process 10, Nbr 30.1.1.1 on Serial3/0 from LOADING to FULL, Loading Done

R3(config-router)#network 172.16.1.64 0.0.0.63 area 1  //63=255-192
R3(config-router)#network 172.16.1.128 0.0.0.63 area 1 //63=255-192

 此时R1路由表:

                10.0.0.0/24 is subnetted, 1 subnets

        C 10.1.1.0 is directly connected, FastEthernet0/0

                20.0.0.0/24 is subnetted, 1 subnets

        C 20.1.1.0 is directly connected, Serial2/0

                30.0.0.0/24 is subnetted, 1 subnets

        O IA 30.1.1.0 [110/128] via 20.1.1.2, 00:08:50, Serial2/0

                172.16.0.0/26 is subnetted, 2 subnets

        O IA 172.16.1.64 [110/129] via 20.1.1.2, 00:05:13, Serial2/0

        O IA 172.16.1.128 [110/129] via 20.1.1.2, 00:04:51, Serial2/0

        R 192.168.1.0/24 [120/1] via 10.1.1.1, 00:00:26, FastEthernet0/0

        R 192.168.2.0/24 [120/1] via 10.1.1.1, 00:00:26, FastEthernet0/0

步骤三:配置路由重发布;

        想要全网连通,需要对边界路由器R1进行重发布: 

R1(config)#router rip 
R1(config-router)#redistribute ospf 10 metric 2  //对rip进行重发布
R1(config-router)#exit
R1(config)#router ospf 10
R1(config-router)#redistribute rip subnets //对ospf进行重发布
R1(config-router)#redistribute rip metric 20 //设置metric值

此刻,R1的路由表不会发生变化,但是边上的路由器会发生变化

EG:三层路由器:

                10.0.0.0/24 is subnetted, 1 subnets

        C 10.1.1.0 is directly connected, FastEthernet0/22

                20.0.0.0/24 is subnetted, 1 subnets

        R 20.1.1.0 [120/2] via 10.1.1.2, 00:00:04, FastEthernet0/22

                30.0.0.0/24 is subnetted, 1 subnets

        R 30.1.1.0 [120/2] via 10.1.1.2, 00:00:04, FastEthernet0/22

                172.16.0.0/26 is subnetted, 2 subnets

        R 172.16.1.64 [120/2] via 10.1.1.2, 00:00:04, FastEthernet0/22

        R 172.16.1.128 [120/2] via 10.1.1.2, 00:00:04, FastEthernet0/22

        C 192.168.1.0/24 is directly connected, Vlan10

        C 192.168.2.0/24 is directly connected, Vlan20

EG:R2 

                10.0.0.0/24 is subnetted, 1 subnets

        O E2 10.1.1.0 [110/20] via 20.1.1.1, 00:09:03, Serial2/0

                20.0.0.0/24 is subnetted, 1 subnets

        C 20.1.1.0 is directly connected, Serial2/0

                30.0.0.0/24 is subnetted, 1 subnets

        C 30.1.1.0 is directly connected, Serial3/0

                172.16.0.0/26 is subnetted, 2 subnets

        O 172.16.1.64 [110/65] via 30.1.1.2, 00:17:17, Serial3/0

        O 172.16.1.128 [110/65] via 30.1.1.2, 00:16:54, Serial3/0

        O E2 192.168.1.0/24 [110/20] via 20.1.1.1, 00:09:03, Serial2/0

        O E2 192.168.2.0/24 [110/20] via 20.1.1.1, 00:09:03, Serial2/0

步骤四:查看路由表;

步骤五:用ping命令测试连通性;

步骤六:查看配置; 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值