6.5
完成计网实验二路由器动态路由的配置方法
)三层交换机的基本配置
Switch(config)#vlan 10 !新建VLAN10
Switch(config)#interface fastethernet0/1 !将F0/1放入VLAN10
Switch(config-if)#switchport access vlan 10
Switch(config)#vlan 50 !新建VLAN50
Switch(config)#interface fastethernet0/5 !将F0/5放入VLAN50
Switch(config-if)#switchport access vlan 50
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#ip address 172.16.1.2 255.255.255.0
Switch(config-if)#no shutdown !创建VLAN 10虚拟接口,并配置IP
Switch(config-if)#exit
Switch(config)#interface vlan 50
Switch(config-if)#ip address 172.16.5.1 255.255.255.0
Switch(config-if)#no shutdown !创建VLAN 50虚拟接口,并配置IP
验证测试:
Switch#show vlan
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Fa0/24
10 VLAN0010 active Fa0/1
50 VLAN0050 active Fa0/5
Switch#show ip interface
Interface :VL10
Description :Vlan 10
OperStatus :UP
ManagementStatus :Enabled
Primary Internet address :172.16.1.2/24
Broadcast address :255.255.255.255
Physaddress :00d0.f8ff.8ab5
Interface :VL50
Description :Vlan 50
OperStatus :UP
ManagementStatus :Enabled
Primary Internet address :172.16.5.1/24
Broadcast address :255.255.255.255
Physaddress :00d0.f8ff.8ab6
2) 路由器基本配置
在路由器A上配置端口IP
RA(config)#interface fastethernet 1/0
RA(config-if)#ip address 172.16.1.1 255.255.255.0
RA(config-if)#no shutdown
RA(config)#interface serial 1/2
RA(config-if)#ip address 172.16.2.1 255.255.255.0
RA(config-if)# Clock rate 64000
RA(config-if)#no shutdown
在路由器B上配置端口IP
RB(config)#interface fastethernet 1/0
RB(config-if)#ip address 172.16.3.1 255.255.255.0
RB(config-if)#no shutdown
RB(config)#interface serial 1/2
RB(config-if)#ip address 172.16.2.2 255.255.255.0
RB(config-if)#no shutdown
验证测试:验证路由器接口的配置和状态
RA#show ip interface brief
Interface IP-Address(Pri) OK? Status
serial 1/2 172.16.2.1/24 YES UP
serial 1/3 no address YES DOWN
FastEthernet 1/0 172.16.1.1/24 YES UP
FastEthernet 1/1 no address YES DOWN
Null 0 no address YES UP
RB#show ip interface brief
Interface IP-Address(Pri) OK? Status
serial 1/2 172.16.2.2/24 YES UP
serial 1/3 no address YES DOWN
FastEthernet 1/0 172.16.3.1/24 YES UP
FastEthernet 1/1 no address YES DOWN
Null 0 no address YES UP
2、配置RIPv2路由协议
1)三层交换机配置RIP协议
Switch(config)#router rip
Switch(config-router)#network 172.16.1.0 !申明本设备的直连网段
Switch(config-router)#network 172.16.5.0
Switch(config-router)#version 2
2)RA配置RIP v2协议
RA(config)#router rip
RA(config-router)#network 172.16.1.0
RA(config-router)#network 172.16.2.0
RA(config-router)#version 2
RA(config-router)#no auto-summary !关闭路由信息的自动汇总功能
3)RB配置RIP v2协议
RB(config)#router rip
RB(config-router)#network 172.16.2.0
RB(config-router)#network 172.16.3.0
RB(config-router)#version 2
RB(config-router)#no auto-summary
3、验证三台路由设备的路由表,查看是否自动学习了其他网段的路由信息。
Switch#show ip route
Type: C - connected, S - static, R – RIP,O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
Type Destination IP NEXT hop Interface Distance Metric Status
C 172.16.1.0/24 0.0.0.0 VL10 0 0 Active
C 172.16.2.0/24 172.16.1.1 VL10 120 2 Active
C 172.16.3.0/24 172.16.1.1 VL10 120 3 Active
C 172.16.5.0/24 0.0.0.0 VL50 0 0 Active
RA#show ip route
Codes: C - connected, S - static, R - RIP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
* - candidate default
Gateway of last resort is no set
C 172.16.1.0/24 is directly connected, FastEthernet 1/0
C 172.16.1.1/32 is local host.
C 172.16.2.0/24 is directly connected, serial 1/2
C 172.16.2.1/32 is local host.
R 172.16.5.0/24 [120/1] via 172.16.1.2,00:00:01,Fastethernet1/0
R 172.16.3.0/24 [120/1] via 172.16.2.2,00:00:21,serial 1/2
RB#show ip route
Codes: C - connected, S - static, R - RIP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
* - candidate default
Gateway of last resort is no set
C 172.16.2.0/24 is directly connected, serial 1/2
C 172.16.2.2/32 is local host.
C 172.16.3.0/24 is directly connected, Fastethernet1/0
C 172.16.3.1/32 is local host.
R 172.16.1.0/24 [120/1] via 172.16.2.1,00:00:3,serial 1/2
R 172.16.5.0/24 [120/2] via 172.16.2.1,00:00:03,serial 1/2
4、配置OSPF路由协议
router ospf
Step1
Router(config)#router ospf process-id
使用router ospf 命令在路由器上启用OSPF协议
Process id 代表路由器上运行的不用的OSPF进程号
是一个1~65535的数字
Step 2
Router(config-router)#network network-address wildeard-mark area area-id
使用network 命令来指定运行OSPF协议的每个主网络
Wildarad-mask:OSPF需要通配符掩码(子网掩码的范掩码)
area area-id : 指ospf区域,单区域中使用0作为主干区域
5、测试网络的连通性
从PCA ping PCB
网络跟踪命令:
tracert ip
结果:显示到达目的主机经过的每一跳路由的接口地址