概念定义:
所谓地址族,就是把ipv4、ipv6和***v4分成不同的“块”,对每个“块”单独进行配置,如下所示:
Rack1R3(config-router)#address-family ?
ipv4 Address family
ipv6 Address family
***v4 Address family
由于ipv6现在应用较少,所以暂时不予讨论,如果大家配置过MPLS ×××,那么对ipv4和***v4这两个地址族应该有些了解。
其实如果不是有特殊应用(MPLS、Ipv6),也不会用到这些地址族的概念,直接默认建立全局BGP邻居及属性就可以了。所以可以理解地址组是BGP的一个扩展。
下面我们就这两个地址族进行分析。
Ipv4和***v4地址族的分析:
特殊说明:“no bgp default ipv4-unicast” 命令是在全局BGP下禁用单播的传播,在MPLS中,正确的配置就是打上此命令,然后如果需要全局BGP连接或在BGP ***v4连接,那么就在各个地址族中激活此邻居就可以了。
但有些全局命令是可以被继承到各个地址族中的。
以下分别分析几种常见的情况
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 ***v4
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 ***v4
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 ***v4
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 ***v4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family
!
由于“no bgp default ipv4-unicast”命令的关系,虽然建立了全局BGP的邻居,但它是不会出现在任何地址族中的。如果想在ipv4或***v4中起效果,就得在地址族中用“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 ***v4
neighbor 150.1.2.2 activate
neighbor 150.1.2.2 send-community extended
exit-address-family
!
3、如果在没打“no bgp default ipv4-unicast”时,配置“address-family ipv4” (不用配置地址族,进去后直接end退出),会怎么样呢?
Rack1R2#sh run | b r b
router bgp 1
no synchronization
bgp router-id 150.1.2.2
neighbor 150.1.1.1 remote-as 1
neighbor 150.1.1.1 update-source Loopback0
no auto-summary
! >>>>> 此时没有ipv4地址族
address-family ***v4
neighbor 150.1.1.1 activate
neighbor 150.1.1.1 send-community extended
exit-address-family
Rack1R2(config)#router bgp 1
Rack1R2(config-router)#address-family ipv4
Rack1R2(config-router-af)#exit
Rack1R2(config-router)#end
Rack1R2#
Rack1R2#sh run | b r b
router bgp 1
bgp router-id 150.1.2.2
neighbor 150.1.1.1 remote-as 1
neighbor 150.1.1.1 update-source Loopback0
!
address-family ipv4
neighbor 150.1.1.1 activate
no auto-summary
no synchronization
exit-address-family
!
address-family ***v4
neighbor 150.1.1.1 activate
neighbor 150.1.1.1 send-community extended
exit-address-family
!
可以看出来,全局的BGP邻居出现在ipv4的地址族中了,所以得出结论:在不配置“no bgp default ipv4-unicast”命令时,默认会把全局BGP邻居关系继承到Ipv4的地址族中。
此时可以用no命令no掉Ipv4地址组中的邻居关系,但命令形式有两种,一种是直接从配置中no掉,一种是no掉后不会从配置中清除,详细如下所示:
No 掉后不会从配置中清除:
Rack1R2(config)#router bgp 1
Rack1R2(config-router)#address-family ipv4
Rack1R2(config-router-af)#no nei 150.1.3.3 activate
Rack1R2(config-router-af)#exit
Rack1R2(config-router)#end
Rack1R2#
Rack1R2#sh run | b r b
router bgp 1
bgp router-id 150.1.2.2
neighbor 150.1.1.1 remote-as 1
neighbor 150.1.1.1 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.1.1 activate
no neighbor 150.1.3.3 activate
no auto-summary
no synchronization
exit-address-family
此时有2种方法可以从配置中清除ipv4地址族中的没有用的BGP邻居关系:
1、直接在全局BGP配置下配置“no bgp default ipv4-unicast”
2、用“no nei ” 来把整个邻居No掉,如下所示:
No 掉后从配置中清除:
Rack1R2(config-router)#address-family ipv4
Rack1R2(config-router-af)#no nei 150.1.3.3
Rack1R2(config-router-af)#end
Rack1R2#
Rack1R2#sh run | b r b
router bgp 1
bgp router-id 150.1.2.2
neighbor 150.1.1.1 remote-as 1
neighbor 150.1.1.1 update-source Loopback0
! >>>>> 整个全局BGP的邻居被No掉了
address-family ipv4
neighbor 150.1.1.1 activate
no auto-summary
no synchronization
exit-address-family
4、关于***v4的地址族,只要在***v4地址族中打上“nei active”就可以了,“neighbor send-community extended”是自动生成的,其他的BGP Policies需要自己手工配置。
在有路由反射器的情况下,“no neighbor peer-group ”命令可以直接从配置中删除此行(ipv4地址族中),但是不能No掉整个peer group,如:
c12012-GD-RR(config-router)#address-family ipv4
c12012-GD-RR(config-router-af)#no neighbor pc1 activate
% Peergroups are automatically activated when parameters are configured
总结:
1、无论是否执行“no bgp default ipv4-unicast”,可以说全局BGP配置同等于ipv4地址组中的配置,如果此时你在ipv4下直接用“no nei ”命令,他会直接从全局BGP的邻居中no掉此邻居,所以不建议如此操作。
2、如果执行了“no bgp default ipv4-unicast”,BGP的Policies (如“route-reflector-client”、“next-hop-self”等)就不能在全局BGP中配置,它们只能在地址族中起作用,这是新版IOS的特性,其实也是强制使配置规范
转载于:https://blog.51cto.com/alandu/804331