• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

BGP Basic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BGP Basic

    Basic BGP
    1. Mục tiêu
    Trong bài lab này, chúng ta sẽ cấu hình BGP cơ bản để kết nối với hai ISP

    2. Hoàn cảnh



    Công ty XYZ ở Sài Gòn là một công ty chuyên kinh doanh buôn bán qua mạng. Do yêu cầu của công ty, mạng của XYZ thuộc AS100 có kết nối đến hai ISP sử dụng BGP có dạng sơ đồ trên. Phòng kỹ thuật đã chọn bạn để thực hiện công việc này, bạn muốn thử nghiệm trên test lab trước khi thực hiện công việc.

    3. Thực hiện
    a. Bước 1
    Kết nối mạng theo sơ đồ như trên. Cấu hình hostname, địa chỉ IP các interface serial, loopback theo đúng sơ đồ. Chưa cấu hình routing protocol. Kiểm tra các kết nối trực tiếp bằng lệnh ping và show cdp neighbor. Chú ý lúc này ISP1 chưa thể ping được ISP2.

    b. Bước 2
    Trong bài lab này, ta cấu hình BGP ở cả router ISP1, ISP2 và router SaiGon:

    ISP1(config)#router bgp 200
    ISP1(config-router)#neighbor 10.0.0.2 remote-as 100
    ISP1(config-router)#network 12.0.1.0 mask 255.255.255.0

    Trên router ISP2, ta cấu hình như sau:

    ISP2(config)#router bgp 300
    ISP2(config-router)#neighbor 172.16.0.2 remote-as 100
    ISP2(config-router)#network 172.16.1.0 mask 255.255.255.0

    c. Bước 3
    Cấu hình router SaiGon3 chạy BGP với cả hai ISP:

    SaiGon(config)#router bgp 100
    SaiGon(config-router)#neighbor 10.0.0.1 remote-as 200
    SaiGon(config-router)#neighbor 172.16.0.1 remote-as 300
    SaiGon(config-router)#network 192.168.0.0
    SaiGon(config-router)#network 192.168.1.0

    Nếu bạn không cấu hình mask ở câu lệnh network thì router sẽ lấy mask mặc định theo classful.

    Kiểm tra bảng route tại SaiGon:
    SaiGon#show ip route

    Gateway of last resort is not set

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
    C 192.168.1.0/24 is directly connected, Loopback1

    Router SaiGon đã thiết lập các route đến các loopback interface của các router ISP. Kiểm tra các kết nối này bằng lệnh ping, và kết quả phải ping thành công.

    d. Bước 4
    Dùng lệnh show ip bgp để kiểm tra hoạt động của BGP:

    SaiGon#show ip bgp
    [fade:10c63099f2]BGP table version is 17[/fade:10c63099f2], local router ID is 192.168.1.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
    Origin codes: i - IGP, e - EGP, ? - incomplete

    Network Next Hop Metric LocPrf Weight Path
    *> 12.0.1.0/24 10.0.0.1 0 0 200 i
    *> 172.16.1.0/24 172.16.0.1 0 0 300 i
    *> 192.168.0.0 0.0.0.0 0 32768 i
    *> 192.168.1.0 0.0.0.0 0 32768 i

    Table version có thể thay đổi tùy theo tình huống cụ thể. Ví dụ, ta shutdown interface loopback 0 của ISP1 sau đó no shutdown trở lại, table version sẽ tăng lên 1 đơn vị so với trước đó.

    e. Bước 5
    Kiểm tra bảng route tại router ISP2 bằng lệnh show ip route. ISP2 phải có route 12.0.1.0 thuộc router ISP1.
    Router SaiGon đã quảng bá các network của ISP1 cho ISP2. ISP2 sau đó đưa các network này vào bảng route của nó và có thể đưa các transit traffic qua SaiGon, điều này là không mong muốn. Ta sẽ cấu hình SaiGon sao cho nó chỉ quảng bá các network của SaiGon là 192.168.0.0/24 và 192.168.1.0/24 cho cả hai ISP. Trên SaiGon, ta cấu hình access-list:

    SaiGon(config)#access-list 1 permit 192.168.0.0 0.0.1.255

    Sau đó, sử dụng access list này như là một route filter, dùng từ khóa
    distribute-list trong lệnh BGP neighbor:

    SaiGon(config)#router bgp 100
    SaiGon(config-router)#neighbor 10.0.0.1 distribute-list 1 out
    SaiGon(config-router)#neighbor 172.16.0.1 distribute-list 1 out

    Sau khi cấu hình route filter, kiểm tra lại bảng route của ISP2, route đến network có thể vẫn còn trong đó.
    Trở lại router SaiGon, đánh lệnh clear ip bgp * và chờ vài giây để các router đạt đến trạng thái Establish. Sau đó kiểm tra bảng route của ISP2, các route đến network của ISP1 sẽ không xuất hiện trong bảng route của ISP2. Route đến network 172.16.1.0 của ISP2 cũng không xuất hiện trong bảng route của ISP1.

    f. Bước 6:
    Bây giờ, ta đã có liên kết bằng BGP giữa SaiGon và hai ISP. Vấn đề tiếp theo là khai báo primary route và backup route. Để thực hiện điều này, có thể sử dụng floating static route hoặc khai báo trong BGP.
    Sử dụng phương pháp dùng static route, ta kiểm tra bảng định tuyến trên router SaiGon:

    SaiGon#show ip route

    Gateway of last resort is not set

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
    C 192.168.1.0/24 is directly connected, Loopback1

    Chú ý rằng ta chưa xác định “Gateway of last resort”. Đây là một việc cần phải thực hiện do router SaiGon là một border router cho toàn bộ mạng của công ty. Giả sử ISP1 là primary provider và ISP2 là backup provider, ta cấu hình như sau:

    SaiGon(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
    SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220

    Để kiểm tra default route đã được thực hiện, ta dùng show ip route trên router SaiGon:
    SaiGon#show ip route

    Gateway of last resort is 10.0.0.1 to network 0.0.0.0

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:01:28
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:34
    C 192.168.1.0/24 is directly connected, Loopback1
    S* 0.0.0.0/0 [210/0] via 10.0.0.1

    Để kiểm tra default route này, trước hết ta tạo một loopback interface trên ISP1:

    ISP1(config)#interface loopback 100
    ISP1(config-if)#ip address 210.210.210.1 255.255.255.0

    Trên router SaiGon, dùng lệnh clear ip bgp 10.0.0.1 để thiết lập lại kết nối BGP với neighbor 10.0.0.1:

    SaiGon#clear ip bgp 10.0.0.1

    Sau một lúc, khi kết nối BGP với host 10.0.0.1 được thiết lập lại, kiểm tra bảng route của router SaiGon để chắc chắn rằng network 210.210.210.1/24 không xuất hiện trong đó:

    SaiGon#show ip route

    Gateway of last resort is 10.0.0.1 to network 0.0.0.0

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:04:00
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:35
    C 192.168.1.0/24 is directly connected, Loopback1
    S* 0.0.0.0/0 [210/0] via 10.0.0.1

    Dùng extend ping từ địa chỉ 192.168.1.1 của SaiGon đến địa chỉ 210.210.210.1:
    SaiGon#ping
    Protocol [ip]:
    Target IP address: 210.210.210.1
    Repeat count [5]:
    Datagram size [100]:
    Timeout in seconds [2]:
    Extended commands [n]: y
    Source address or interface: 192.168.1.1
    Type of service [0]:
    Set DF bit in IP header? [no]:
    Validate reply data? [no]:
    Data pattern [0xABCD]:
    Loose, Strict, Record, Timestamp, Verbose[none]:
    Sweep range of sizes [n]:
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 210.210.210.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 28/30/32 ms

    g. Bước 7
    Một phương pháp khác để giải quyết vấn đề default route của router SaiGon là dùng lệnh default-network thay vì sử dụng route 0.0.0.0/0
    Trước hết, ta bỏ các floating static route trong bước trước:

    SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
    SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 172.16.0.1 220

    Ta sẽ quảng bá network 210.210.210.0/24 trên router ISP1:

    ISP1(config)#router bgp 200
    ISP1(config-router)#network 210.210.210.0
    ISP1(config-router)#^Z
    ISP1#clear ip bgp 10.0.0.2

    Router SaiGon bây giờ cần phải cấu hình bằng lệnh default-network để thiết lập “Gateway of last resort”:
    SaiGon(config)#ip default-network 210.210.210.0

    SaiGon#show ip route

    Gateway of last resort is 10.0.0.1 to network 210.210.210.0

    B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:21
    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:20
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:50
    C 192.168.1.0/24 is directly connected, Loopback1

    Ta đã cấu hình default route cho router SaiGon, để thiết lập kết nối dự phòng với ISP2, ta dùng static route:

    SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220

    Các route được học từ eBGP có AD bằng 20 sẽ được ưu tiên hơn các route có AD lớn hơn 20, như route vừa cấu hình trên với AD bằng 220. Route này có vai trò như một backup route khi không còn route đến network 210.210.210.0/24.

    Kiểm tra lại bảng route của SaiGon, ta sẽ thấy hai default route xuất hiện, nhưng chỉ có route đến network 210.210.210/24 được chọn cho “Gateway of last resort”:

    SaiGon#show ip route

    Gateway of last resort is 10.0.0.1 to network 210.210.210.0

    B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:52
    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:51
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    12.0.0.0/24 is subnetted, 1 subnets
    B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:20
    C 192.168.1.0/24 is directly connected, Loopback1
    S* 0.0.0.0/0 [220/0] via 172.16.0.1
    Khi reset liên kết BGP với neighbor 10.0.0.1, router SaiGon sẽ chọn network 0.0.0.0/0 cho default route. Khi liên kết BGP với neighbor 10.0.0.1 được thiết lập thành công, router SaiGon sẽ chọn network 210.210.210.0/24 cho default route.

    SaiGon#clear ip bgp 10.0.0.1
    SaiGon#show ip route

    Gateway of last resort is 172.16.0.1 to network 0.0.0.0

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
    C 172.16.0.0/30 is directly connected, Serial0/1
    B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:08:10
    10.0.0.0/30 is subnetted, 1 subnets
    C 10.0.0.0 is directly connected, Serial0/0
    C 192.168.0.0/24 is directly connected, Loopback0
    C 192.168.1.0/24 is directly connected, Loopback1
    S* 0.0.0.0/0 [220/0] via 172.16.0.1

    4. Cấu hình
    SaiGon#show running-config
    Building configuration...

    Current configuration:
    !
    version 11.3
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname SaiGon
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 192.168.0.1 255.255.255.0
    !
    interface Loopback1
    ip address 192.168.1.1 255.255.255.0
    !
    interface Serial0/0
    ip address 10.0.0.2 255.255.255.252
    no ip mroute-cache
    no fair-queue
    clockrate 64000
    !
    interface Serial0/1
    ip address 172.16.0.2 255.255.255.252
    !
    router bgp 100
    network 192.168.0.0
    network 192.168.1.0
    neighbor 10.0.0.1 remote-as 200
    neighbor 10.0.0.1 distribute-list 1 out
    neighbor 172.16.0.1 remote-as 300
    neighbor 172.16.0.1 distribute-list 1 out
    !
    ip classless
    ip default-network 210.210.210.0
    ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
    !
    access-list 1 permit 192.168.0.0 0.0.1.255
    !
    line con 0
    logging synchronous
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    no scheduler allocate
    end

    -------------------------------------------------------------------------------

    ISP1#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname ISP1
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 12.0.1.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Loopback100
    ip address 210.210.210.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Serial0
    ip address 10.0.0.1 255.255.255.252
    no ip directed-broadcast
    no ip mroute-cache
    no fair-queue
    !
    router bgp 200
    network 12.0.1.0 mask 255.255.255.0
    network 210.210.210.0
    neighbor 10.0.0.2 remote-as 100
    !
    ip classless
    no ip http server
    !
    line con 0
    exec-timeout 0 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    end

    -------------------------------------------------------------------------------

    ISP2#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.1
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname ISP2
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 172.16.1.1 255.255.255.0
    !
    interface Serial1
    ip address 172.16.0.1 255.255.255.252
    clockrate 64000
    !
    router bgp 300
    network 172.16.1.0 mask 255.255.255.0
    neighbor 172.16.0.2 remote-as 100
    !
    ip classless
    no ip http server
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    end

  • #2
    up lại mô hình mạng đi, link die rồi nhìn vô cấu hình không hiểu gì hết

    Comment


    • #3
      Hi bác klepski, bác up lại hình sơ đồ mạng giúp em được không, em đang rất cần tìm hiểu về giao thức này...

      Comment


      • #4
        Originally posted by laptopbaohuy806
        hay lắm.
        cảm ơn bạn đã chia sẻ bài viết hay.
        Thôi đừng spam lấy số nữa, hình có đâu mà biết hay dở?

        Comment


        • #5
          bác mod nào sửa lại link ảnh bài này giúp anh em được không ạ :(
          em xin chân thành cảm ơn :(

          Comment

          Working...
          X