linux7打开ospf,Centos下的 Quagga 路由配置:开局、OSPF和BGP

Quagga开局

我们使用yum安装Quagga。# yum install quagga

在CentOS7,SELinux默认会阻止quagga将配置文件写到/usr/sbin/zebra。这个SELinux策略会干扰我们接下来要介绍的安装过程,所以我们要禁用此策略。对于这一点,无论是关闭SELinux(这里不推荐),还是如下启用“zebrawriteconfig”都可以。如果你使用的是CentOS 6的请跳过此步骤。# setsebool -P zebra_write_config 1

安装完Quagga后,我们要配置必要的对等IP地址,并更新OSPF设置。Quagga自带了一个命令行称为vtysh。vtysh里面用到的Quagga命令与主要的路由器厂商如思科和Juniper是相似的。

步骤 1: 配置 Zebra

我们首先创建Zebra配置文件,并启用Zebra守护进程。# cp /usr/share/doc/quagga-XXXXX/zebra.conf.sample /etc/quagga/zebra.conf

# service zebra start

# chkconfig zebra on

启动vtysh命令行:# vtysh

首先,我们为Zebra配置日志文件。输入下面的命令进入vtysh的全局配置模式:site-A-RTR# configure terminal

指定日志文件位置,接着退出模式:site-A-RTR(config)# log file /var/log/quagga/quagga.log

site-A-RTR(config)# exit

永久保存配置:site-A-RTR# write

接下来,我们要确定可用的接口并按需配置它们的IP地址。site-A-RTR# show interface

Interface eth0 is up, line protocol detection is disabled

. . . . .

Interface eth1 is up, line protocol detection is disabled

. . . . .

配置eth0参数:

site-A-RTR# configure terminal

site-A-RTR(config)# interface eth0

site-A-RTR(config-if)# ip address 10.10.10.1/30

site-A-RTR(config-if)# description to-site-B

site-A-RTR(config-if)# no shutdown

site-A-RTR(config-if)# do show interface description

Interface Status Protocol Description

eth0 up unknown to-site-B

eth1 up unknown to-site-A-LAN

永久保存配置:

site-A-RTR(config-if)# do write

在site-B上重复上面配置IP地址的步骤。

如果一切顺利,你应该可以在site-A的服务器上ping通site-B上的对等IP地址10.10.10.2了。

注意:一旦Zebra的守护进程启动了,在vtysh命令行中的任何改变都会立即生效。因此没有必要在更改配置后重启Zebra守护进程。

注意:防火墙应当放通OSPF协议 centos 执行: firewall-cmd --add-protocol=89 --permanent

firewall-cmd --add-masquerade --permanent

很多写教程都不写全,不加--permanent重启没用

步骤 2: 配置OSPF

我们首先创建OSPF配置文件,并启动OSPF守护进程:# cp /usr/share/doc/quagga-XXXXX/ospfd.conf.sample /etc/quagga/ospfd.conf

# service ospfd start

# chkconfig ospfd on

现在启动vtysh命令行来继续OSPF配置:

vtysh

输入路由配置模式:site-A-RTR# configure terminal

site-A-RTR(config)# router ospf

可选配置路由id:site-A-RTR(config-router)# router-id 10.10.10.1

添加在OSPF中的网络:site-A-RTR(config-router)# network 10.10.10.0/30 area 0

site-A-RTR(config-router)# network 192.168.1.0/24 area 0

永久保存配置:

site-A-RTR(config-router)# do write

在site-B上重复和上面相似的OSPF配置:site-B-RTR(config-router)# network 10.10.10.0/30 area 0

site-B-RTR(config-router)# network 172.16.1.0/24 area 0

site-B-RTR(config-router)# do write

OSPF的邻居现在应该启动了。只要ospfd在运行,通过vtysh的任何OSPF相关配置的改变都会立即生效而不必重启ospfd。

配置BGP部分

添加一个lo接口:

[root@gfs02 quagga-0.99.22.4]# cd /etc/sysconfig/network-scripts/

[root@gfs02 network-scripts]# cp ifcfg-lo ifcfg-lo:1

[root@gfs02 network-scripts]# vi ifcfg-lo:1

