selecting best path route BGP using weight parameters

3 04 2009

In this tutorial, i will demonstrate how we can selecting best path using weight atributes on BGP. I’ve create a network topology consist 4 routers. here is the network topology :

In this scenario, i’m using GNS3 and dynagen. I’m using CISCO 3640. here is the IP address of each router :
R1 :

interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Serial0/0
description KONEK_R2
ip address 12.12.12.1 255.255.255.0
serial restart_delay 0
!
interface Serial0/1
description KONEK_R3
ip address 13.13.13.1 255.255.255.0
serial restart_delay 0

R2 :

interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Serial0/0
description KONEK_R1
ip address 12.12.12.2 255.255.255.0
serial restart_delay 0
!
interface Serial0/1
description KONEK_R4
ip address 24.24.24.2 255.255.255.0
serial restart_delay 0

R3 :

interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface Serial0/0
description KONEK_R1
ip address 13.13.13.3 255.255.255.0
serial restart_delay 0
!
interface Serial0/1
description KONEK_R4
ip address 34.34.34.3 255.255.255.0
serial restart_delay 0
!

R4 :

interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Serial0/0
description KONEK_R3
ip address 34.34.34.4 255.255.255.0
serial restart_delay 0
!
interface Serial0/1
description KONEK_R2
ip address 24.24.24.4 255.255.255.0
serial restart_delay 0

On each router, you can see loopback interface is activated. it used for BGP router ID. Now, lets start our scenario, R1 advertise their network (including loopback address) to all router. Destination IP is R1’s ip address, and the path selection from R3 is R3-R4-R2-R1 not R3-R1 and R4 path is R4-R2-R1. okey, now lets start our main configuration. i will start on R1 until R4.

R1 :

router ospf 1
log-adjacency-changes
network 12.12.12.1 0.0.0.0 area 0
network 13.13.13.1 0.0.0.0 area 0
!
router bgp 1
no synchronization
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 12.12.12.2 remote-as 2
neighbor 13.13.13.3 remote-as 34
no auto-summary

R2 :

router ospf 1
log-adjacency-changes
network 12.12.12.2 0.0.0.0 area 0
network 24.24.24.2 0.0.0.0 area 0
!
router bgp 2
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 12.12.12.1 remote-as 1
neighbor 24.24.24.4 remote-as 34
no auto-summary

R3 :

router ospf 1
log-adjacency-changes
network 13.13.13.3 0.0.0.0 area 0
network 34.34.34.3 0.0.0.0 area 0
!
router bgp 34
no synchronization
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 13.13.13.1 remote-as 1
neighbor 34.34.34.4 remote-as 34
no auto-summary

R4 :

router ospf 1
log-adjacency-changes
network 24.24.24.4 0.0.0.0 area 0
network 34.34.34.4 0.0.0.0 area 0
!
router bgp 34
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor 24.24.24.2 remote-as 2
neighbor 34.34.34.3 remote-as 34
no auto-summary

Okey, now let us verify the BGP conectivity. I’ll verify just on R3 and R4. here’s the output on R3

R3#sh ip bgp
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
... Network    Next Hop   Metric LocPrf Weight Path
*> 1.1.1.1/32 13.13.13.1   0              0  1 i

and the traceroute from R3 to R1 (loopback) is :

R3#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 13.13.13.1 88 msec 76 msec *

and the output of R4 is :

R4#sh ip bgp
BGP table version is 3, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
...   Network    Next Hop   Metric LocPrf Weight Path
*> 1.1.1.1/32 13.13.13.1   0        100      0  1 i
*             24.24.24.2                     0  2  1  i

and the traceroute output from R4 to R1 (loopback) is :

R4#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 34.34.34.3 112 msec 76 msec 156 msec
2 13.13.13.1 328 msec 288 msec *

As you can see from R3 and R4 sh ip bgp output, from R3 to reach R1 (1.1.1.1) via 13.13.13.1 and from R4 to reach R1 via 13.13.13.1. (default bgp, they choose the smallest AS path). And then, how we could change the default Path on R3 and R4? follow these steps :
R3 :

R3#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#router bgp 34
R3(config-router)#neighbor 34.34.34.4 weight 100

(MUST!!!)restart R3 bgp peering connection to apply the changes.
and the output will look like this :

R3#sh ip bgp
BGP table version is 6, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       13.13.13.1           0             0   1 i
*>i                 24.24.24.2           0    100    100   2 1 i

and the traceroute output from R3 to R1 (loopback address) is :

R3#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 34.34.34.4 96 msec 52 msec 24 msec
2 24.24.24.2 148 msec 236 msec 196 msec
3 12.12.12.1 260 msec 264 msec *

R4 :

R4#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#router bgp 34
R4(config-router)#neighbor 24.24.24.2 weight 100

(MUST!!!)restart R3 bgp peering connection to apply the changes.
and the output will look like this :

R3#sh ip bgp
BGP table version is 8, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.1/32       24.24.24.2           0    100    100   2 1 i
*                   13.13.13.1           0             0   1 i

and the traceroute output from R4 to R1 (loopback address) is :

R4#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 24.24.24.2 64 msec 116 msec 104 msec
2 12.12.12.1 240 msec 104 msec *

HOHOHOHO………..pass the first scenario :)

next scenario ?? wait……………..





Simple BGP Routing Filter

26 07 2008

hihihihihihihi, akhirnya posting lagi blog ga mutu ini :p . BGP??? wahhhh……. apaan tu? silakan cari artikel tentang BGP, gw ga bakalan ngejelasin tentang cara kerjanya :p . nah, gimana implementasi nya??? 

