1 bird简介

bird实际是BIRD Internet Routing Daemon'的简称,它是在网络里跑着动态路由协议(支持IPV4 IPV6)的一种程序。相比较于其他的一些路由软件而言(routed (RIP only), GateD (non-free), Zebra and MRTD),bird的特性更多,配置更简便。

根据官方文档,bird支持特性如下:

  • both IPv4 and IPv6 protocols
  • multiple routing tables
  • the Border Gateway Protocol (BGPv4)
  • the Routing Information Protocol (RIPv2, RIPng)
  • the Open Shortest Path First protocol (OSPFv2, OSPFv3)
  • the Babel Routing Protocol
  • the Router Advertisements for IPv6 hosts
  • a virtual protocol for exchange of routes between different routing tables on a single host
  • a command-line interface allowing on-line control and inspection of status of the daemon
  • soft reconfiguration (no need to use complex online commands to change the configuration, just edit the configuration file and notify BIRD to re-read it and it will smoothly switch itself to the new configuration, not disturbing routing protocols unless they are affected by the configuration changes)
  • a powerful language for route filtering

bird1.*的版本在配置IPV4与IPV6时候是单独配置,bird2.*的版本在1.*版本基础之上又进行了进一步的扩展。

2 bird安装

官方文档给出的安装步骤如下:(需要提前安装相关依赖包、编译软件GNU development tools GCC, binutils, m4, make and Perl)

./configure
make
make install
vi /usr/local/etc/bird.conf
bird

实际安装过程如下,由于centos采用的是最小安装,所以需要装许多相关的依赖包:

先安装相关依赖包:

yum install -y make gcc* m4 flex* binutils bison ncurses* readline-devel git perl*
git init
tar -xvf bird-2.0.8.tar.gz
cd bird-2.0.8/
./configure --prefix=/usr/src
make && make install

由于源码安装时指定了安装路径是在/usr/src里,简便起见,做如下软链接以方便使用:

ln -s /usr/src/sbin/bird /usr/sbin/
ln -s /usr/src/sbin/birdc /usr/sbin/

3 bird配置

3.1 bird命令参数说明

[root@vm1 ~]# bird -h
Usage: bird [--version] [--help] [-c <config-file>] [OPTIONS]Options:-c <config-file>     Use given configuration file instead of /usr/src/etc/bird.conf #指定bird配置文件,默认是安装路径/etc/bird.conf-d                   Enable debug messages and run bird in foreground #在前端启动bird并使能debug信息-D <debug-file>      Log debug messages to given file instead of stderr #指定debug信息到指定的文件而不是标准错误输出stderr-f                   Run bird in foreground #在前端启动bird-g <group>           Use given group ID -h, --help           Display this information-l                   Look for a configuration file and a control socketin the current working directory-p                   Test configuration file and exit without start-P <pid-file>        Create a PID file with given filename-R                   Apply graceful restart recovery after start-s <control-socket>  Use given filename for a control socket-u <user>            Drop privileges and use given user ID--version            Display version of BIRD

通过bird,进行启动。下面通过例子来说bird.conf配置文件,这也是bird里主要会配置的文件。两台主机之间配置ospf p2p类型的ospf peer,并各自引入静态路由,设置ospf为一类外部路由并将metric值设置为10。

3.1.1 例1 ospf建立P2P邻居并引入所有静态路由(E1)

bird.conf文件如下:

