在运行IBGP时,内部路由器一般都要运行IGP路由协议,建立邻居关系时用loopback口作为更新源,在运行EBGP时,也是用loopback口作为更新源,而且还要建立一条到对端路由器loopback口的路由,一般是静态,因为BGP默认路由只传播一跳,所以EBGP没有IGP传播路由,所以要特别指定EBGP多跳,BGP建立邻居关系后,并不能传播路由,需要把与对等体组相连的网络通告。BGP的边界路由器和内部对等体建立邻居关系时,要指明next-hop-self 指向自己,这样内部BGP对等体才能通告自己去往其他的AS。
R1配置
interface Loopback0
ip address 1.1.1.1 255.255.255.255
interface FastEthernet0/0
ip address 12.12.12.1 255.255.255.0
interface FastEthernet0/1
ip address 13.13.13.1 255.255.255.0!
router rip
version 2
network 1.0.0.0
network 12.0.0.0
network 13.0.0.0
no auto-summary
router bgp 65535
no synchronization
network 12.12.12.0 mask 255.255.255.0
network 13.13.13.0 mask 255.255.255.0
neighbor 2.2.2.2 remote-as 65535
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 65535
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
R2配置
interface Loopback0
ip address 2.2.2.2 255.255.255.255
interface FastEthernet0/0
ip address 12.12.12.2 255.255.255.0
interface FastEthernet0/1
ip address 24.24.24.1 255.255.255.0
interface FastEthernet1/0
ip address 23.23.23.1 255.255.255.0
router rip
version 2
network 2.0.0.0
network 12.0.0.0
network 23.0.0.0
no auto-summary
router bgp 65535
no synchronization
bgp default local-preference 200 //在全局下配置本地优先级,影响本地
network 12.12.12.0 mask 255.255.255.0
network 23.23.23.0 mask 255.255.255.0
network 24.24.24.0 mask 255.255.255.0
neighbor INTER peer-group //运用对等体组配置BGP,简化了配置
neighbor INTER remote-as 65535
neighbor INTER update-source Loopback0
neighbor INTER next-hop-self
neighbor 1.1.1.1 peer-group INTER
neighbor 3.3.3.3 peer-group INTER
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 ebgp-multihop 2
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 route-map LOCAL_PRE_200 in
no auto-summary
ip route 4.4.4.4 255.255.255.255 24.24.24.2
access-list 10 permit 200.200.200.0 0.0.0.255
route-map LOCAL_PRE_200 permit 10
match ip address 10
set local-preference 1500
运用rout-map指明特定的网络从哪个路由器通过,对本地的成员出去起作用
R3路由器配置
interface Loopback0
ip address 3.3.3.3 255.255.255.255
interface FastEthernet0/0
ip address 13.13.13.2 255.255.255.0
interface FastEthernet0/1
ip address 34.34.34.1 255.255.255.0
interface FastEthernet1/0
ip address 23.23.23.2 255.255.255.0
router rip
version 2
network 3.0.0.0
network 13.0.0.0
network 23.0.0.0
no auto-summary
router bgp 65535
no synchronization
bgp default local-preference 500
network 13.13.13.0 mask 255.255.255.0
network 23.23.23.0 mask 255.255.255.0
network 34.34.34.0 mask 255.255.255.0
neighbor INTER peer-group
neighbor INTER remote-as 65535
neighbor INTER update-source Loopback0
neighbor INTER next-hop-self
neighbor 1.1.1.1 peer-group INTER
neighbor 2.2.2.2 peer-group INTER
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 ebgp-multihop 2
neighbor 4.4.4.4 update-source Loopback0
no auto-summary
ip route 4.4.4.4 255.255.255.255 34.34.34.2
R4路由器配置
interface Loopback0
ip address 4.4.4.4 255.255.255.255
interface Loopback100
ip address 100.100.100.1 255.255.255.0
interface Loopback200
ip address 200.200.200.1 255.255.255.0
interface FastEthernet0/0
ip address 24.24.24.2 255.255.255.0
interface FastEthernet0/1
ip address 34.34.34.2 255.255.255.0
router bgp 100
no synchronization
bgp log-neighbor-changes
network 24.24.24.0 mask 255.255.255.0
network 34.34.34.0 mask 255.255.255.0
network 100.100.100.0 mask 255.255.255.0
network 200.200.200.0
neighbor EBGP peer-group
neighbor EBGP remote-as 65535
neighbor EBGP ebgp-multihop 2
neighbor EBGP update-source Loopback0
neighbor 2.2.2.2 peer-group EBGP
neighbor 3.3.3.3 peer-group EBGP
no auto-summary
ip route 3.3.3.3 255.255.255.255 34.34.34.1
BGP的路径操作有
权重(weight),权重越大越优先。neighbor PEERROUTER weight 权重值,权重值只影响当前的路由器,对其他路由器权重值不影响,但是会影响其他路由的路径
本地优先级(local-preference): 优先级越大越优先,上面配置运用到了。
AS路由(as-path):通告路由映射图设置,可以手动指定到某个网络经过哪些AS。
MED多路径鉴别器,当本AS的两个或两个以上路由器连接到其他ASS时,影响外部网络到内部网络要经过的路由器,可以在路由配置全局指定,也可以用路由映射图指定特定的网络的MED。
BGP还有一些团体属性和路由反射器功能。