22. 详解 FRRouting --> OSPF 配置

FRRouting 简介

FRRouting (FRR) is a free and open source Internet routing protocol suite for Linux and Unix platforms. It implements BGP, OSPF, RIP, IS-IS, PIM, LDP, BFD, Babel, PBR, OpenFabric and VRRP, with alpha support for EIGRP and NHRP.
官方网站链接。 如何移植 FRRoutin 项目中 OpenWRT中,请参考链接

本篇介绍如何在 OpenWRT 中,应用配置 OSPF 协议,测试方案的网络拓扑如下:
在这里插入图片描述
此网络拓扑借用IPSec中实验拓扑,实验环境是在PVE虚拟集群中布置 OpenWRT 虚拟机方式。

实验搭建:
两台路由器分别是moon(10.1.1.92/24)和sun(10.2.2.94/24),在设备上开启 OSPF 路由协议;
两台主机 alice 和 bob;alice 接入到 moon 网关,bob 接入 sun 网关;实验中并未实验此客户端。
图片中的Webserver服务器不做应用。

第1步 开启 OSPF 应用

1.1. 配置 FRRouting 的工作参数

root@OpenWRT $ vi /etc/frr/daemons

zebra=no
bgpd=no
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
ldpd=no
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
staticd=no
pbrd=no
bfdd=no
fabricd=no
 
#
# If this option is set the /etc/init.d/frr script automatically loads
# the config via "vtysh -b" when the servers are started.
# Check /etc/pam.d/frr if you intend to use "vtysh"!
#
vtysh_enable=yes
zebra_options=" -s 90000000 --daemon -A 127.0.0.1"
bgpd_options="   --daemon -A 127.0.0.1"
ospfd_options="  --daemon -A 127.0.0.1"
ospf6d_options=" --daemon -A ::1"
ripd_options="   --daemon -A 127.0.0.1"
ripngd_options=" --daemon -A ::1"
isisd_options="  --daemon -A 127.0.0.1"
pimd_options="  --daemon -A 127.0.0.1"
ldpd_options="  --daemon -A 127.0.0.1"
nhrpd_options="  --daemon -A 127.0.0.1"
eigrpd_options="  --daemon -A 127.0.0.1"
babeld_options="  --daemon -A 127.0.0.1"
sharpd_options="  --daemon -A 127.0.0.1"
staticd_options="  --daemon -A 127.0.0.1"
pbrd_options="  --daemon -A 127.0.0.1"
bfdd_options="  --daemon -A 127.0.0.1"
fabricd_options="  --daemon -A 127.0.0.1"
 
#MAX_FDS=1024
# The list of daemons to watch is automatically generated by the init script.
#watchfrr_options=""
 
# for debugging purposes, you can specify a "wrap" command to start instead
# of starting the daemon directly, e.g. to use valgrind on ospfd:
#   ospfd_wrap="/usr/bin/valgrind"
# or you can use "all_wrap" for all daemons, e.g. to use perf record:
#   all_wrap="/usr/bin/perf record --call-graph -"
# the normal daemon command is added to this at the end.                

此配置文件是 FRRouting 项目全局配置,需要把应用的功能修改为 =yes,根据各自情况配置,如上图所示。
启用 OSPF 路由功能

ospfd=yes

启用命令行配置功能

vtysh_enable=yes

重启FRRouting 服务

~# /etc/init.d/frr restart

Stopped watchfrr
Stopped staticd
Stopped vrrpd
Stopped eigrpd
Stopped pbrd
Stopped bfdd
Stopped ldpd
Stopped ripngd
Stopped ospf6d
Stopped ospfd
Stopped isisd
Stopped ripd
Stopped pimd
Stopped bgpd
Stopped zebra
Started watchfrr

第2步 配置 OSPF 参数

  • 配置 moon 路由器参数,如下。
1. 配置 ospf router
# vtysh
Hello, this is FRRouting (version 7.5).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
ixeCloud(config)# configure terminal
ixeCloud(config-if)# router ospf 100
ixeCloud(config-router)# ospf router-id 10.1.1.92
2. 配置 interface eth1
ixeCloud(config)# interface eth1
ixeCloud(config-if)# ip ospf 100 area 0
ixeCloud(config-if)# ip address 10.1.1.92/24
3. 宣告 eth0 为 ospf 100 域内接口
ixeCloud(config)# interface eth0
ixeCloud(config-if)# ip ospf 100 area 0
4. 保存参数
ixeCloud(config-if)# do write
Note: this version of vtysh never writes vtysh.conf
Building Configuration...
Integrated configuration saved to /etc/frr/frr.conf
[OK]
ixeCloud(config-if)# do write memory
Note: this version of vtysh never writes vtysh.conf
Building Configuration...
Integrated configuration saved to /etc/frr/frr.conf
[OK]
5. 检查 OSPF 邻居信息
root@ixeCloud:~# vtysh
ixeCloud# configure terminal
ixeCloud(config)# do show ip ospf neighbor 

