文章目录
一.配置环境
1.在华为模拟器ensp上设置三个普通路由器先打开ensp,分别用网线连接,如下图
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
命令
[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 路由表中有回去的路,不用再配置
测试:
[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