所谓地址族,就是把ipv4、ipv6和vpnv4分成不同的“块”,对每个“块”单独进行配置,如下所示:
Rack1R3(config-router)#address-family ?
ipv4 Address family
ipv6 Address family
vpnv4 Address family
由于ipv6现在应用较少,所以暂时不予讨论,如果大家配置过MPLS VPN,那么对ipv4和vpnv4这两个地址族应该有些了解。
其实如果不是有特殊应用(MPLS、Ipv6),也不会用到这些地址族的概念,直接默认建立全局BGP邻居及属性就可以了。所以可以理解地址组是BGP的一个扩展。
下面我们就这两个地址族进行分析。
Ipv4和vpnv4地址族的分析:
特殊说明:“no bgp default ipv4-unicast” 命令是在全局BGP下禁用单播的传播,在MPLS中,正确的配置就是打上此命令,然后如果需要全局BGP连接或在BGP vpnv4连接,那么就在各个地址族中激活此邻居就可以了。
但有些全局命令是可以被继承到各个地址族中的。
以下分别分析几种常见的情况
1、如果没有配置“no bgp default ipv4-unicast”,直接在全局配置BGP邻居关系,这样ipv4地址族会默认被激活的,但是不会显示在“show run”中,如下所示:
Rack1R1#config ter
Enter configuration commands, one per line. End with CNTL/Z.
Rack1R1(config)#router bgp 1
Rack1R1(config-router)#bgp router-id 150.1.1.1
Rack1R1(config-router)#nei 150.1.2.2 remote-as 1
Rack1R1(config-router)#nei 150.1.2.2 update-source lo0
Rack1R1(config-router)#address-family vpnv4
Rack1R1(config-router-af)#nei 150.1.2.2 activate
Rack1R1(config-router-af)#nei 150.1.2.2 send-community ex
Rack1R1(config-router-af)#exit
Rack1R1(config-router)#end
Rack1R1#
Rack1R1#sh run | b r b
router bgp 1
no synchronization
bgp router-id 150.1.1.1
neighbor 150.1.2.2 remote-as 1
neighbor 150.1.2.2 update-source Loopback0
no auto-summary
! >>>>> 没有ipv4地址族
address-family vpnv4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family
!
2、此时如果打上“no bgp default ipv4-unicast” ,address-family ipv4地址族就会自动显示出来,此时如果再建立BGP全局邻居,这条命令就会生效:
Rack1R1#config ter
Enter configuration commands, one per line. End with CNTL/Z.
Rack1R1(config)#router bgp 1
Rack1R1(config-router)#no bgp default ipv4-unicast
Rack1R1(config-router)#end
Rack1R1#
Rack1R1#sh run | b r b
router bgp 1
bgp router-id 150.1.1.1
no bgp default ipv4-unicast
neighbor 150.1.2.2 remote-as 1
neighbor 150.1.2.2 update-source Loopback0
!
address-family ipv4
neighbor 150.1.2.2 activate
no auto-summary >>>>> 这些命令从全局BGP配置中继承到了ipv4的地址族中
no synchronization
exit-address-family
!
address-family vpnv4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family
再加一个全局BGP邻居会怎么样呢?
Rack1R1#config ter
Enter configuration commands, one per line. End with CNTL/Z.
Rack1R1(config)#router bgp 1
Rack1R1(config-router)#nei 150.1.3.3 remot 1
Rack1R1(config-router)#nei 150.1.3.3 update-source lo0
Rack1R1(config-router)#end
Rack1R1#
Rack1R1#sh run | b r b
router bgp 1
bgp router-id 150.1.1.1
no bgp default ipv4-unicast
neighbor 150.1.2.2 remote-as 1
neighbor 150.1.2.2 update-source Loopback0
neighbor 150.1.3.3 remote-as 1
neighbor 150.1.3.3 update-source Loopback0
!
address-family ipv4 >>>>> 在ipv4地址族中没有150.1.3.3 的邻居
neighbor 150.1.2.2 activate
no auto-summary
no synchronization
exit-address-family
!
address-family vpnv4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family
!
由于“no bgp default ipv4-unicast”命令的关系,虽然建立了全局BGP的邻居,但它是不会出现在任何地址族中的。如果想在ipv4或vpnv4中起效果,就得在地址族中用“nei 150.1.3.3 active”把邻居激活:
Rack1R1(config-router)#address-family ipv4
Rack1R1(config-router-af)#nei 150.1.3.3 activate
Rack1R1(config-router-af)#exit
Rack1R1(config-router)#end
Rack1R1#
Rack1R1#sh run | b r b
router bgp 1
bgp router-id 150.1.1.1
no bgp default ipv4-unicast
neighbor 150.1.2.2 remote-as 1
neighbor 150.1.2.2 update-source Loopback0
neighbor 150.1.3.3 remote-as 1
neighbor 150.1.3.3 update-source Loopback0
!
address-family ipv4
neighbor 150.1.2.2 activate
neighbor 150.1.3.3 activate
no auto-summary
no synchronization
exit-address-family
!
address-family vpnv4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family