实验环境:
理论之前的博客已经写过,这次直接实验。
具体拓扑图如下,注意R3接口不够,需要添加两个NM-1FE-TX单板。
实际操作:
1.配置R1。
R1#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0 //进入接口模式
R1(config-if)#ip add 192.168.10.1 255.255.255.0 //设置IP地址与子网掩码
R1(config-if)#no shut //开启接口
R1(config-if)#
*Mar 1 00:01:35.883: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:01:36.883: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f0/1 //进入接口模式
R1(config-if)#ip add 192.168.20.1 255.255.255.0 //设置IP地址与子网掩码
R1(config-if)#no shut //开启接口
R1(config-if)#
*Mar 1 00:01:59.307: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:02:00.307: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#exit //退出
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.20.2 //添加默认路由
R1(config)#
2.配置R2。
R2#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/0 //进入接口模式
R2(config-if)#ip add 192.168.30.1 255.255.255.0 //设置IP地址与子网掩码
R2(config-if)#no shut //开启接口
R2(config-if)#
*Mar 1 00:04:47.727: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:04:48.727: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#int f0/1 //进入接口模式
R2(config-if)#ip add 192.168.20.2 255.255.255.0 //设置IP地址与子网掩码
R2(config-if)#no shut //开启接口
R2(config-if)#
*Mar 1 00:05:11.091: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:05:12.091: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config-if)#exit //退出
R2(config)#router ospf 1 //启用ospf协议,进程号为1
R2(config-router)#router-id 2.2.2.2 //设置router-id
R2(config-router)#network 192.168.30.0 0.0.0.255 area 1 //宣告网段
R2(config-router)#exit //退出
R2(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1 //添加静态路由
R2(config)#router ospf 1 //进入ospf 协议
R2(config-router)#redistribute connected subnets //OSPF引入直连网段
R2(config-router)#redistribute static subnets //OSPF引入静态路由
R2(config-router)#exit //退出
R2(config)#
*Mar 1 00:16:38.251: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2(config)#
3.配置R3。
R3#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int f0/0 //进入接口模式
R3(config-if)#ip add 192.168.30.2 255.255.255.0 //设置IP地址与子网掩码
R3(config-if)#no shut //开启接口
*Mar 1 00:11:13.671: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:11:14.671: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config-if)#int f0/1 //进入接口模式
R3(config-if)#ip add 192.168.40.1 255.255.255.0 //设置IP地址与子网掩码
R3(config-if)#no shut //开启接口
R3(config-if)#
*Mar 1 00:11:33.875: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:11:34.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config-if)#int f1/0 //进入接口模式
R3(config-if)#ip add 12.0.0.1 255.255.255.0 //设置IP地址与子网掩码
R3(config-if)#no shut //开启接口
R3(config-if)#
*Mar 1 00:11:57.195: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar 1 00:11:58.195: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
R3(config-if)#int f2/0 //进入接口模式
R3(config-if)#ip add 192.168.70.1 255.255.255.0 //设置IP地址与子网掩码
R3(config-if)#no shut //开启接口
R3(config-if)#
*Mar 1 00:12:21.339: %LINK-3-UPDOWN: Interface FastEthernet2/0, changed state to up
*Mar 1 00:12:22.339: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet2/0, changed state to up
R3(config-if)#exit //退出
R3(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.2 //添加默认路由
R3(config)#router ospf 1 //启用ospf协议,进程号为1
R3(config-router)#router-id 3.3.3.3 //设置router-id
R3(config-router)#network 192.168.30.0 0.0.0.255 area 1 //宣告网段
R3(config-router)#
*Mar 1 00:15:28.199: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R3(config-router)#network 192.168.40.0 0.0.0.255 area 0 //宣告网段
R3(config-router)#network 192.168.70.0 0.0.0.255 area 0 //宣告网段
R3(config-router)#default-information originate //OSPF引入默认路由
R3(config-router)#exit //退出
R3(config)#
*Mar 1 00:34:42.595: %OSPF-5-ADJCHG: Process 1, Nbr 4.4.4.4 on FastEthernet0/1 from LOADING to FULL, Loading Done
R3(config)#
4.配置R4。
R4#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int f0/0 //进入接口模式
R4(config-if)#ip add 192.168.40.2 255.255.255.0 //设置IP地址与子网掩码
R4(config-if)#no shut //开启接口
R4(config-if)#
*Mar 1 00:28:15.879: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:28:16.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R4(config-if)#int f0/1 //进入接口模式
R4(config-if)#ip add 192.168.50.1 255.255.255.0 //设置IP地址与子网掩码
R4(config-if)#no shut //开启接口
R4(config-if)#
*Mar 1 00:29:21.695: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:29:22.695: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R4(config-if)#exit //退出
R4(config)#router rip //启用RIP协议
R4(config-router)#version 2 //使用RIP版本2
R4(config-router)#no auto-summary //关闭自动汇总
R4(config-router)#network 192.168.50.0 //宣告网段
R4(config-router)#redistribute ospf 1 metric 5 //RIP引入OSPF路由
R4(config-router)#exit //退出
R4(config)#router ospf 1 //启用ospf协议,进程号为1
R4(config-router)#router-id 4.4.4.4 //设置router-id
R4(config-router)#network 192.168.40.0 0.0.0.255 area 0 //宣告网段
*Mar 1 00:33:22.651: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done
R4(config-router)#redistribute rip subnets //OSPF引入RIP路由
R4(config-router)#exit //退出
R4(config)#
5.配置R5。
R5#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#int f0/0 //进入接口模式
R5(config-if)#ip add 192.168.50.2 255.255.255.0 //设置IP地址与子网掩码
R5(config-if)#no shut //开启接口
R5(config-if)#int f0/1 //进入接口模式
R5(config-if)#
*Mar 1 00:36:28.747: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:36:29.815: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R5(config-if)#ip add 192.168.60.1 255.255.255.0 //设置IP地址与子网掩码
R5(config-if)#no shut //开启接口
R5(config-if)#
*Mar 1 00:36:57.275: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:36:58.275: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R5(config-if)#exit //退出
R5(config)#router rip //启用RIP协议
R5(config-router)#version 2 //使用RIP版本2
R5(config-router)#no auto-summary //关闭自动汇总
R5(config-router)#network 192.168.50.0 //宣告网段
R5(config-router)#network 192.168.60.0 //宣告网段
R5(config-router)#exit //退出
R5(config)#
6.配置R6。
R6#conf t //进入全局模式
Enter configuration commands, one per line. End with CNTL/Z.
R6(config)#int f0/0 //进入接口模式
R6(config-if)#ip add 12.0.0.2 255.255.255.0 //设置IP地址与子网掩码
R6(config-if)#no shut //开启接口
R6(config-if)#int f0/1 //进入接口模式
R6(config-if)#
*Mar 1 00:19:13.363: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:19:14.363: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R6(config-if)#ip add 13.0.0.1 255.255.255.0 //设置IP地址与子网掩码
R6(config-if)#no shut //开启接口
R6(config-if)#exit //退出
R6(config)#
*Mar 1 00:19:37.803: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:19:38.803: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R6(config)#ip route 192.168.0.0 255.255.0.0 12.0.0.1 //设置默认路由
R6(config)#
7.分别给PC1、PC2、PC3、PC四(防违禁)设置IP地址
(1)给PC1设置IP地址
PC1> ip 192.168.10.2 192.168.10.1 //设置IP和网关
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1
(2)给PC2设置IP地址
PC2>
PC2> ip 192.168.70.2 192.168.70.1 //设置IP和网关
Checking for duplicate address...
PC1 : 192.168.70.2 255.255.255.0 gateway 192.168.70.1
(3)给PC3设置IP地址
PC3>
PC3> ip 13.0.0.13 13.0.0.1 //设置IP和网关
Checking for duplicate address...
PC1 : 13.0.0.13 255.255.255.0 gateway 13.0.0.1
(4)给PC四设置IP地址
PC四> ip 192.168.60.2 192.168.60.1 //设置IP和网关
Checking for duplicate address...
PC1 : 192.168.60.2 255.255.255.0 gateway 192.168.60.1
8.验证实验结果
分别用PC1去ping其它所有PC机,都能互通,实验成功。
PC1> ping 192.168.70.2
192.168.70.2 icmp_seq=1 timeout
192.168.70.2 icmp_seq=2 timeout
84 bytes from 192.168.70.2 icmp_seq=3 ttl=61 time=93.680 ms
84 bytes from 192.168.70.2 icmp_seq=4 ttl=61 time=93.717 ms
84 bytes from 192.168.70.2 icmp_seq=5 ttl=61 time=93.722 ms
PC1> ping 13.0.0.13
13.0.0.13 icmp_seq=1 timeout
13.0.0.13 icmp_seq=2 timeout
84 bytes from 13.0.0.13 icmp_seq=3 ttl=60 time=124.965 ms
84 bytes from 13.0.0.13 icmp_seq=4 ttl=60 time=124.858 ms
84 bytes from 13.0.0.13 icmp_seq=5 ttl=60 time=125.056 ms
PC1> ping 192.168.60.2
192.168.60.2 icmp_seq=1 timeout
84 bytes from 192.168.60.2 icmp_seq=2 ttl=59 time=156.210 ms
84 bytes from 192.168.60.2 icmp_seq=3 ttl=59 time=157.946 ms
84 bytes from 192.168.60.2 icmp_seq=4 ttl=59 time=166.144 ms
84 bytes from 192.168.60.2 icmp_seq=5 ttl=59 time=156.238 ms
原文地址:https://blog.51cto.com/14449541/2440110
时间: 2024-10-09 23:11:55