使用Quagga测试IPv4/IPv6 BGP双栈动态路由(by quqi99)

作者:张华  发表于:2016-07-04
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

( http://blog.csdn.net/quqi99 )


测试环境 

测试环境依然用上次测STT的两台物理机, 已有的网络环境如下:


node1, duduo.seg, 

  • eth0: 10.230.56.14,   1000Mb/s,  br-ex
  • eth6: 10.230.56.15,  10000Mb/s, out-off-band management
  • eth7: 192.168.122.2, 10000Mb/s, br-phy
sudo ovs-vsctl -- --may-exist add-br br-ex
sudo ovs-vsctl -- --may-exist add-port br-ex eth0
sudo ifconfig eth0 0.0.0.0 up
sudo ifconfig br-ex 10.230.56.233/21
sudo ovs-vsctl -- --may-exist add-br br-phy
sudo ovs-vsctl -- --may-exist add-port br-phy eth7
sudo ifconfig eth7 0.0.0.0 up
sudo ifconfig br-phy 192.168.122.2/24

node2, voltorb.seg,
  • eth0: 10.230.56.21,   1000Mb/s, out-off-band management
  • eth4: 192.168.122.3, 10000Mb/s, br-phy
sudo ovs-vsctl -- --may-exist add-br br-phy
sudo ovs-vsctl -- --may-exist add-port br-phy eth4
sudo ifconfig eth4 0.0.0.0 up
sudo ifconfig br-phy 192.168.122.3/24

这次BGP实验规划的新增的网络环境如下:
-------------------------------       -------------------------------
|   eth6: 10.230.56.15/21     |-------|   eth0: 10.230.56.21/21     |
|   eth6: 2001:db8:3::1/64    |       |   eth0: 2001:db8:3::2/64    |
|     AS: 100                 |       |     AS: 200                 |
| br-phy: 2001:db8:1::1/64    |-------| br-phy: 2001:db8:2::1/64    |       
| br-phy: 192.168.1.1/24      |       | br-phy: 192.168.2.1/24      |
-------------------------------       -------------------------------
sudo ip addr add 2001:db8:3::1/64 dev eth6
sudo ip addr add 2001:db8:1::1/64 dev br-phy
sudo ip addr add 192.168.1.1/24 dev br-phy

sudo ip addr add 2001:db8:3::2/64 dev eth0
sudo ip addr add 2001:db8:2::1/64 dev br-phy
sudo ip addr add 192.168.2.1/24 dev br-phy

Quagga安装及防火墙配置

sudo apt-get install quagga 
sudo chown quagga.quaggavty /etc/quagga/*.conf
sudo chmod 640 /etc/quagga/*.conf

echo "net.ipv4.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf 
echo "net.ipv4.conf.default.forwarding=1" | sudo tee -a /etc/sysctl.conf 
sed 's/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=1/g' /etc/sysctl.conf | sudo tee /etc/sysctl.conf
echo "net.ipv6.conf.default.forwarding=1" | sudo tee -a /etc/sysctl.conf 
sudo sysctl -p
sudo ip6tables -F

# BGP sessions
sudo iptables -A INPUT -p tcp --dport 179 -j ACCEPT
sudo iptables -A INPUT -p tcp --sport 179 -j ACCEPT
# Telnet session to zebra
sudo iptables -A INPUT -p tcp --dport 2601 -j ACCEPT
# Telnet session to quagga/bgpd
sudo iptables -A INPUT -p tcp --dport 2605 -j ACCEPT

Quagga配置文件

1, 两节点上的配置文件 /etc/quagga/zebra.conf
sudo cp /usr/share/doc/quagga/examples/zebra.conf.sample /etc/quagga/zebra.conf
ubuntu@duduo:~$ sudo cat /etc/quagga/zebra.conf
hostname duduo         #另一台节点修改为voltorb
password zebra
enable password zebra
log file /var/log/quagga/zebra.log

1, 两节点上的配置文件 /etc/quagga/daemons
ubuntu@duduo:~$ sudo cat /etc/quagga/daemons 
zebra=yes
bgpd=yes

ospfd=no
ospf6d=no
ripd=no
ripngd=no
isisd=no
babeld=no

3, 两节点上的配置文件 /etc/quagga/bgpd.conf如下:
ubuntu@duduo:~$ sudo cat /etc/quagga/bgpd.conf 
hostname duduo
password zebra
log file /var/log/quagga/bgpd.log
log stdout
!
router bgp 100 
no synchronization 
bgp router-id 10.230.56.15
network 192.168.1.0/24
neighbor 10.230.56.21 remote-as 200
neighbor 10.230.56.21 description test-v4
neighbor 2001:db8:3::2 remote-as 200
neighbor 2001:db8:3::2 description test-v6
no auto-summary
no neighbor 2001:db8:3::2 activate
!
address-family ipv6
network 2001:db8:1::/48
network 2001:db8:1::/56
network 2001:db8:1::/64
neighbor 2001:db8:3::2 activate
neighbor 2001:db8:3::2 route-map IPV6-OUT out
exit-address-family
!
ipv6 prefix-list pl-ipv6 seq 10 permit 2001:db8:1::/56 le 64
route-map IPV6-OUT permit 10
match ipv6 address prefix-list pl-ipv6
set ipv6 next-hop global 2001:db8:3::1
!
line vty
!
debug bgp events
debug bgp filters
!debug bgp fsm
!debug bgp keepalives
debug bgp updates

ubuntu@voltorb:~$ sudo cat /etc/quagga/bgpd.conf
hostname voltorb
password zebra
log file /var/log/quagga/bgpd.log
log stdout
!
router bgp 200
no synchronization
bgp router-id 10.230.56.21
network 192.168.2.0/24
neighbor 10.230.56.15 remote-as 100
neighbor 10.230.56.15 description test-v4
neighbor 2001:db8:3::1 remote-as 100
neighbor 2001:db8:3::1 description test-v6
no auto-summary
no neighbor 2001:db8:3::1 activate
!
address-family ipv6
network 2001:db8:2::/48
network 2001:db8:2::/56
network 2001:db8:2::/64
neighbor 2001:db8:3::1 activate
neighbor 2001:db8:3::1 route-map IPV6-OUT out
exit-address-family
!
ipv6 prefix-list pl-ipv6 seq 10 permit 2001:db8:2::/56 le 64
route-map IPV6-OUT permit 10
match ipv6 address prefix-list pl-ipv6
set ipv6 next-hop global 2001:db8:3::2
!
line vty
!
debug bgp events
debug bgp filters
!debug bgp fsm
!debug bgp keepalives
debug bgp updates


验证结果

两节点上重启quagga进程(sudo service quagga restart)后观察到的邻居信息如下:

ubuntu@duduo:~$ sudo vtysh

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

duduo# show bgp summary
BGP router identifier 10.230.56.15, local AS number 100
RIB entries 6, using 672 bytes of memory
Peers 2, using 9120 bytes of memory

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2001:db8:3::2   4   200      10      11        0    0    0 00:06:30        2

Total number of neighbors 1


ubuntu@voltorb:~$ sudo vtysh

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

voltorb# show bgp summary
BGP router identifier 10.230.56.21, local AS number 200
RIB entries 6, using 672 bytes of memory
Peers 2, using 9120 bytes of memory

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2001:db8:3::1   4   100      11      14        0    0    0 00:08:22        2

Total number of neighbors 1


两节点观察到的日志分别如下:

2016/07/04 09:29:46 BGP: BGPd 0.99.22.4 starting: vty@2605, bgp@<all>:179
2016/07/04 09:29:46 BGP: Import timer expired.
2016/07/04 09:29:49 BGP: [Event] BGP connection from host 2001:db8:3::2
2016/07/04 09:29:49 BGP: [Event] BGP connection IP address 2001:db8:3::2 is Idle state
2016/07/04 09:29:50 BGP: 2001:db8:3::2 [Event] Connect start to 2001:db8:3::2 fd 13
2016/07/04 09:29:51 BGP: 2001:db8:3::2 send UPDATE 2001:db8:1::/56
2016/07/04 09:29:51 BGP: 2001:db8:3::2 send UPDATE 2001:db8:1::/64
2016/07/04 09:29:51 BGP: 2001:db8:3::2 rcvd UPDATE w/ attr: , origin i, mp_nexthop 2001:db8:3::2(fe80::3ea8:2aff:fe21:9908), metric 0, path 200
2016/07/04 09:29:51 BGP: 2001:db8:3::2 rcvd 2001:db8:2::/56
2016/07/04 09:29:51 BGP: 2001:db8:3::2 rcvd UPDATE w/ attr: , origin i, mp_nexthop 2001:db8:3::2(fe80::3ea8:2aff:fe21:9908), metric 0, path 200
2016/07/04 09:29:51 BGP: 2001:db8:3::2 rcvd 2001:db8:2::/64
2016/07/04 09:29:53 BGP: 10.230.56.21 [Event] Connect start to 10.230.56.21 fd 14
2016/07/04 09:29:54 BGP: 10.230.56.21 send UPDATE 192.168.1.0/24
2016/07/04 09:29:54 BGP: 10.230.56.21 rcvd UPDATE w/ attr: nexthop 10.230.56.21, origin i, metric 0, path 200
2016/07/04 09:29:54 BGP: 10.230.56.21 rcvd 192.168.2.0/24


2016/07/04 09:29:11 BGP: 2001:db8:3::1 [Event] Connect start to 2001:db8:3::1 fd 13
2016/07/04 09:29:11 BGP: stream_read_try: read failed on fd 13: Connection reset by peer
2016/07/04 09:29:11 BGP: 2001:db8:3::1 [Error] bgp_read_packet error: Connection reset by peer
2016/07/04 09:29:12 BGP: [Event] BGP connection from host 2001:db8:3::1
2016/07/04 09:29:12 BGP: [Event] Make dummy peer structure until read Open packet
2016/07/04 09:29:12 BGP: 2001:db8:3::1 [Event] Transfer accept BGP peer to real (state Active)
2016/07/04 09:29:12 BGP: 2001:db8:3::1 [Event] Accepting BGP peer delete
2016/07/04 09:29:13 BGP: 2001:db8:3::1 send UPDATE 2001:db8:2::/56
2016/07/04 09:29:13 BGP: 2001:db8:3::1 send UPDATE 2001:db8:2::/64
2016/07/04 09:29:13 BGP: 2001:db8:3::1 rcvd UPDATE w/ attr: , origin i, mp_nexthop 2001:db8:3::1(fe80::8edc:d4ff:feb3:9c3c), metric 0, path 100
2016/07/04 09:29:13 BGP: 2001:db8:3::1 rcvd 2001:db8:1::/56
2016/07/04 09:29:13 BGP: 2001:db8:3::1 rcvd UPDATE w/ attr: , origin i, mp_nexthop 2001:db8:3::1(fe80::8edc:d4ff:feb3:9c3c), metric 0, path 100
2016/07/04 09:29:13 BGP: 2001:db8:3::1 rcvd 2001:db8:1::/64
2016/07/04 09:29:15 BGP: [Event] BGP connection from host 10.230.56.15
2016/07/04 09:29:15 BGP: [Event] Make dummy peer structure until read Open packet
2016/07/04 09:29:15 BGP: 10.230.56.15 [Event] Transfer accept BGP peer to real (state Active)
2016/07/04 09:29:15 BGP: 10.230.56.15 [Event] Accepting BGP peer delete
2016/07/04 09:29:16 BGP: 10.230.56.15 send UPDATE 192.168.2.0/24
2016/07/04 09:29:16 BGP: 10.230.56.15 rcvd UPDATE w/ attr: nexthop 10.230.56.15, origin i, metric 0, path 100
2016/07/04 09:29:16 BGP: 10.230.56.15 rcvd 192.168.1.0/24

路由变化如下:

ubuntu@duduo:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.230.56.1     0.0.0.0         UG    0      0        0 eth6
10.230.56.0     0.0.0.0         255.255.248.0   U     0      0        0 eth6
10.230.56.0     0.0.0.0         255.255.248.0   U     0      0        0 br-ex
10.230.56.0     0.0.0.0         255.255.248.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br-phy
192.168.2.0     10.230.56.21    255.255.255.0   UG    0      0        0 eth6
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 br-phy
ubuntu@duduo:~$ route -n |grep 192.168.2
192.168.2.0     10.230.56.21    255.255.255.0   UG    0      0        0 eth6
ubuntu@duduo:~$ ping -c 1 192.168.2.1
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=0.232 ms

--- 192.168.2.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.232/0.232/0.232/0.000 ms
ubuntu@duduo:~$ ping6 -c 1 2001:db8:2::1
PING 2001:db8:2::1(2001:db8:2::1) 56 data bytes
64 bytes from 2001:db8:2::1: icmp_seq=1 ttl=64 time=0.287 ms

--- 2001:db8:2::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.287/0.287/0.287/0.000 ms

ubuntu@duduo:~$ route -n -6 |grep 2001:db8:2
2001:db8:2::/64                fe80::3ea8:2aff:fe21:9908  UG   1024 1     0 eth6
2001:db8:2::/56                fe80::3ea8:2aff:fe21:9908  UG   1024 0     0 eth6



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

quqi99

你的鼓励就是我创造的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值