一、实验明细
设备:4台路由器
路径:R1到R4有两条路径,
一条是R1—R3—R4,
另外一条是R1—R2—R3—R4
目的:PC1可以和PC2通信
网段规划
R1和R2相连的网段是10.10.12.0(其中的12是路由器1和路由器2)
R2和R3相连的网段是10.10.23.0(其中的23是路由器2和路由器3)
R1和R3相连的网段是10.10.13.0(其中的13是路由器1和路由器3)
R3和R4相连的网段是10.10.34.0(其中的34是路由器3和路由器4)
Ip规划:
Pc1
ip:10.10.10.100/24
Gw:10.10.10.1
Pc2
ip:10.10.40.100/24
Gw:10.10.40.1
R1:
Ge0/0/0:10.10.12.1/24
Ge0/0/1:10.10.13.1/24
Ge0/0/2:10.10.10.1/24
R2:
Ge0/0/1:10.10.23.2/24
Ge0/0/1:10.10.12.2/24
R3:
Ge0/0/0:10.10.13.3/24
Ge0/0/1:10.10.23.3/24
Ge0/0/2:10.10.34.3/24
R4:
Ge0/0/1:10.10.40.4/24
Ge0/0/2:10.10.40.1/24
二、拓扑图
![3394a5839cdd11cfbdb07bf2e9bd8337.png](https://img-blog.csdnimg.cn/img_convert/3394a5839cdd11cfbdb07bf2e9bd8337.png)
三、配置:
3.1PC1
![5bc8a7ecc1fef965130c79fb9ea98300.png](https://img-blog.csdnimg.cn/img_convert/5bc8a7ecc1fef965130c79fb9ea98300.png)
3.2PC2
![fe92dbc853988839277d15f743919694.png](https://img-blog.csdnimg.cn/img_convert/fe92dbc853988839277d15f743919694.png)
3.3R1
sys
[Huawei]sys R1
![d65de6f937ab864b3367968c66bee760.png](https://img-blog.csdnimg.cn/img_convert/d65de6f937ab864b3367968c66bee760.png)
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.10.12.1 24
![3af73db998175bd8ee62503ebae7236e.png](https://img-blog.csdnimg.cn/img_convert/3af73db998175bd8ee62503ebae7236e.png)
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.10.13.1 24
![6dd227f630c9fc5dd6c60dc6f300fdfe.png](https://img-blog.csdnimg.cn/img_convert/6dd227f630c9fc5dd6c60dc6f300fdfe.png)
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 10.10.10.1 24
![7e6b876a2f49fca92a356ff550c9912b.png](https://img-blog.csdnimg.cn/img_convert/7e6b876a2f49fca92a356ff550c9912b.png)
查看
[R1]disp cu int
![d8a375d17071bb98ba3b1d2411173850.png](https://img-blog.csdnimg.cn/img_convert/d8a375d17071bb98ba3b1d2411173850.png)
测试PC1到R1
PC>ping 10.10.10.1
![5296ccfa34cfed779eefe6adfa454198.png](https://img-blog.csdnimg.cn/img_convert/5296ccfa34cfed779eefe6adfa454198.png)
3.4R2
sys
[Huawei]sysname R2
![ffa8a5d154cb6d137416b8fc361c6c21.png](https://img-blog.csdnimg.cn/img_convert/ffa8a5d154cb6d137416b8fc361c6c21.png)
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 10.10.23.2 24
![99a7f4051a76b6e19b9b14a1a9aaeb3c.png](https://img-blog.csdnimg.cn/img_convert/99a7f4051a76b6e19b9b14a1a9aaeb3c.png)
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.10.12.2 24
![e3c51b920cc2b03d072e9a19ed863c68.png](https://img-blog.csdnimg.cn/img_convert/e3c51b920cc2b03d072e9a19ed863c68.png)
查看
[R2]disp current-configuration interface
![df11546c7d3c017b44868ab6eb8f4863.png](https://img-blog.csdnimg.cn/img_convert/df11546c7d3c017b44868ab6eb8f4863.png)
测试R1到R2
ping 10.10.12.2
![d319d56d3691cb5811104cf0000555be.png](https://img-blog.csdnimg.cn/img_convert/d319d56d3691cb5811104cf0000555be.png)
3.5R3
sys
[Huawei]sysname R3
![62511f59e28f6adb77c5a65e6462be72.png](https://img-blog.csdnimg.cn/img_convert/62511f59e28f6adb77c5a65e6462be72.png)
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.10.13.3 24
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 10.10.23.3 24
![85f2c3acf7ee626c6a6f33af03b509fa.png](https://img-blog.csdnimg.cn/img_convert/85f2c3acf7ee626c6a6f33af03b509fa.png)
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet0/0/2]ip address 10.10.34.3 24
![4ac2b16e6238a989c5e32629726b282f.png](https://img-blog.csdnimg.cn/img_convert/4ac2b16e6238a989c5e32629726b282f.png)
查询
[R3]disp current-configuration interface
![8a193558c22fda27fb14b7f165aebc21.png](https://img-blog.csdnimg.cn/img_convert/8a193558c22fda27fb14b7f165aebc21.png)
测试R3到R1
[R3]ping 10.10.13.1
![c0d89840c43d96c4e21f90e7c1407067.png](https://img-blog.csdnimg.cn/img_convert/c0d89840c43d96c4e21f90e7c1407067.png)
测试R3到R2
[R3]ping 10.10.23.2
![e649472d9ffe50a47966d08a124ddb43.png](https://img-blog.csdnimg.cn/img_convert/e649472d9ffe50a47966d08a124ddb43.png)
3.6R4
system-view
[Huawei]sysname R4
![a19eeb5ef5d823d068564e4764076450.png](https://img-blog.csdnimg.cn/img_convert/a19eeb5ef5d823d068564e4764076450.png)
[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 10.10.34.4 24
![eab14b5fedc75ca4a67f46593497868a.png](https://img-blog.csdnimg.cn/img_convert/eab14b5fedc75ca4a67f46593497868a.png)
[R4]interface GigabitEthernet 0/0/2
[R4-GigabitEthernet0/0/2]ip address 10.10.40.1 24
![91f4745f3a8181f6276838be53e2a94d.png](https://img-blog.csdnimg.cn/img_convert/91f4745f3a8181f6276838be53e2a94d.png)
查询
[R4]disp current-configuration interface
![d7fba97f6568e1de334a1c77674f9926.png](https://img-blog.csdnimg.cn/img_convert/d7fba97f6568e1de334a1c77674f9926.png)
或者
disp ip interface brief
![d592fcac1fd900cdfdf44955f4cd6eb8.png](https://img-blog.csdnimg.cn/img_convert/d592fcac1fd900cdfdf44955f4cd6eb8.png)
测试R4 到PC2
[R4]ping 10.10.40.100
![3f12d850d17b6fc339a0e8e1932daa32.png](https://img-blog.csdnimg.cn/img_convert/3f12d850d17b6fc339a0e8e1932daa32.png)
[R4]ping 10.10.34.3
![c5114d3ba5cdfbcede05eaa02e12382c.png](https://img-blog.csdnimg.cn/img_convert/c5114d3ba5cdfbcede05eaa02e12382c.png)
此时接口的IP地址配置完毕,并且相邻设备可以通信。
四、配置路由
4.1PC1到达PC2
PC1所直连的路由器是R1
disp ip routing-table
![5e7c8d82b5110322d3c713df1fc490ad.png](https://img-blog.csdnimg.cn/img_convert/5e7c8d82b5110322d3c713df1fc490ad.png)
由上图知悉,全部是直连路由
而PC1到PC2如果通信,需要在R1上有到PC2所在网段的路由,才可以到达PC2,所以在R1上写到达PC2的静态路由,PC1到PC2经过两条路由,一条是R1—R3—R4,
另外一条是R1—R2—R3—R4,我们选最短的R1—R3—R4这条路由。
[R1]ip route-static 10.10.40.0 24 10.10.13.3
![cb820cc62b194460d01386b5f1e314bb.png](https://img-blog.csdnimg.cn/img_convert/cb820cc62b194460d01386b5f1e314bb.png)
现在PC1到达R3
查看R3上的路由
disp ip routing-table
![08591635257c609bfdb9b74a59605389.png](https://img-blog.csdnimg.cn/img_convert/08591635257c609bfdb9b74a59605389.png)
由上图可知,R3上没有到10.10.40.0网段的路由,在R3上增加静态路由
[R3]ip route-static 10.10.40.0 24 10.10.34.4
![d0f9e02ccb61ec8a0ca06e9161abf5e7.png](https://img-blog.csdnimg.cn/img_convert/d0f9e02ccb61ec8a0ca06e9161abf5e7.png)
现在PC1到达R4
查看R4
[R4]disp ip routing-table
![76d2183ea37085552b72b29d114a1147.png](https://img-blog.csdnimg.cn/img_convert/76d2183ea37085552b72b29d114a1147.png)
由上图知悉,R4上有到10.10.40.0的直连(Direct)路由
此时PC1可以到PC2,但是PC2不能返回PC1,需要添加路由R4—R3—R1
4.2pc2到pc1
R4
[R4]ip route-static 10.10.10.0 24 10.10.34.3
![19e2caa3b4958d8483841d3362cca6ca.png](https://img-blog.csdnimg.cn/img_convert/19e2caa3b4958d8483841d3362cca6ca.png)
R3
[R3]ip route-static 10.10.10.0 24 10.10.13.1
![431b7ed8734edc21b639285608e567bf.png](https://img-blog.csdnimg.cn/img_convert/431b7ed8734edc21b639285608e567bf.png)
R1
disp ip routing-table
![e132fe478165bff9629f0cca2db9b5de.png](https://img-blog.csdnimg.cn/img_convert/e132fe478165bff9629f0cca2db9b5de.png)
由上图知悉,R1上有到10.10.10.0网段的直连(Direct)路由。
五、测试
5.1PC1上ping PC2
Pc>ping 10.10.40.100
![71fea2767e8dc04286c531730c09dc84.png](https://img-blog.csdnimg.cn/img_convert/71fea2767e8dc04286c531730c09dc84.png)
由上图知悉,PC1可以和PC2通信
PC>tracert 10.10.40.100
![79e4ea78bcc22c26d2f8d65a53abbd37.png](https://img-blog.csdnimg.cn/img_convert/79e4ea78bcc22c26d2f8d65a53abbd37.png)
由上图可知,PC1到PC2路径是
10.10.10.1----R1
10.10.13.3----R3
10.10.34.4----R4
10.10.40.100----PC2
5.2PC2到PC1
Tracert 10.10.10.100
![c86630b876b1782f9ce1cfed167d0fcd.png](https://img-blog.csdnimg.cn/img_convert/c86630b876b1782f9ce1cfed167d0fcd.png)
10.10.40.1----R4
10.10.34.3----R3
10.10.13.1----R1
10.10.10.100----PC1
此时R1和R3用静态路由的方法可以通信,在网络中存在多路由器的情况下,必须考虑报文的过去和回来两个方向的路由条目,在经过所有的设备上都要考虑静态路由,同时说明,设备间通信在路由表中必须有需要通信的设备的路由条目。