log syslog all;
router id 10.10.1.10;
debug protocols all;
debug protocols { events, states };
protocol device {
}
protocol kernel {ipv4 {         # Connect protocol to IPv4 table by channelexport all;  # Export to protocol. default is export none};
}
protocol kernel {ipv6 { export all; };
}
protocol static {ipv4;          # Again, IPv4 channel with default optionsroute 10.20.0.0/24 via 172.20.0.1;
}
protocol ospf v2 {ipv4 {import all;export filter {if source = RTS_STATIC then {ospf_metric1 = 10;accept;}reject;};};area 0 {interface "enp0s9" {type pointopoint;       # Detected by defaultcost 1;                # Interface metrichello 3;      # Default hello perid 10 is too longdead 5;};};
}

另一侧:

[root@vm2 ~]# grep -v "^#" /usr/src/etc/bird.conf | grep -v "^$"
log syslog all;
router id 10.10.1.11;
debug protocols all;
debug protocols { events, states };
protocol device {
}
protocol kernel {ipv4 {         # Connect protocol to IPv4 table by channelexport all;  # Export to protocol. default is export none};
}
protocol kernel {ipv6 { export all; };
}
protocol static {ipv4;          # Again, IPv4 channel with default optionsroute 10.30.0.0/24 via 172.20.0.1;
}
protocol ospf v2 {ipv4 {import all;export filter {if source = RTS_STATIC then {ospf_metric1 = 10;accept;}reject;};};area 0 {interface "enp0s9" {type pointopoint;       # Detected by defaultcost 1;                # Interface metrichello 3;      # Default hello perid 10 is too longdead 5;};};
}

查看ospf邻居建立正常,路由学习正常:

此外,可以看一下birdc里命令行的相关命令:

bird> ?
quit                                           Quit the client
exit                                           Exit the client
help                                           Description of the help system
show ...                                       Show status information
dump ...                                       Dump debugging information
eval <expr>                                    Evaluate an expression
echo ...                                       Control echoing of log messages
disable (<protocol> | "<pattern>" | all) [message]  Disable protocol
enable (<protocol> | "<pattern>" | all) [message]  Enable protocol
restart (<protocol> | "<pattern>" | all) [message]  Restart protocol
reload <protocol> | "<pattern>" | all          Reload protocol
debug ...                                      Control protocol debugging via BIRD logs
mrtdump ...                                    Control protocol debugging via MRTdump files
restrict                                       Restrict current CLI session to safe commands
configure ...                                  Reload configuration
down                                           Shut the daemon down
graceful restart                               Shut the daemon down for graceful restart

3.1.2 在例1上优化引入路由

在host1上定义了2条路由,只引入其中一条/24路由,其他路由都不引入。

[root@vm1 ~]# grep -v "^$"  /usr/src/etc/bird.conf | grep -v "^#"
log syslog all;
router id 10.10.1.10;
debug protocols all;
debug protocols { events, states };
protocol device {
}
protocol kernel {ipv4 {         # Connect protocol to IPv4 table by channelexport all;  # Export to protocol. default is export none};
}
protocol kernel {ipv6 { export all; };
}
protocol static {ipv4;          # Again, IPv4 channel with default optionsroute 10.20.0.0/24 via 172.20.0.1;route 10.40.0.0/24 via 172.20.0.1;
}
function net_len_too_long(){case net.type {NET_IP4: return net.len > 24; # IPv4 CIDR 大于 /24 为太长else: print "net_len_too_long: unexpected net.type ", net.type, " ", net;return false;}
}
function ospf_export() {if net_len_too_long() then return false;if source != RTS_STATIC then return false;if net !~ [10.0.0.0/11{11,24}] then return false;return true;
}
protocol ospf v2 {ipv4 {import all;export filter {if !ospf_export() then reject;ospf_metric1 = 10;accept;};};area 0 {interface "enp0s9" {type pointopoint;       # Detected by defaultcost 1;                # Interface metrichello 3;      # Default hello perid 10 is too longdead 5;};};
}

在host2上进行路由信息查看:

3.2 bird日志信息打印

日常我们需要对网络内的ospf/bgp的邻居日志信息进行记录,因此需要在bird.conf文件里配置日志记录信息,有几种配置手段(1、在全局上配置;2、针对每个协议进行配置),但感觉全局配置就足够使用了。

[root@vm1 log]# grep -v "^$"  /usr/src/etc/bird.conf | grep -v "^#"
log "/var/log/bird.log" all;

测试一下ospf邻居震荡的情况:       

4 参考文献

官网:https://bird.network.cz/?get_doc&v=20&f=bird-6.html#ss6.8

https://blog.csdn.net/legend050709/article/details/109334949?utm_term=bird%E8%B7%AF%E7%94%B1&utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~sobaiduweb~default-2-109334949&spm=3001.4430

https://www.cnblogs.com/xkops/p/8048144.html

路由软件安装使用(一)(bird)相关推荐

  1. linux路由软件quagga安装

    介绍: quagga是继承于zebra的一款开源路由软件,支持多种协议: OSPF.RIP.OSPF6.BGP等. 软件介绍:http://www.nongnu.org/quagga/ 下载: 下载源 ...

  2. 开源路由软件zebra介绍和和在Linux环境下的安装

    感谢:http://www.cnblogs.com/iTsihang/archive/2012/11/22/2783249.html ================================= ...

  3. quagga 简介 开源路由软件

    quagga Quagga是一个开源的基于Zebra实现了RIP, OSPF, BGP的动态路由软件.它提供的CLI命令和Cisco IOS类似 ,可以使用 quagga 将linux 机器打造成一台 ...

  4. Quagga:开源的基于Zebra实现了RIP, OSPF, BGP的动态路由软件

    目录 quagga简介 特性 安装 quagga简介 https://www.jianshu.com/p/300acac7801f Quagga是一个开源的基于Zebra实现了RIP, OSPF, B ...

  5. 海蜘蛛软路由linux安装教程,软路由安装设置教程【详细步骤】-太平洋IT百科

    导读:随着 现代 生活中科学技术的不断发展,网络应用成为家家必须的东西,更因为如此也出现了如今的"低头族"们,不过在家庭中我们所使用的网络都需要有路由器这样的设备,其实路由器也分为 ...

  6. 【软件安装】vmware虚拟机安装完整教程(15.5版本)

     目录 一.基础介绍 二.准备工作(注意:如果自己下载不下来翻到最下面获取下载地址) 三.VMware下载与安装 VMware Workstation15.5新功能 注意: 一.基础介绍 VMware ...

  7. linux 入门 及一些常用命令及常用软件安装

    Linux入门: ------------------------------------------------------------------------- 1.Linux的安装方式:    ...

  8. 中华云盒M1刷Linux教程,N1 盒子刷最新版 armbian 及软件安装

    N1 盒子刷最新版 armbian 及软件安装 2019-12-22 16:02:10 79点赞 754收藏 71评论 写在前面 前段时间关注了#如何玩转NAS 后,玩性大发,各路值友们分享的好玩东西 ...

  9. SW2021软件安装教程

    SW2021软件安装教程 软件简介: SW是一款能够帮助用户轻松建立产品模型的3D建模软件,也是一款集3D设计软件.分析软件和产品数据管理等功能于一身的平台,用户通过它可以很快速的设计出所需要的产品: ...

最新文章

  1. 规范性分析是不是产生最优业务成果的处方?
  2. Struts2如何实现MVC,与Spring MVC有什么不同?
  3. metrics_将指标标签与MicroProfile Metrics 2.0结合使用
  4. Java多线程中的死锁问题
  5. /和//在python中使用
  6. Java面向对象(4) ——多态
  7. BZOJ1562: [NOI2009]变换序列(二分图 匈牙利)
  8. 今天,滴滴被爆亏损109亿,需裁员2000多人,哪些员工会被裁掉?
  9. java gc cms_Java垃圾收集器:G1GC何时将CMS强制退出?
  10. Error:Artifact com.*******:war exploded: java.nio.file.InvalidPathException: Illeg
  11. 一款不错的SpringCloud 脚手架项目
  12. java file.length 单位_Java.io.File.length()返回0
  13. 集成学习—决策树(CART)
  14. CSS Li点击有蓝色浮层
  15. PCI/PCIe硬件相关知识
  16. java开发微信抢红包挂_微信抢红包算法实现(JAVA)
  17. css锚点定位不准确问题
  18. 51单片机的LCD12864电子秤设计
  19. Python 入门 26 —— ASCII 编码、Unicode 编码、 UTF-32、 UTF-16、 UTF-8、 GB2312 编码、 GBK 编码
  20. Go实现自动回复的Tg bot机器人

热门文章

  1. AVPlayer(一)AVPlayerItem
  2. 嵌入式软件工程师和物联网工程师的区别
  3. 【清华大学】操作系统 陈渝——Part6 全局页面置换算法
  4. android note4 android版本,三星Note 4可升级Android 5.1.1:体验不如三星S6
  5. Typecho简单的BearSimple主题模板
  6. 青少年编程-Python画图“爱笑的眼睛机器人”第二幕
  7. 疫情下的区块链企业:11家公司共捐赠6000多万元,发动海外采购渠道
  8. javascript中内置对象promise知多少
  9. U8与MES对接,字段对接案例分享
  10. [Codewar练习-javac++]Twice linear(双线性)