配置路由实验

1. 安装VMWare虚拟机

分别安装6台虚拟机,命名为:route_1, route_2, route_3, route_A, route_B, route_C
本次实验,使用的Ubuntu 1604镜像以及quagga-1.2.1

2. 配置如图所示的拓扑

整体网络拓扑链接如下图所示
路由实验--quagga
在以上的每一台机器,都需要添加网卡,配置静态IP,安装quagga路由程序,我们以route_A为例介绍其中的具体流程,其他的机器类似。

2.1. 添加网卡

VMWare 提供三种网络:

  • 桥接:直接连接到物理网络,对应的虚拟机网卡使用的是和主机正常上网的同一段IP
  • NAT:通过地址转换方式,构造属于虚拟机自己的独立网段(主机能和虚拟机直接通信)
  • LAN(虚拟网络):搭建属于虚拟机自己的网段(主机不可和虚拟机直接通信)
  • VMNet(虚拟网络):可以实现以上各种网络模型的自定义配置。
    这里,我们选用LAN网段,实现域间路由的网络搭建。

路由实验--quagga

2.2. 配置静态IP

选择LAN网段意味着,我们需要自己管理网络地址,因此,我们需要配置静态的IP,具体方法如下:
修改配置文件:/etc/network/interfaces
如图所示:
路由实验--quagga
注意:对于强迫症患者,很难接受网卡奇奇怪怪的命令方式,因此你可以通过修改文件/etc/default/grub如下图所示,来是的网卡编号为ethxxx格式
路由实验--quagga
然后执行:update-grub重启就好了。

2.3. 测试网络的连通性

通过简单的ping命令即可,如图所示
路由实验--quagga

2.4. 开启IPv4转发功能

修改/etc/sysctl.conf如下图所示
路由实验--quagga
然后执行:sysctl -p /etc/sysctl.conf就可以了。

3. 安装路由软件(quagga)

3.1 安装依赖环境

3.1.1.下载源码

# http://download.savannah.gnu.org/releases/quagga/
wget http://download.savannah.gnu.org/releases/quagga/quagga-1.2.1.tar.gz
tar -zxvf quagga-1.2.1.tar.gz
cd PATH-TO_QUAGGA

3.1.2. 安装依赖

sudo apt-get install gawk texinfo libreadline-dev -y

3.1.3. 配置和编译源码

cd PATH-TO-QUAGGA
./configure --enable-vtysh --enable-user=root --enable-group=root 
\--enable-vty-group=root [--enable-bgpd --enable-ospfd --enable-ripd]

如果出现PKG-CONFIG问题,使用下述方法修复。

3.1.4. 修复PKG-CONFIG

#download c-ares-X.XX.X.tar.gz from https://c-ares.haxx.se/
wget https://c-ares.haxx.se/download/c-ares-1.15.0.tar.gz
tar -zxvf c-ares-1.15.0.tar.gz
#cd PATH-TO-C_ARES
./configure
make 
make install
cp libcares.pc  /usr/lib/pkgconfig/

3.2. 编译和安装quagga源码

3.2.1. 编译

cd PATH-TO-QUAGGA
./configure --enable-vtysh --enable-user=root --enable-group=root \
--enable-vty-group=root --enable-bgpd
make 
sudo make install

3.2.2. 安装

(由于configure没有指定安装路径,因此默认安装/usr/local/XXX),我们需要将库文件链接到能够识别的路径中去

sudo updatedb
locate libzebra.so.1
sudo ln -s /usr/local/lib/libzebra.so /lib/libzebra.so
sudo ln -s /usr/local/lib/libzebra.so.1 /lib/libzebra.so.1

3.3. 启用IP forwarding

执行命令:

cat /proc/sys/net/ipv4/ip_forward

确保输出为1,则可以了。否则,重新开启IP_forwarding(2.4)

3.4. 启用zebra

cd /usr/local/etc
cp zebra.conf.sample zebra.conf
sudo zebra -d
telnet localhost 2601 #或者vtysh

4. 配置路由协议(以BGP为例说明)

4.1. 启用路由系统(BGP)

cd /usr/local/etc
cp bgpd.conf.sample bgpd.conf
zebra -d
bgpd -d
vtysh ##or telnet localhost zebra/bgpd

4.2. 配置IP和网卡

具体参考 https://linux.cn/article-4609-1.html

参考资料

quagga - vrf 代码流程图:https://wenku.baidu.com/view/2f7a66c8f111f18582d05ac7.html
如何使用Quagga把一个Linux系统变成一个BGP路由器: https://linux.cn/article-4609-1.html
如何使用 Quagga BGP(边界网关协议)路由器来过滤 BGP 路由:https://linux.cn/article-6468-1.html
https://schd.ws/hosted_files/ossna2017/fe/vrf-tutorial-oss.pdf
https://github.com/FRRouting/frr/issues/385
http://www.routereflector.com/2016/11/working-with-vrf-on-linux/
https://linux.cn/article-6468-1.html
https://blog.51cto.com/momentsli/2135742
vrf https://blog.csdn.net/dog250/article/details/78069964

相关文章:

  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2021-12-05
  • 2021-06-29
  • 2021-06-13
  • 2022-01-17
猜你喜欢
  • 2021-12-10
  • 2022-03-04
  • 2021-11-15
  • 2021-11-30
  • 2022-02-26
  • 2021-07-28
  • 2021-07-18
相关资源
相似解决方案