基于FRR全面解析BGP协议(八):FRR配置实例

FRR配置实例

环境:centos 7.6.1810

版本:FRR 7.3

服务器: 1台

Namespace配置实例

FRR的vrf功能支持同一个进程在不同ns内创建bgp对等体。首先需要配置zebra支持backend方式为ns

[root@k8s-master ~]# cat /usr/local/frr/etc/daemons |grep zebra
# The watchfrr and zebra daemons are always started.
zebra_options="  -A 127.0.0.1 -s 90000000 -n"
拓扑网络

我们在一台服务器上创建ns1和ns2,并创建veth pair分别绑定到ns1和ns2,使得两者的网络直连,然后使用vrf功能在ns1和ns2上创建对等体关系,并分别向对方通告虚拟路由。

1592299712230
网络设置
ip netns add ns1
ip netns add ns2
ip link add veth_ns2 type veth peer name veth_ns1
#去掉ARP限制
echo 1 > /proc/sys/net/ipv4/conf/veth_ns1/accept_local 
echo 1 > /proc/sys/net/ipv4/conf/veth_ns2/accept_local
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter 
echo 0 > /proc/sys/net/ipv4/conf/veth_ns2/rp_filter 
echo 0 > /proc/sys/net/ipv4/conf/veth_ns1/rp_filter 
ip link set veth_ns1 netns ns1
ip netns exec ns1 ip link set veth_ns1 up
ip netns exec ns1 ip addr add 10.10.1.2/24 dev veth_ns1
ip link set veth_ns2 netns ns2
ip netns exec ns2 ip link set veth_ns2 up
ip netns exec ns2 ip addr add 10.10.1.4/24 dev veth_ns2

测试网络连通性:

[root  ~]# ip netns exec ns1 ping 10.10.1.4
PING 10.10.1.4 (10.10.1.4) 56(84) bytes of data.
64 bytes from 10.10.1.4: icmp_seq=1 ttl=64 time=0.275 ms
64 bytes from 10.10.1.4: icmp_seq=2 ttl=64 time=0.091 ms
64 bytes from 10.10.1.4: icmp_seq=3 ttl=64 time=0.057 ms
64 bytes from 10.10.1.4: icmp_seq=4 ttl=64 time=0.093 ms
BGP设置
[root ]# cat /usr/local/frr/etc/bgpd.conf        
hostname bgpd
password zebra
router bgp 100 vrf ns1
 bgp router-id 10.10.1.2
 network 100.10.1.0/24
 neighbor 10.10.1.4 remote-as 200
 neighbor 10.10.1.4 ebgp-multihop
 address-family ipv4 unicast
 exit-address-family
router bgp 200 vrf ns2
 bgp router-id 10.10.1.4
 neighbor 10.10.1.2 remote-as 100
 neighbor 10.10.1.2 ebgp-multihop 255
 network 200.10.1.0/24
 address-family ipv4 unicast
 exit-address-family
debug bgp neighbor-events
debug bgp updates
debug bgp keepalives
debug bgp zebra
log file /usr/local/frr/var/log/bgpd.log
结果

vtysh查看当前状态show bgp vrf ns1 neighbors

[root ]# /usr/local/frr/bin/vtysh                

Hello, this is FRRouting (version 7.3).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

AS100# show bgp vrf ns1 neighbors 
BGP neighbor is 10.10.1.4, remote AS 200, local AS 100, external link
Hostname: bgpd
  BGP version 4, remote router ID 10.10.1.4, local router ID 10.10.1.2
  BGP state = Established, up for 00:05:17
......

vtysh查看当前状态show bgp vrf ns1 ipv4,可以看到AS200通告的路由200.10.1.0/24;

同样,show bgp vrf ns2 ipv4,可以看到AS100通告的路由200.10.1.0/24;

  • 5
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
根据提供的引用内容,我们可以了解到BGP是一种路由协议,而静态路由则是手动配置路由。因此,FRR BGP配置静态路由需要先配置静态路由,然后再将其与BGP协议结合起来。具体步骤如下: 1. 配置静态路由。可以使用以下命令配置静态路由: ```shell ip route add <destination_network>/<netmask> via <next_hop_ip_address> ``` 其中,`<destination_network>/<netmask>`表示目标网络和子网掩码,`<next_hop_ip_address>`表示下一跳IP地址。例如,要将目标网络`192.168.1.0/24`的流量发送到下一跳IP地址`10.0.0.1`,可以使用以下命令: ```shell ip route add 192.168.1.0/24 via 10.0.0.1 ``` 2. 配置BGP协议。可以使用以下命令配置BGP协议: ```shell router bgp <local_as_number> neighbor <neighbor_ip_address> remote-as <remote_as_number> network <local_network> ``` 其中,`<local_as_number>`表示本地AS号,`<neighbor_ip_address>`表示******本地网络设置为`192.168.1.0/24`,可以使用以下命令: ```shell router bgp 65001 neighbor 10.0.0.2 remote-as 65002 network 192.168.1.0/24 ``` 3. 将静态路由BGP协议结合起来。可以使用以下命令将静态路由BGP协议结合起来: ```shell router bgp <local_as_number> network <destination_network>/<netmask> route-map <route_map_name> out ``` 其中,`<destination_network>/<netmask>`表示目标网络和子网掩码,`<route_map_name>`表示路由映射名称。例如,要将目标网络`192.168.1.0/24`的流量发送到BGP邻居,可以使用以下命令: ```shell router bgp 65001 network 192.168.1.0/24 route-map static-to-bgp out ``` 在这个例子中,`static-to-bgp`是一个路由映射名称,它将静态路由转换为BGP路由

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

codemillion

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值