OSPF Instance: 100
Neighbor ID     Pri State           Dead Time Address         Interface                        RXmtL RqstL DBsmL
10.1.1.10         1 Full/Backup       33.546s 10.1.1.10       eth1:10.1.1.92                       0     0     0
63.63.63.63       1 Full/DR           32.740s 10.1.1.63       eth1:10.1.1.92                       0     0     0
61.61.61.61       1 2-Way/DROther     32.968s 192.168.40.61   eth0:192.168.40.92                   0     0     0
63.63.63.63       1 Full/DR           32.968s 192.168.40.63   eth0:192.168.40.92                   0     0     0
67.67.67.67       1 2-Way/DROther     32.968s 192.168.40.67   eth0:192.168.40.92                   0     0     0
71.71.71.71       1 Full/Backup       30.325s 192.168.40.71   eth0:192.168.40.92                   0     0     0

# 此接口是本次实验 对端interface
10.2.2.94         1 2-Way/DROther     31.122s 192.168.40.94   eth0:192.168.40.92                   0     0     0 
  • 以同样的方式配置 路由器 sun 的参数,注意配置不同参数。

第3步 验证 OSPF 功能

功能验证。

1. 检查 OSPF 路由信息
ixeCloud(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

K>* 0.0.0.0/0 [0/0] via 192.168.40.1, eth0, src 192.168.40.92, 00:55:05
O[100]   10.1.1.0/24 [110/1] is directly connected, eth1, weight 1, 00:20:42
C>* 10.1.1.0/24 is directly connected, eth1, 00:20:57
O[100]>* 10.2.0.0/24 [110/2] via 10.1.1.10, eth1, weight 1, 00:20:42
O[100]>* 10.2.2.0/24 [110/2] via 192.168.40.94, eth0, weight 1, 00:16:55  # 宣告对端接口
O[100]>* 10.4.4.0/24 [110/2] via 192.168.40.67, eth0, weight 1, 00:19:05
O[100]>* 10.5.5.0/24 [110/2] via 192.168.40.71, eth0, weight 1, 00:19:05
O[100]   192.168.40.0/24 [110/1] is directly connected, eth0, weight 1, 00:19:05
C>* 192.168.40.0/24 is directly connected, eth0, 00:55:05
2. 检查网卡参数
root@ixeCloud:~# ifconfig
eth0      Link encap:Ethernet  HWaddr C6:FA:E9:BE:28:60  
          inet addr:192.168.40.92  Bcast:192.168.40.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11316 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2585 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1073205 (1.0 MiB)  TX bytes:314501 (307.1 KiB)
## ospf 接口
eth1      Link encap:Ethernet  HWaddr 82:51:7F:D9:A3:32  
          inet addr:10.1.1.92  Bcast:10.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::8051:7fff:fed9:a332/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2788 errors:0 dropped:0 overruns:0 frame:0
          TX packets:431 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:267105 (260.8 KiB)  TX bytes:67430 (65.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:438 errors:0 dropped:0 overruns:0 frame:0
          TX packets:438 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:30677 (29.9 KiB)  TX bytes:30677 (29.9 KiB)
3. moon 网关 ping 验证sun对端连通性
root@ixeCloud:~# ping 10.2.2.94
PING 10.2.2.94 (10.2.2.94) 56(84) bytes of data.
64 bytes from 10.2.2.94: icmp_req=1 ttl=64 time=0.113 ms
64 bytes from 10.2.2.94: icmp_req=2 ttl=64 time=0.248 ms
64 bytes from 10.2.2.94: icmp_req=3 ttl=64 time=0.206 ms
64 bytes from 10.2.2.94: icmp_req=4 ttl=64 time=0.209 ms
64 bytes from 10.2.2.94: icmp_req=5 ttl=64 time=0.176 ms
^C
--- 10.2.2.94 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4182ms
rtt min/avg/max/mdev = 0.113/0.190/0.248/0.046 ms
  • 2
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值