简介
FRR 是一个路由软件套件,它衍生自 Quagga,并在 GNU GPL2 许可下分发。与 Quagga 一样,它为类 Unix 平台提供了所有主要路由协议的实现,例如 OSPF、 路由信息协议(Routing Information Protocol)(RIP)、 边界网关协议(Border Gateway Protocol)(BGP) 和 中间系统到中间系统(Intermediate system-to-intermediate system) (IS-IS)。
FRRouting(FRR)是用于Linux和Unix平台的IP路由协议套件,其中 包括BGP,IS-IS,LDP,OSPF,PIM和RIP的协议守护程序。FRR与本机Linux / Unix IP网络堆栈的无缝集成 使其适用于各种用例,包括将 主机/ VM /容器连接到网络,广告网络服务,LAN 交换和路由,Internet接入路由器以及Internet对等。FRR起源于Quagga项目。实际上,它是由许多Quagga长期开发人员开始的,他们共同努力以改善Quagga的行之有效的基础,以创建可用的最佳路由协议堆栈。
官网文档:http://docs.frrouting.org/en/latest/overview.html
演示步骤
TIP:代码块#开头为全部主机都需配置,[root@serverxx ~]#开头则为对应主机
环境
主机 | 网卡 | IP | gw |
---|---|---|---|
server01 | enp0s3 | 192.168.1.11 | 192.168.1.1 |
server02 | enp0s3---enp0s8 | 192.168.1.12---172.25.0.6 | 192.168.1.1---172.25.0.1 |
server03 | enp0s3---enp0s8 | 172.25.0.5---192.168.56.102 | 172.25.0.1---192.168.56.1 |
目标
server01和server02可以访问server03的192.168.56.102
路由流程:
(1)server01--enp0s3-->enp0s3--server02--enp0s8-->enp0s3--server03--enp0s8
(2)server03--enp0s3-->enp0s8--server02--enp0s3-->enp0s3--server01
查看路由表状态
[root@server01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp0s3
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
[root@server02 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp0s3
0.0.0.0 172.25.0.1 0.0.0.0 UG 101 0 0 enp0s8
172.25.0.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s8
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
[root@server03 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.0.1 0.0.0.0 UG 100 0 0 enp0s3
172.25.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.56.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s8
安装frr软件
# FRRVER="frr-8"
# curl -O https://rpm.frrouting.org/repo/$FRRVER-repo-1-0.el8.noarch.rpm
# sudo yum install ./$FRRVER*
# sudo yum install frr frr-pythontools
配置frr
# sed -i "s/ospfd=no/ospfd=yes/" /etc/frr/daemons
# systemctl enable frr && systemctl start frr
配置ospf路由
[root@server01 ~]# vtysh
config t
router ospf
network 192.168.1.0/24 area 0
end
do write file
exit
[root@server02 ~]# vtysh
config t
router ospf
network 192.168.1.0/24 area 0
network 172.25.0.0/24 area 0
end
do write file
exit
[root@server03 ~]# vtysh
config t
router ospf
network 172.25.0.0/24 area 0
network 192.168.56.0/24 area 0
end
do write file
exit
配置路由转发
[root@server02 ~]# echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf
[root@server02 ~]# sysctl -p
由于数据在server02上中转,仅配置server02
注意:frr服务执行restart后转发配置会失效,需要重新执行sysctl -p
查看路由
[root@server01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp0s3
172.25.0.0 192.168.1.12 255.255.255.0 UG 20 0 0 enp0s3
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.56.0 192.168.1.12 255.255.255.0 UG 20 0 0 enp0s3
[root@server02 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp0s3
0.0.0.0 172.25.0.1 0.0.0.0 UG 101 0 0 enp0s8
172.25.0.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s8
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.56.0 172.25.0.5 255.255.255.0 UG 20 0 0 enp0s8
[root@server03 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.0.1 0.0.0.0 UG 100 0 0 enp0s3
172.25.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.1.0 172.25.0.6 255.255.255.0 UG 20 0 0 enp0s3
192.168.56.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s8
验证
# ping -c 1 10.0.3.15 && echo "connect success" || echo "connect fail"