AR1:

#
interface Ethernet0/0/0
 ip address 192.168.1.1 255.255.255.0
#
interface Ethernet0/0/1
 ip address 192.168.2.1 255.255.255.0
#
bgp 100
 router-id 1.1.1.1
 peer 192.168.2.2 as-number 200
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.1.0
  peer 192.168.2.2 enable
#

 

AR3:

#
interface Ethernet0/0/0
 ip address 192.168.2.2 255.255.255.0
#
interface Ethernet0/0/1
 ip address 192.168.3.1 255.255.255.0
#
#
bgp 200
 router-id 2.2.2.2
 peer 192.168.2.1 as-number 100
 peer 192.168.3.2 as-number 300
 #
 ipv4-family unicast
  undo synchronization
  network 192.168.2.0
  network 192.168.3.0
  peer 192.168.2.1 enable
  peer 192.168.3.2 enable

 

AR4

interface Ethernet0/0/0
 ip address 192.168.3.2 255.255.255.0
#
bgp 300
 router-id 3.3.3.3
 peer 192.168.3.1 as-number 200
 #
 ipv4-family unicast
  undo synchronization
  peer 192.168.3.1 enable
#

 

这样bgp就建立起来了

[Huawei-bgp]dis bgp routing-table  192.168.1.1

 BGP local router ID : 2.2.2.2
 Local AS number : 200
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 192.168.1.0/24:
 From: 192.168.2.1 (1.1.1.1)
 Route Duration: 00h14m16s 
 Direct Out-interface: Ethernet0/0/0
 Original nexthop: 192.168.2.1
 Qos information : 0x0
 AS-path 100, origin igp, MED 0, pref-val 0, valid, external, best, select, acti
ve, pre 255
 Advertised to such 2 peers:
    192.168.2.1
    192.168.3.2

看到AR3把学到的bgp传递给AR1  AR4 了

现在要做的是:AR3阻止从AR1学习到的BGP发布到AR4.

 

AR1:

#
route-policy 1 permit node 10
 apply community no-export

#

bgp 100

  peer 192.168.2.2 route-policy 1 export
  peer 192.168.2.2 advertise-community
#

再查看AR4

[Huawei-bgp]dis bgp rou 
[Huawei-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete


 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   192.168.2.0        192.168.3.1     0                     0      200i
      192.168.3.0        192.168.3.1     0                     0      200i

 

就没有到AR1的bgp了