路由转发实例-指定数据传输方向

一.配置环境
1.在华为模拟器ensp上设置三个普通路由器先打开ensp,分别用网线连接,如下图

mark
mark

2.配置思路

1)R1:配置接口 int g0 ,ip add 12.0.0.1 24,un sh ;int g1, ip add 13.0.0.1 24, un sh

2)R2:配置接口 int g0 ,ip add 12.0.0.2 24,un sh ;int g1, ip add 23.0.0.1 24, un sh;

int loo 0 ,ip add 2.2.2.2 24

3)R3:配置接口 int g1 ,ip add 13.0.0.3 24,un sh ;int g3, ip add 23.0.0.3 24, un sh;

int loo 0 ,ip add 3.3.3.3 24; int loo 1 ,ip add 4.4.4.4 24;

4)按照需求配路由:

需求1:数据去的方向R2- R1-R3 所以再 R1 和R2配置静态路由指定路

R2: ip route-static 3.3.3.0 24 12.0.0.1

R1: ip route-static 3.3.3.0 24 13.0.0.3

数据回去的方向 R3-R2

R3: ip route-static 2.2.2.0 24 23.0.0.2

需求2:数据去的方向R2-R3 回来的的方向R3-R2

去:R2: ip route-static 4.4.4.0 24 23.0.0.3

回:R3: ip route-static 2.2.2.0 24 23.0.0.2

二.配置过程
1.配各路由接口地址

配置R1

[Huawei]sysname R1

[R1]int GigabitEthernet 0/0/1

[R1-GigabitEthernet0/0/1]ip add 13.0.0.1 24

[R1-GigabitEthernet0/0/1]un sh

[R1-GigabitEthernet0/0/1]int GigabitEthernet 0/0/0

[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24

[R1-GigabitEthernet0/0/0]un sh

[R1-GigabitEthernet0/0/1]dis ip int brief

GigabitEthernet0/0/0       12.0.0.1/24     up     up    

GigabitEthernet0/0/1       13.0.0.1/24     up     up

配置R2接口

[R2]interface g0/0/3

[R2-GigabitEthernet0/0/3]ip add 23.0.0.2 24

[R2-GigabitEthernet0/0/3]un sh

[R2-GigabitEthernet0/0/3]interface g0/0/0

[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24

[R2-GigabitEthernet0/0/0]un sh

[R2-GigabitEthernet0/0/0]q

[R2]int loo 0

[R2-LoopBack0]ip address 2.2.2.2 24

[R2-LoopBack0]q

[R2]dis ip int brief

GigabitEthernet0/0/0       12.0.0.2/24     up     up

GigabitEthernet0/0/3       23.0.0.2/24     up     up    

LoopBack0             2.2.2.2/24      up      up

配置R3接口

[R3]int g0/0/1

[R3-GigabitEthernet0/0/1]ip add 13.0.0.3 24

[R3-GigabitEthernet0/0/1]un sh 

[R3-GigabitEthernet0/0/1]int g0/0/3

[R3-GigabitEthernet0/0/3]ip add 23.0.0.3 24

[R3-GigabitEthernet0/0/3]un sh

[R3-GigabitEthernet0/0/3]int loo 0

[R3-LoopBack0]ip add 3.3.3.3 24

[R3-LoopBack0]int loo 1

[R3-LoopBack1]ip add 4.4.4.4 24

[R3-LoopBack1]q

[R3]dis ip int brief

GigabitEthernet0/0/1       13.0.0.3/24     up     up    

GigabitEthernet0/0/3       23.0.0.3/24      up     up    

LoopBack0             3.3.3.3/24      up     up(s)   

LoopBack1             4.4.4.4/24      up     up(s)   
2.按照需求配置路由
需求一 :去的路R2-R1-R3 回的路 R3-R2

mark

mark

mark

命令

[R2]ip route-static 3.3.3.0 24 12.0.0.1

[R1]ip route-static 3.3.3.0 24 13.0.0.3

[R3]ip route-static 2.2.2.0 24 23.0.0.2

测试

[R2]ping -a 2.2.2.2 3.3.3.3

 [R3]ping -a 3.3.3.3 2.2.2.2
需求二 :去的路R2-R3 回的路 R3-R2

[R2]ip route-static 4.4.4.0 24 23.0.0.3

[R3]dis ip routing-table 路由表中有回去的路,不用再配置

mark

测试:

[R2]ping -a 2.2.2.2 4.4.4.4

 PING 4.4.4.4: 56 data bytes, press CTRL_C to break

  Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=255 time=40 ms

  Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=255 time=40 ms

  Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=255 time=50 ms

  Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=255 time=50 ms

Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=255 time=40 ms

[R3]ping -a 4.4.4.4 2.2.2.2

 PING 2.2.2.2: 56 data bytes, press CTRL_C to break

  Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=50 ms

  Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=10 ms

  Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms

  Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=40 ms

 Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=30 ms
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值