Example for Configuring the BGP Community Attribute

Created Nov 27, 2014 23:31:25Latest reply Nov 28, 2014 11:36:47 5681 2 0 0
 connections are established between SwitchB and SwitchA, and between SwitchB and SwitchC. It is required that AS 20 not advertise the routes advertised by AS 10 to AS 30.

 

 

 

Procedure
Configure VLANs that interfaces belong to.

<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 20
[SwitchA] interface gigabitethernet 1/0/0
[SwitchA-GigabitEthernet1/0/0] port link-type trunk
[SwitchA-GigabitEthernet1/0/0] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet1/0/0] quit
[SwitchA] interface gigabitethernet 2/0/0
[SwitchA-GigabitEthernet2/0/0] port link-type trunk
[SwitchA-GigabitEthernet2/0/0] port trunk allow-pass vlan 20
[SwitchA-GigabitEthernet2/0/0] quitThe configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not mentioned here.


Assign an IP address to each VLANIF interface.

[SwitchA] interface vlanif 10
[SwitchA-Vlanif10] ip address 10.1.1.1 24
[SwitchA-Vlanif10] quit
[SwitchA] interface vlanif 20
[SwitchA-Vlanif20] ip address 192.168.2.1 24
[SwitchA-Vlanif20] quitThe configurations of SwitchB and SwitchC are similar to the configuration of SwitchA, and are not mentioned here.


Configure EBGP.

# ConfigureSwitchA.

[SwitchA] bgp 10
[SwitchA-bgp] router-id 172.16.1.1
[SwitchA-bgp] peer 192.168.2.2 as-number 20
[SwitchA-bgp] ipv4-family unicast
[SwitchA-bgp-af-ipv4] network 10.1.1.0 255.255.255.0
[SwitchA-bgp-af-ipv4] quit
[SwitchA-bgp] quit# Configure SwitchB.

[SwitchB] bgp 20
[SwitchB-bgp] router-id 172.16.2.2
[SwitchB-bgp] peer 192.168.2.1 as-number 10
[SwitchB-bgp] peer 192.168.3.2 as-number 30
[SwitchB-bgp] quit# Configure SwitchC.

[SwitchC] bgp 30
[SwitchC-bgp] router-id 172.16.3.3
[SwitchC-bgp] peer 192.168.3.1 as-number 20
[SwitchC-bgp] quit# Check the routing table of SwitchB.

[SwitchB] display bgp routing-table 10.1.1.0

BGP local router ID : 172.16.2.2
 Local AS number : 20
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 10.1.1.0/24:
 From: 192.168.2.1 (172.16.1.1)
 Route Duration: 00h00m15s
 Direct Out-interface: Vlanif20
 Original nexthop: 192.168.2.1
 Qos information : 0x0
 AS-path 10, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255
 Advertised to such 2 peers:
    192.168.2.1
    192.168.3.2You can view that SwitchB advertises the received routes to SwitchC in AS 30.

# Check the routing table of SwitchC.

[SwitchC] display bgp routing-table

 BGP Local router ID is 172.16.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: 1
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   10.11.1.0/24        192.168.3.1                           0      20 10iYou can find that SwitchC has learned a route to the destination 10.1.1.0/24 from SwitchB.


Configure BGP community attributes.

# Configure the routing policy on SwitchA to enable SwitchB not to advertise the routes advertised by SwitchA to any other AS.

[SwitchA] route-policy comm_policy permit node 10
[SwitchA-route-policy] apply community no-export
[SwitchA-route-policy] quit# Apply routing policies.

[SwitchA] bgp 10
[SwitchA-bgp] ipv4-family unicast
[SwitchA-bgp-af-ipv4] peer 192.168.2.2 route-policy comm_policy export
[SwitchA-bgp-af-ipv4] peer 192.168.2.2 advertise-community# Check the routing table of SwitchB.

[SwitchB] display bgp routing-table 10.1.1.0

BGP local router ID : 172.16.2.2
 Local AS number : 20
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 10.1.1.0/24:
 From: 192.168.2.1 (172.16.1.1)
 Route Duration: 00h00m33s
 Direct Out-interface: Vlanif20
 Original nexthop: 192.168.2.1
 Qos information : 0x0
 Community:no-export
 AS-path 10, origin igp, MED 0, pref-val 0, valid, external, best, select, activ
e, pre 255
 Not advertised to any peer yetYou can view the configured community attribute in the BGP routing table of SwitchB. At this time, there are no routes to the destination 10.1.1.0/24 in the BGP routing table of SwitchC.


Configuration Files
Configuration file of SwitchA

#
sysname SwitchA
#
vlan batch 10 20
#
interface Vlanif10
 ip address 10.1.1.1 255.255.255.0
#
interface Vlanif20
 ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet1/0/0
 port link-type trunk
 port trunk allow-pass vlan 10
#
interface GigabitEthernet2/0/0
 port link-type trunk
 port trunk allow-pass vlan 20
#
bgp 10
 router-id 172.16.1.1
 peer 192.168.2.2 as-number 20
 #
 ipv4-family unicast
  undo synchronization
  network 10.1.1.0 255.255.255.0
  peer 192.168.2.2 enable
  peer 192.168.2.2 route-policy comm_policy export
  peer 192.168.2.2 advertise-community
#
route-policy comm_policy permit node 10
 apply community no-export
#
returnConfiguration file of SwitchB

#
sysname SwitchB
#
vlan batch 20 30
#
interface Vlanif20
 ip address 192.168.2.2 255.255.255.0
#
interface Vlanif30
 ip address 192.168.3.1 255.255.255.0
#
interface GigabitEthernet2/0/0
 port link-type trunk
 port trunk allow-pass vlan 20
#
interface GigabitEthernet3/0/0
 port link-type trunk
 port trunk allow-pass vlan 30
#
bgp 20
 router-id 172.16.2.2
 peer 192.168.2.1 as-number 10
 peer 192.168.3.2 as-number 30
 #
 ipv4-family unicast
  undo synchronization
  peer 192.168.2.1 enable
  peer 192.168.3.2 enable
#
returnConfiguration file of SwitchC

#
sysname SwitchC
#
vlan 30
#
interface Vlanif30
 ip address 192.168.3.2 255.255.255.0
#
interface GigabitEthernet3/0/0
 port link-type trunk
 port trunk allow-pass vlan 30
#
bgp 30
 router-id 172.16.3.3
 peer 192.168.3.1 as-number 20
 #
 ipv4-family unicast
  undo synchronization
  peer 192.168.3.1 enable
#
return

 

 

  • x
  • convention:

user_109211     Created Nov 27, 2014 23:31:52 Helpful(0) Helpful(0)

support
  • x
  • convention:

user_2790689  Expert   Created Nov 28, 2014 11:36:47 Helpful(0) Helpful(0)

Thank you.
  • x
  • convention:

Responses

Reply
You need to log in to reply to the post Login | Register

Notice:To ensure the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but not limited to politically sensitive content, content concerning pornography, gambling, drug abuse and trafficking, content that may disclose or infringe upon others' intellectual properties, including commercial secrets, trade marks, copyrights, and patents, and personal privacy. Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see“ Privacy Policy.”
If the attachment button is not available, update the Adobe Flash Player to the latest version!
Fast reply Scroll to top