使用Route-policy控制路由
拓扑图
实验过程
IP地址选配
设备名称 | 接口 | ip地址 | 网关 |
---|---|---|---|
PCA | – | 10.0.1.2/24 | 10.0.1.1 |
PCB | – | 10.0.2.2/24 | 10.0.2.1 |
RTA | G0/0 | 10.0.1.1/24 | – |
S5/0 | 192.168.1.1/30 | – | |
S5/1 | 192.168.1.5/30 | – | |
RTB | S5/0 | 192.168.1.2/30 | – |
S5/1 | 192.168.2.1/30 | – | |
RTC | S5/0 | 192.168.1.6/30 | – |
S5/1 | 192.168.2.5/30 | – | |
RTD | G0/0 | 10.0.2.1/24 | – |
S5/0 | 192.168.2.2/30 | – | |
S5/1 | 192.168.2.6/30 | – |
在pc及路由上配置ip地址。
设置PC IP
PCA
PCB
基本配置
RTA
<H3C>sys
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]hostname RTA
[RTA]int g0/0
[RTA-GigabitEthernet0/0]ip add 10.0.1.1 24
[RTA-GigabitEthernet0/0]no shu
[RTA-GigabitEthernet0/0]no shutdown
[RTA-GigabitEthernet0/0]exit
[RTA]int g5/0
[RTA-GigabitEthernet5/0]ip add 192.168.1.1 30
[RTA-GigabitEthernet5/0]no shutdown
[RTA-GigabitEthernet5/0]exit
[RTA]int g5/1
[RTA-GigabitEthernet5/1]ip add 192.168.1.5 30
[RTA-GigabitEthernet5/1]no shutdown
[RTA-GigabitEthernet5/1]exit
[RTA]
RTB
<H3C>SYS
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]hostname RTB
[RTB]int g5/0
[RTB-GigabitEthernet5/0]ip add 192.168.1.2 30
[RTB-GigabitEthernet5/0]no shu
[RTB-GigabitEthernet5/0]no shutdown
[RTB-GigabitEthernet5/0]exi
[RTB-GigabitEthernet5/0]exit
[RTB]int g5/1
[RTB-GigabitEthernet5/1]ip add 192.168.2.1 30
[RTB-GigabitEthernet5/1]no shu
[RTB-GigabitEthernet5/1]no shutdown
[RTB-GigabitEthernet5/1]exi
[RTB-GigabitEthernet5/1]exit
[RTB]
RTC
[H3C]hostname RTC
[RTC]int g5/0
[RTC-GigabitEthernet5/0]ip add 192.168.1.6 30
[RTC-GigabitEthernet5/0]no shu
[RTC-GigabitEthernet5/0]no shutdown
[RTC-GigabitEthernet5/0]exi
[RTC-GigabitEthernet5/0]exit
[RTC]int g5/1
[RTC-GigabitEthernet5/1]ip add 192.168.2.5 30
[RTC-GigabitEthernet5/1]no shu
[RTC-GigabitEthernet5/1]no shutdown
[RTC-GigabitEthernet5/1]exi
[RTC-GigabitEthernet5/1]exit
[RTC]
RTD
[H3C]hostname RTD
[RTD]int g0/0
[RTD-GigabitEthernet0/0]ip add 10.0.2.1 24
[RTD-GigabitEthernet0/0]no shu
[RTD-GigabitEthernet0/0]no shutdown
[RTD-GigabitEthernet0/0]exi
[RTD-GigabitEthernet0/0]exit
[RTD]int g5/0
[RTD-GigabitEthernet5/0]ip add 192.168.2.2 30
[RTD-GigabitEthernet5/0]no shu
[RTD-GigabitEthernet5/0]no shutdown
[RTD-GigabitEthernet5/0]exi
[RTD-GigabitEthernet5/0]exit
[RTD]int g5/1
[RTD-GigabitEthernet5/1]ip add 192.168.2.6 30
[RTD-GigabitEthernet5/1]no shu
[RTD-GigabitEthernet5/1]no shutdown
[RTD-GigabitEthernet5/1]exi
[RTD-GigabitEthernet5/1]exit
[RTD]
引入静态路由
在路由器RTA、RTB、RTC上启用RIPV2进行路由学习,并将RTB和RTC的接口s5/0的路由发布,再RTA上配置静态路由10.1.0.0/24 和10.1.1.0/24,并将静态路由引入到rip协议中,并将所引入的路由缺省度量值改为2
。
配置RTA
[RTA]ip route-static 10.1.0.0 24 10.0.1.2
[RTA]ip route-static 10.1.1.0 24 10.0.1.2
[RTA]rip
[RTA-rip-1]network 10.0.0.0
[RTA-rip-1]network 192.168.1.0
[RTA-rip-1]version 2
[RTA-rip-1]undo summary
[RTA-rip-1]import-route static
[RTA-rip-1]default cost 2
[RTA-rip-1]
配置RTB
[RTB]rip
[RTB-rip-1]ne
[RTB-rip-1]network 192.168.1.0
[RTB-rip-1]ve
[RTB-rip-1]version 2
[RTB-rip-1]un
[RTB-rip-1]undo sum
[RTB-rip-1]undo summary
[RTB-rip-1]
配置RTC
[RTC]rip
[RTC-rip-1]network 192.168.1.0
[RTC-rip-1]version 2
[RTC-rip-1]undo summary
[RTC-rip-1]
配置完成之后在RTB和RTC上查看路由表,如下所示:
[RTB]dis ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
10.0.1.0/24 RIP 100 1 192.168.1.1 GE5/0
10.1.0.0/24 RIP 100 3 192.168.1.1 GE5/0
10.1.1.0/24 RIP 100 3 192.168.1.1 GE5/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/30 Direct 0 0 192.168.1.2 GE5/0
192.168.1.0/32 Direct 0 0 192.168.1.2 GE5/0
192.168.1.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.3/32 Direct 0 0 192.168.1.2 GE5/0
192.168.1.4/30 RIP 100 1 192.168.1.1 GE5/0
192.168.2.0/30 Direct 0 0 192.168.2.1 GE5/1
192.168.2.0/32 Direct 0 0 192.168.2.1 GE5/1
192.168.2.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.3/32 Direct 0 0 192.168.2.1 GE5/1
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
[RTB]
[RTC]dis ip routing-table
Destinations :