AR100, AR120, AR150, AR160, AR200, AR1200, AR2200, AR3200, and AR3600 CLI-based Typical Configuration Examples
Example for Applying the AS-Path Attribute to a Route-Policy
Networking Requirements
As shown in Figure 8-28, four routers belong to different ASs and establish EBGP connections. When RouterD sends routes to RouterA, the AS-Path attribute needs to be changed so that route from RouterA to 192.168.6.1/24 is changed.
Procedure
- Configure RouterA.
# sysname RouterA # interface GigabitEthernet1/0/0 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.2.1 255.255.255.0 # interface LoopBack0 ip address 1.1.1.1 255.255.255.255 # bgp 100 router-id 1.1.1.1 //Set the router ID. You are advised to set the IP address of Loopback 0 as the router ID. peer 192.168.1.2 as-number 200 //Specify the peer IP address and AS number. peer 192.168.2.2 as-number 400 # ipv4-family unicast undo synchronization peer 192.168.1.2 enable peer 192.168.2.2 enable #
- Configure RouterB.
# sysname RouterB # interface GigabitEthernet1/0/0 ip address 192.168.3.1 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.2.2 255.255.255.0 # interface LoopBack0 ip address 2.2.2.2 255.255.255.255 # 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 peer 192.168.2.1 enable peer 192.168.3.2 enable #
- Configure RouterC.
# sysname RouterC # interface GigabitEthernet1/0/0 ip address 192.168.3.2 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.4.2 255.255.255.0 # interface LoopBack0 ip address 3.3.3.3 255.255.255.255 # bgp 300 router-id 3.3.3.3 peer 192.168.3.1 as-number 200 peer 192.168.4.1 as-number 400 # ipv4-family unicast undo synchronization peer 192.168.3.1 enable peer 192.168.4.1 enable #
- Configure RouterD.
# sysname RouterD # interface GigabitEthernet1/0/0 ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.4.1 255.255.255.0 # interface GigabitEthernet3/0/0 ip address 192.168.6.1 255.255.255.0 # interface LoopBack0 ip address 4.4.4.4 255.255.255.255 # bgp 400 router-id 4.4.4.4 peer 192.168.1.1 as-number 100 peer 192.168.4.2 as-number 300 # ipv4-family unicast undo synchronization network 192.168.6.0 255.255.255.0 //Configure BGP to advertise local routes. peer 192.168.1.1 enable peer 192.168.1.1 route-policy t1 export //Apply a route-policy to the advertised routes. peer 192.168.4.2 enable # route-policy t1 permit node 5 //Create a route-policy. apply as-path 400 400 400 additive //Add AS number 400 400 400 to the AS-Path list. #
- Verify the configuration.
# Before a route-policy is applied to RouterD, run the display bgp routing-table command on RouterA. You can see that there are two BGP routes destined for 192.168.6.0/24. A route with next-hop address 192.168.2.2 has AS-Path 200 300 400, and the other route with next-hop address 192.168.1.2 has AS-Path 400. Then run the display ip routing-table command. You can see that the route with next-hop address 192.168.1.2 is preferred.
# After a route-policy is applied to RouterD, run the display bgp routing-table command on RouterA. You can see that there are two BGP routes destined for 192.168.6.0/24. A route with next-hop address 192.168.2.2 has AS-Path 200 300 400, and the other route with next-hop address 192.168.1.2 has AS-Path 400,400,400,400. Then run the display ip routing-table command. You can see that the route with next-hop address 192.168.2.2 is preferred.