Quagga
Quagga中文翻译斑驴,是一种先进的路由软件包,提供一套基于TCP/IP的路由协议。
– 使得操作系统变成专业的路由
– 使得操作系统具有与传统路由通过路由协议直接对接
– BGP
– OSPF
– RIP
– IS-IS
– MPLS
– LDP
– BFD
– PIM-SSM
– 传统路由以提供所有路由协议的过程程序的方式运行
– 斑驴由多个守护进程共同构建路由表的方式运行
+----+ +----+ +-----+ +-----+ |bgpd| |ripd| |ospfd| |zebra| +----+ +----+ +-----+ +-----+ | +---------------------------|--+ | v | | UNIX Kernel routing table | | | +------------------------------+ Quagga System Architecture
如上图所示:
– ripd,负责处理RIP协议
– ospfd,负责处理ospf v2协议
– bgpd,负责处理BGP v4协议
– zebra,作为内核路由表管理器
其他守护进程:
– ripngd
– ospf6d
– GNU/Linux
– FreeBSD
– NetBSD
– OpenBSD
另外,以下平台将来也可能支持
– Solaris
– Mac OSX
– GNU’s CCC
– LLVM’s clang
– Intel’s ICC
注:以上C库经过充分的测试
IP Address = 10.168.0.60
OS = RHEL 8.0 x86_64
yum -y install gcc gcc-c++ make expat-devel
cd ~ wget https://gogs.quagga.net/attachments/a6f5eb64-639a-49cf-964e-7aa196b9ac50 -O quagga-1.2.4.tar.gz
注:如果你需要下载其他版本,或以上链接无效,请参阅如下链接,
Releases · Quagga/quagga · GitHub
tar -xf quagga-1.2.4.tar.gz
cd ~/quagga-1.2.4/ ./configure --bindir=/usr/bin \ --sbindir=/usr/sbin \ --libexecdir=/usr/libexec \ --sysconfdir=/etc/quagga \ --localstatedir=/var/run/quagga \ --libdir=/usr/lib64 \ --includedir=/usr/include \ --datarootdir=/usr/share \ --infodir=/usr/share/info \ --localedir=/usr/share/locale \ --mandir=/usr/share/man \ --docdir=/usr/share/doc/quagga \ --enable-user=quagga \ --enable-group=quagga \ --enable-vty-group=quaggavt
参数“localstatedir”是必须设置为“/var/run/quagga”,否则配置ospf时会出现以下错误提示,
OSPF not enabled on this interface
如果看到如下错误提示,
configure: error: vtysh needs libreadline but was not found and usable on your system.
你可能需要安装如下依赖包,
yum install -y readline-devel
如果看到如下错误提示,
configure: error: Package requirements (libcares) were not met: Package 'libcares', required by 'virtual:world', not found
你可能需要安装如下依赖包,
yum install -y c-ares-devel
make make install
groupadd -g 85 quaggavt groupadd -g 92 quagga useradd -u 92 -g 92 -d /var/run/quagga/ -s /sbin/nologin quagga usermod -G quaggavt quagga
cp /etc/quagga/vtysh.conf.sample /etc/quagga/vtysh.conf cp /etc/quagga/zebra.conf.sample /etc/quagga/zebra.conf chown quagga:quagga /etc/quagga/ chown quagga:quagga /etc/quagga/*.conf chown quagga:quaggavt /etc/quagga/vtysh.conf chmod 640 /etc/quagga/*.conf
zebra -d -f /etc/quagga/zebra.conf -C
参数简介,
-d 参数声明zebra以damon的模式运行
-f 参数声明zebra配置文件的位置
-C 参数声明zebra以测试模式运行并退出(适合调试)
zebra -d -f /etc/quagga/zebra.conf -i /run/quagga/zebra.pid
参数简介,
-i 参数声明pid文件的位置
命令执行后,我们建议你使用如下命令确认运行正常,
pgrep -a zebra
如果你看到如下输出,则守护进程正常运行,
47962 zebra -d -f /etc/quagga/zebra.conf -i /run/quagga/zebra.pid
如果你需要手动退出进程,请使用如下命令,
kill 2 `pgrep zebra`
cp ~/quagga-1.2.4/redhat/*.service /usr/lib/systemd/system/ cp ~/quagga-1.2.4/redhat/quagga.sysconfig /etc/sysconfig/quagga
如果你需要外部主机可以管理zebra,我建议你修改如下配置
vim /etc/sysconfig/quagga
内容修改如下,
# # Default: Bind all daemon vtys to the loopback(s) only # BABELD_OPTS="-A 127.0.0.1" BGPD_OPTS="-A 127.0.0.1" ISISD_OPTS="-A ::1" OSPF6D_OPTS="-A ::1" OSPFD_OPTS="-A 127.0.0.1" RIPD_OPTS="-A 127.0.0.1" RIPNGD_OPTS="-A ::1" # ZEBRA_OPTS="-A 127.0.0.1" ZEBRA_OPTS="-A 0.0.0.0" PIMD_OPTS="-A 127.0.0.1" # Watchquagga configuration for LSB initscripts # # (Not needed with systemd: the service files are configured to automatically # restart any daemon on failure. If zebra fails, all running daemons will be # stopped; zebra will be started again; and then the previously running daemons # will be started again.) # # Uncomment and edit this line to reflect the daemons you are actually using: #WATCH_DAEMONS="zebra bgpd ospfd ospf6d ripd ripngd" # # Timer values can be adjusting by editing this line: WATCH_OPTS="-Az -b_ -r/sbin/service_%s_restart -s/sbin/service_%s_start -k/sbin/service_%s_stop"
由于官方提供的启动脚本执行会报错,我们建议你使用如下命令修改,
vim /usr/lib/systemd/system/zebra.service
脚本修改如下,
[Unit] Description=GNU Zebra routing manager Wants=network.target Before=network.target After=network-pre.target ConditionPathExists=/etc/quagga/zebra.conf Documentation=man:zebra [Service] Type=forking EnvironmentFile=-/etc/sysconfig/quagga ExecStartPre=/sbin/ip route flush proto zebra ExecStartPre=-/usr/bin/mkdir -p /run/quagga ExecStartPre=-/bin/chown -f quagga:quagga /run/quagga /etc/quagga/zebra.conf ExecStartPre=-/bin/chown -f quagga:quaggavt /etc/quagga/vtysh.conf ExecStartPre=-/bin/chmod -f 640 /etc/quagga/zebra.conf /etc/quagga/vtysh.conf ExecStart=/usr/sbin/zebra -d $ZEBRA_OPTS -f /etc/quagga/zebra.conf -i /run/quagga/zebra.pid Restart=on-abort [Install] WantedBy=multi-user.target
修改完毕后,你需要重新载入脚本,
systemctl daemon-reload
systemctl start zebra.service systemctl stop zebra.service systemctl restart zebra.service systemctl status zebra.service
systemctl enable zebra.service
cp /etc/quagga/ospfd.conf.sample /etc/quagga/ospfd.conf chown quagga:quagga /etc/quagga/ chown quagga:quagga /etc/quagga/*.conf chown quagga:quaggavt /etc/quagga/vtysh.conf chmod 640 /etc/quagga/*.conf
ospfd -d -f /etc/quagga/zebra.conf -C
参数简介,
-d 参数声明zebra以damon的模式运行
-f 参数声明zebra配置文件的位置
-C 参数声明zebra以测试模式运行并退出(适合调试)
ospfd -d -f /etc/quagga/ospfd.conf -i /run/quagga/ospfd.pid
参数简介,
-i 参数声明pid文件的位置
命令执行后,我们建议你使用如下命令确认运行正常,
pgrep -a ospfd
如果你看到如下输出,则守护进程正常运行,
51600 ospfd -d -f /etc/quagga/ospfd.conf -i /run/quagga/ospfd.pid
如果你需要手动退出进程,请使用如下命令,
kill 2 `pgrep ospfd`
vim /etc/sysconfig/quagga
内容修改如下,
# # Default: Bind all daemon vtys to the loopback(s) only # BABELD_OPTS="-A 127.0.0.1" BGPD_OPTS="-A 127.0.0.1" ISISD_OPTS="-A ::1" OSPF6D_OPTS="-A ::1" # OSPFD_OPTS="-A 127.0.0.1" OSPFD_OPTS="-A 0.0.0.0" RIPD_OPTS="-A 127.0.0.1" RIPNGD_OPTS="-A ::1" # ZEBRA_OPTS="-A 127.0.0.1" ZEBRA_OPTS="-A 0.0.0.0" PIMD_OPTS="-A 127.0.0.1" # Watchquagga configuration for LSB initscripts # # (Not needed with systemd: the service files are configured to automatically # restart any daemon on failure. If zebra fails, all running daemons will be # stopped; zebra will be started again; and then the previously running daemons # will be started again.) # # Uncomment and edit this line to reflect the daemons you are actually using: #WATCH_DAEMONS="zebra bgpd ospfd ospf6d ripd ripngd" # # Timer values can be adjusting by editing this line: WATCH_OPTS="-Az -b_ -r/sbin/service_%s_restart -s/sbin/service_%s_start -k/sbin/service_%s_stop"
由于官方提供的启动脚本执行会报错,我们建议你使用如下命令修改,
vim /usr/lib/systemd/system/ospfd.service
脚本修改如下,
[Unit] Description=OSPF routing daemon BindsTo=zebra.service Wants=network.target After=zebra.service network-pre.target Before=network.target ConditionPathExists=/etc/quagga/ospfd.conf Documentation=man:ospfd [Service] Type=forking EnvironmentFile=/etc/sysconfig/quagga ExecStartPre=-/bin/chown -f quagga:quagga /etc/quagga/ospfd.conf ExecStartPre=-/bin/chmod -f 640 /etc/quagga/ospfd.conf ExecStart=/usr/sbin/ospfd -d $OSPFD_OPTS -f /etc/quagga/ospfd.conf -i /run/quagga/ospfd.pid Restart=on-abort [Install] WantedBy=multi-user.target
修改完毕后,你需要重新载入脚本,
systemctl daemon-reload
systemctl start ospfd.service systemctl stop ospfd.service systemctl restart ospfd.service systemctl status ospfd.service
systemctl enable ospfd.service
netstat -anp | egrep "ospfd|zebra"
可见如下输出,
tcp 0 0 0.0.0.0:2601 0.0.0.0:* LISTEN 2746/zebra tcp 0 0 0.0.0.0:2604 0.0.0.0:* LISTEN 2753/ospfd raw 0 0 0.0.0.0:89 0.0.0.0:* LISTEN 2753/ospfd raw6 0 0 :::58 :::* 7 2746/zebra
注:ospfd进程的89端口可能要等路由发布才能看到
egrep "89|58" /etc/protocols
可见如下信息,
ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 ospf 89 OSPFIGP # Open Shortest Path First IGP
由于89与58端口不是IP协议是一种socket的类型,所以使用允许协议的方式配置,
firewall-cmd --permanent --add-protocol=ospf firewall-cmd --permanent --add-protocol=ipv6-icmp firewall-cmd --reload firewall-cmd --list-all
另外两个管理端口使用如下命令配置,
firewall-cmd --permanent --add-port 2601/tcp firewall-cmd --permanent --add-port 2604/tcp firewall-cmd --reload firewall-cmd --list-all
如果你不熟悉路由的基本配置,请参阅以下链接的2.3章节,
如何实现基于Linux的路由之Quagga? – cmdSchool
参阅文档
===============
Quagga github
—————-
GitHub - Quagga/quagga: Quagga Tracking repository - Master is at http://git.savannah.gnu.org/cgit/quagga.git
Quagga的下载,
Releases · Quagga/quagga · GitHub
https://gogs.quagga.net/Quagga/quagga/releases
rpm包的构建
—————–
https://github.com/Quagga/quagga/blob/master/redhat/README.rpm_build.md
错误“OSPF not enabled on this interface”的解决方法,
———————–
https://lists.quagga.net/pipermail/quagga-users/2006-April/006715.html
https://lists.quagga.net/pipermail/quagga-users/2006-April/006709.html
Mailing List Archive: OSPF not enabled on this interface