交换机
园区网交换机
数据中心与云计算交换机
中小网络精简型交换机
工业交换机
意图网络指挥官
无线
放装型无线接入点
墙面型无线接入点
智分无线接入点
室外无线接入点
场景化无线
无线控制器
小锐A系列
统一运维
身份管理
服务产品
运营商
政府
金融
互联网
电力能源
制造业
高教/职教
医疗卫生
交通
地产酒店文旅·连锁服务
公共安全
功能介绍:
静态路由就是手工配置的路由,使得数据包能够按照预定的路径传送到指定的目标网络。当不能通过动态路由协议学到一些目标网络的路由时,配置静态路由就会显得十分重要。
一、组网需求
路由器R1的F0/0、F0/1接口在vrf abc下,路由器R2为普通全局路由器, 如下网络,需要实现全网互通。
二、组网拓扑
三、配置要点
1、在R1上配置vrf abc
2、基本ip地址配置
3、在R1上将对应的接口划入vrf
4、配置静态路由
四、配置步骤
1、在R1上配置vrf abc
注意:
vrf 是本地有效的,在本端起了vrf,只是本路由器上相同vrf下的接口互通,不同vrf的接口逻辑隔离,与对端路由器是否起vrf无关
Ruijie(config)#hostname R1
R1(config)#ip vrf abc //在路由器上启用vrf abc
R1(config-vrf)#exit
2、基本ip地址配置
R1(config)#interface fastEthernet 0/2
R1(config-if-FastEthernet 0/2)#ip address 192.168.1.1 255.255.255.0
R1(config-if-FastEthernet 0/2)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if-FastEthernet 0/0)#ip address 10.1.1.1 255.255.255.0
R1(config-if-FastEthernet 0/0)#exit
Ruijie(config)#hostname R2
R2(config)#interface fastEthernet 0/0
R2(config-if-FastEthernet 0/0)#ip address 192.168.1.2 255.255.255.0
R2(config-if-FastEthernet 0/0)#exit
R2(config)#interface fastEthernet 0/1
R2(config-if-FastEthernet 0/1)#ip address 10.2.1.1 255.255.255.0
R2(config-if-FastEthernet 0/1)#exit
3、在R1上将对应的接口划入vrf
注意:
将接口划入到vrf时,若该接口有配置ip地址,会将ip地址移除,需要重新配置该接口的ip地址。
R1(config)#interface fastEthernet 0/2
R1(config-if-FastEthernet 0/2)#ip vrf forwarding abc //配置vrf abc
% Interface FastEthernet 0/2 IP address 192.168.1.1 removed due to enabling VRF abc
R1(config-if-FastEthernet 0/2)#ip address 192.168.1.1 255.255.255.0 //重新配置F0/2接口的ip地址
R1(config-if-FastEthernet 0/2)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if-FastEthernet 0/0)#ip vrf forwarding abc //将接口划入vrf abc
% Interface FastEthernet 0/0 IP address 10.1.1.1 removed due to enabling VRF abc
R1(config-if-FastEthernet 0/0)#ip address 10.1.1.1 255.255.255.0 //重新配置接口的ip地址
R1(config-if-FastEthernet 0/0)#exit
4、配置静态路由
注意:
vrf下的静态路由配置,只是配置命令多了vrf abc,配置vrf下的静态路由注意事项与配置普通静态路由一致,请参考静态路由配置的相关章节。
R1(config)#ip route vrf abc 10.2.1.0 255.255.255.0 192.168.1.2 //配置vrf abc下的静态路由
R2(config)#ip route 10.1.1.0 255.255.255.0 192.168.1.1 //R2上未启用vrf,配置普通的静态路由
五、配置验证
1、在内网电脑上ping对端内网的地址,若能ping通,代表vrf下的静态路由配置正确。
ping的命令“开始菜单”-----“运行”------敲入cmd-----ping x.x.x.x (x.x.x.x是对端内网的地址)
2、使用命令 show ip route vrf abc查看vrf下的路由
R1#show ip route vrf abc
Routing Table: abc
Codes: C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default
Gateway of last resort is no set
C 10.1.1.0/24 is directly connected, FastEthernet 0/0
C 10.1.1.1/32 is local host.
S 10.2.1.0/24 [1/0] via 192.168.1.2
C 192.168.1.0/24 is directly connected, FastEthernet 0/2
C 192.168.1.1/32 is local host.