itu gambar diatas adalah contoh dari network gw. ada 3 buah router: IIX Router, Int’l Router, dan Our Router. IIX ROuter merupakan BGP router yang tugasnya memberikan prefix IIX ke router kita. Int’l Router sama kaya’ IIX router tapi message yang dibawa adalah prefix internasional. Our Router tugasnya adalah meneruskan prefix prefix yang tadi untuk di teruskan ke client (bgp peering client). nah.. dalam gambar diatas ada kasus kek gini, gimana ya caranya buat filter prefix supaya prefix yg berasal dari IIX router tidak masuk ke Int’l router, dan juga sebaliknya. skarang ambil conto kasus kek gini, dari Int’l router, dia mengadvertise 250.000 prefix ke our router, IIX router juga mengadvertise 2000 prefix ke Our router. our router akan mengadvertise kembali prrefix-prefix yang diterima dari Int’l router ke IIX router, dan juga sebaliknya. waahhh, kebayang dong load yang terjadi di IIX router kalo dia nerima prefix prefix dari IIX router. kalo kamu udah pernah config bgp routing, pasti pada tau, betapa ngerinya prefix prefix yang bakal di advertise ke router kita. Pengalaman gw, router gw menerima 250.000 prefix lebih dari internet. nah, disini gw cuman bahas, gimana filter prefix biar prefix tadi ga salah masuk. oke, sekarang kita mulai konfig. gw disini make CISCO openbgpd :p, maklum ga punya duit buat beli cisco :D . IIX router dan Int’l router gw anggap sudah melakukan peering ke Our Router. IIX router AS-Numbernya 12345 dan Int’l Router AS-Numbernya 23456. oks, mulai konfigurasi. konfigurasinya adalah sebagai berikut (Our Router) :

IIX   =”10.20.30.40″
inter   =”50.60.70.4″

AS 2222 #AS Number router kita
router-id 50.60.70.5
listen on 127.0.0.1

fib-update yes
nexthop qualify via bgp
log updates
network 50.60.70.96/27  #ini network yang akan di advertise ke IIX router dan Int’l Router
# neighbors and peers

group “internasional” {
remote-as       23456
announce        all
announce        capabilities yes
softreconfig    in yes
multihop        2
neighbor $core1

{
descr   “INT”

}

}

group “IIX-Peering” {

remote-as      12345

announce       all

neighbor $iix { descr “IIX-only” }

}

deny from any
allow from any inet prefixlen 8 – 24
# do not accept a default route
deny from any prefix 0.0.0.0/0
deny to {group IIX-Peering} peer-as {38458, 17826} #Penting neeh
# filter bogus networks
deny from any prefix 10.0.0.0/8 prefixlen >= 8
deny from any prefix 172.16.0.0/12 prefixlen >= 12
deny from any prefix 192.168.0.0/16 prefixlen >= 16
deny from any prefix 169.254.0.0/16 prefixlen >= 16
deny from any prefix 192.0.2.0/24 prefixlen >= 24
deny from any prefix 224.0.0.0/4 prefixlen >= 4
deny from any prefix 240.0.0.0/4 prefixlen >= 4

oke. konfigurasinya cukup kek diatas.trus jalanin bgpd . deny to {group IIX-Peering} peer-as {38458, 17826} dapetnya dari mana?????? liat neh, gw kasi dikit output dari prefix yg di advertise ke Our Router dari Int’l Router :

flags destination         gateway               lpref   med aspath origin
I*    8.3.19.0/24         202.149.67.121     100     0    17826 4788 3356 26769 i
I*    8.3.26.0/23         202.149.67.121     100     0    17826 4788 3356 26769 i
I*    8.3.30.0/24         202.149.67.121     100     0    17826 4788 10026 15133 15133 i
I*    8.3.37.0/24         202.149.67.121     100     0    17826 4788 3356 21640 i
I*    8.3.38.0/23         202.149.67.121     100     0    17826 4788 5511 3549 16420 i
I*    8.3.46.0/24         202.149.67.121     100     0    17826 4788 3356 21640 i
I*    8.3.52.0/23         202.149.67.121     100     0    17826 4788 1239 26759 i
I*    8.3.160.0/24        202.149.67.121    100     0    17826 4788 3356 36524 i
I*    8.3.162.0/24        202.149.67.121    100     0    17826 4788 5511 3549 17058 i
I*    8.3.208.0/24        202.149.67.121    100     0    17826 4788 701 36431 i
I*    8.3.210.0/24        202.149.67.121    100     0    17826 4788 27524 i
I*    8.3.211.0/24        202.149.67.121    100     0    17826 4788 3356 40415 i
I*    8.3.213.0/24        202.149.67.121    100     0    17826 4788 4739 i
I*    8.3.214.0/23        202.149.67.121    100     0    17826 4788 3356 23286 i
I*    8.3.218.0/23        202.149.67.121    100     0    17826 4788 3356 26769 i

itu sebagian output dari prefix yang di advertise ke Our Router dari Int’l Router. kalo gw copiin semua outputnya semua…… hahhahaha muntah muntah ntar :D . oke……. gw filternya ngambil Leftmost AS (17826). liat deh output di atas. deny to {group IIX-Peering} peer-as {38458, 17826} artinya, router kita (Our Router) nggak bakalan meng-advertise prefix prefix yang memiliki LeftMost AS 17826 dan 38458 ke group IIX-Peering. kalo pengen ngeliat prefix yang di advertise ke router kita, pake perintah ini : bgpctl sh rib neigh INT in

gampang kan?? untuk filter yang lebih lanjut, sabar yaahhh, gw juga masih belajar. maklum masi newbie alias CUPU banget.

dedicated to iud ^_^