DEVICE=lo:1

IPADDR=200.200.1.1

NETMASK=255.255.255.0

If you're having problems with gated making 127.0.0.0/8 a martian,

you can change this to something else (255.255.255.255, for example)

ONBOOT=yes

NAME=loopback1

重启网络

[root@gfs02 network-scripts]# systemctl restart network

检查

[root@gfs02 network-scripts]# ifconfig -a

ens33: flags=4163  mtu 1500

inet 10.45.11.119  netmask 255.255.254.0  broadcast 10.45.11.255

inet6 fe80::11aa:9ac6:ff72:adb0  prefixlen 64  scopeid 0x20

ether 00:0c:29:a1:11:5e  txqueuelen 1000  (Ethernet)

RX packets 746441  bytes 404706532 (385.9 MiB)

RX errors 0  dropped 34  overruns 0  frame 0

TX packets 87385  bytes 7583699 (7.2 MiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536

inet 127.0.0.1  netmask 255.0.0.0

inet6 ::1  prefixlen 128  scopeid 0x10

loop  txqueuelen 1000  (Local Loopback)

RX packets 95719  bytes 7866600 (7.5 MiB)

RX errors 0  dropped 0  overruns 0  frame 0

TX packets 95719  bytes 7866600 (7.5 MiB)

TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo:1: flags=73  mtu 65536

inet 200.200.1.1  netmask 255.255.255.0

loop  txqueuelen 1000  (Local Loopback)

在我们继续下一步之前,确认下彼此的IP是可以ping通的。

gfs01# ping 10.45.11.119

PING 10.45.11.119 (10.45.11.119) 56(84) bytes of data.

64 bytes from 10.45.11.119: icmp_seq=1 ttl=64 time=0.420 ms

64 bytes from 10.45.11.119: icmp_seq=2 ttl=64 time=0.274 ms

下一步,我们将继续配置BGP对等和前缀设置。

6、配置bgp对等

Quagga守护进程负责BGP的服务叫bgpd。首先我们来准备它的配置文件。

cp /usr/share/doc/quagga-0.99.22.4/bgpd.conf.sample /etc/quagga/bgpd.conf

启动bgpd进程:

[root@gfs02 quagga-0.99.22.4]# systemctl start bgpd

[root@gfs02 quagga-0.99.22.4]# systemctl enable bgpd

确保没有报错。可以通过下面命令检查状态。

systemctl status bgpd

现在,让我们来进入Quagga 的shell。

[root@gfs02 quagga-0.99.22.4]# vtysh

第一步,我们要确认当前没有已经配置的BGP会话。在一些版本,我们可能会发现一个AS号为7675的BGP会话。由于我们不需要这个会话,所以把它移除。

gfs02# conf t

gfs02(config)# no router bgp 7675

gfs02(config)# router bgp 200

gfs02(config-router)# no auto-summary

gfs02(config-router)# no synchronization

gfs02(config-router)# neighbor  10.45.11.118 remote-as  100

gfs02(config-router)# neighbor  10.45.11.118 description  "provider A"

gfs02(config-router)# exit

gfs02(config)# exit

gfs02# write

路由器B将用同样的方式来进行配置,以下配置提供作为参考。

gfs01# configure terminal

gfs01(config)# no router bgp 7675

gfs01(config)# router bgp 100

gfs01(config-router)# no auto-summary

gfs01(config-router)# no synchronization

gfs01(config-router)# neighbor  10.45.11.119 remote-as 200

gfs01(config-router)# neighbor  10.45.11.119 description "provider B"

gfs01(config-router)# exit

gfs01(config)# exit

neighbor HK_147 prefix-list hnust in

————————————————

参考文章:

《使用CentOS7.4搭建bgp网络实验Quagga》

原文链接:https://blog.csdn.net/kadwf123/article/details/96838805

《想玩路由器吗?使用 Quagga 将你的 CentOS 变成 OSPF 路由器》

原文链接:https://linux.cn/article-4232-1.html

本文由 wyf 创作,采用 知识共享署名4.0 国际许可协议进行许可

本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名

最后编辑时间为: Mar 26, 2020 at 02:53 pm

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值