• 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 with AS_Path

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

  • BGP with AS_Path

    THUỘC TÍNH AS-PATH TRONG BGP
    1. Mục tiêu
    Trong bài lab này, chúng ta sẽ cấu hình BGP cấm các private AS number được quảng bá ra mạng bên ngoài. Chúng ta cũng sẽ sử dụng thuộc tính AS-PATH để lọc các route BGP dựa vào source AS number

    2. Hoàn cảnh


    Mạng của Công ty ABC ở Sài Gòn, được ISP cung cấp AS number 300. ISP sử dụng BGP để trao đổi thông tin định tuyến với một số mạng khách hàng khác. Các mạng khách hàng này đưọc cung cấp AS number nằm trong phạm vi private, ví dụ như AS 65000. Vấn đề đặt ra là cần phải cấu hình ISP loại bỏ các private AS number nằm trong các thông tin AS-PATH từ các router khách hàng, như trong sơ đồ là router CanTho. Thêm vào đó, ISP cũng ngăn không cho mạng khách hàng nhận được các thông tin định tuyến từ công ty ABC thuộc AS100. Công việc này có thể thực hiện được bằng cách sử dụng thuộc tính AS-PATH.

    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.

    b. Bước 2
    Cấu hình định tuyến BGP cho các router:
    SaiGon(config)#router bgp 100
    SaiGon(config-router)#network 201.0.0.0
    SaiGon(config-router)#neighbor 192.168.1.6 remote-as 300

    SaiGon(config)#router bgp 65000
    SaiGon(config-router)#network 203.0.0.0
    SaiGon(config-router)#neighbor 172.24.1.17 remote-as 300

    ISP(config)#router bgp 300
    ISP(config-router)#network 202.0.0.0
    ISP(config-router)#neighbor 172.24.1.18 remote-as 65000
    ISP(config-router)#neighbor 192.168.1.5 remote-as 100

    Kiểm tra lại các router đã thiết lập được quan hệ neighbor bằng lệnh show ip bgp neighbors trên mỗi router

    c. Bước 3
    Kiểm tra bảng định tuyến từ router SaiGon bằng lệnh show ip route. Router SaiGon phải có route đến cả hai mạng 202.0.0.0 và 203.0.0.0
    Router SaiGon không thể ping được network 203.0.0.0/24 bằng standard ping (bởi khi đó, nó sẽ lấy địa chỉ source là 192.168.1.5, router CanTho gửi packet trả về sẽ không route được do không có route 192.168.1.0/24 trong bảng định tuyến). Nhưng router SaiGon lại có thể ping được network 203.0.0.0/24 bắng extend ping với địa chỉ source là 201.0.0.1:

    SaiGon#ping 203.0.0.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 203.0.0.1, timeout is 2 seconds:
    .....
    Success rate is 0 percent (0/5)

    CanTho#debug ip packet
    IP packet debugging is on
    CanTho#
    00:20:18: IP: s=192.168.1.5 (Serial0), d=203.0.0.1, len 100, rcvd 4
    00:20:18: IP: s=203.0.0.1 (local), d=192.168.1.5, len 100, unroutable
    CanTho#
    00:20:19: IP: s=172.24.1.17 (Serial0), d=172.24.1.18 (Serial0), len 118, rcvd 3
    00:20:19: IP: s=172.24.1.18 (local), d=172.24.1.17 (Serial0), len 40, sending
    00:20:20: IP: s=192.168.1.5 (Serial0), d=203.0.0.1, len 100, rcvd 4
    00:20:20: IP: s=203.0.0.1 (local), d=192.168.1.5, len 100, unroutable


    SaiGon#ping
    Protocol [ip]:
    Target IP address: 203.0.0.1
    Repeat count [5]:
    Datagram size [100]:
    Timeout in seconds [2]:
    Extended commands [n]: y
    Source address or interface: 201.0.0.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 203.0.0.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 64/72/104 ms

    Kiểm tra bảng BGP của router SaiGon bằng lệnh show ip bgp. Chú ý AS-PATH cho mạng 203.0.0.0, AS65000 sẽ nằm trong path đến network 203.0.0.0:

    SaiGon#show ip bgp
    BGP table version is 4, local router ID is 201.0.0.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
    *> 201.0.0.0 0.0.0.0 0 32768 i
    *> 202.0.0.0 192.168.1.6 0 0 300 i
    *> 203.0.0.0 192.168.1.6 0 300 65000 i


    ISP#show ip bgp
    BGP table version is 4, local router ID is 202.0.0.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
    *> 201.0.0.0 192.168.1.5 0 0 100 i
    *> 202.0.0.0 0.0.0.0 0 32768 i
    *> 203.0.0.0 172.24.1.18 0 0 65000 i

    Cấu hình ISP bỏ private AS number khỏi các BGP route trao đổi với router SaiGon. Ta thực hiện các lệnh sau:

    ISP(config)#router bgp 300
    ISP(config-router)#neighbor 192.168.1.5 remove-private-as

    Sau đó, ta thực hiện lệnh clear ip bgp * và chờ cho các router thiết lập lại các kết nối BGP. Sử dụng lệnh show ip bgp trên router SaiGon kiểm tra AS-PATH của route đến network 203.0.0.0/24

    SaiGon#show ip bgp
    BGP table version is 12, local router ID is 201.0.0.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
    *> 201.0.0.0 0.0.0.0 0 32768 i
    *> 202.0.0.0 192.168.1.6 0 0 300 i
    *> 203.0.0.0 192.168.1.6 0 300 i

    d. Bước 4
    Cuối cùng, ta sử dụng thuộc tính AS-PATH để lọc các route dựa vào origin của nó. Trong môi trường hoạt động phức hợp, thuộc tính này có thể được dùng để cấu hình các routing policy. Trong trường hợp này, ta sẽ cấu hình router ISP để nó không quảng bá các route từ AS 100 đến mạng của khách hàng tại router CanTho.
    Trước hết, ta cẩu hình một loại access list đặc biệt dùng để match các BGP route với thuộc tính AS-PATH được bắt đầu và kết thúc với AS number 100

    ISP(config)#ip as-path access-list 1 deny ^100$
    ISP(config)#ip as-path access-list 1 permit .*

    Câu lệnh đầu dùng kí tự ^ để biểu thị AS-PATH phải được bắu đầu bằng số 100, kí tự $ biểu thị AS-PATH cũng phải kết thúc bằng số 100. Lệnh này sẽ match tất cả các path được bắt nguồn từ AS 100, các path khác có thể bao gổm AS 100 trong AS-PATH sẽ không match list này.

    Câu lệnh thứ hai, .* sẽ match tất cả các giá trị của AS-PATH mà giá trị đó không deny bởi lệnh access list trước.

    Chúng ta sẽ apply access list đó như sau:

    ISP(config)#router bgp 300
    ISP(config-router)#neighbor 172.24.1.18 filter-list 1 out

    Từ khóa out biểu thị list này sẽ áp dụng cho các thông tin định tuyến gửi tới neighbor.
    Dùng lệnh clear ip bgp * để reset lại quá trình định tuyến BGP. Chờ một thời gian, sau đó kiểm tra bảng định tuyến của router ISP. Route đến network 201.0.0.0 sẽ nằm trong bảng định tuyến này. Kiểm tra bảng định tuyến của router CanTho, nó sẽ không có route đến network 210.0.0.0

    ISP#clear ip bgp *

    CanTho#show ip bgp
    BGP table version is 17, local router ID is 203.0.0.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
    *> 202.0.0.0 172.24.1.17 0 0 300 i
    *> 203.0.0.0 0.0.0.0 0 32768 i
    Trở lại router ISP kiểm tra lại quá trình lọc hoạt động chính xác, dùng lệnh show ip bgp regexp ^100$. Output của lệnh này sẽ cho thấy tất cả các match của access list ta đã cấu hình trên được dùng để lọc như thế nào

    ISP#show ip bgp regexp ^100$
    BGP table version is 4, local router ID is 202.0.0.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
    *> 201.0.0.0 192.168.1.5 0 0 100 i

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

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname CanTho
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 203.0.0.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Serial0
    ip address 172.24.1.18 255.255.255.252
    no ip directed-broadcast
    no ip mroute-cache
    !
    router bgp 65000
    network 203.0.0.0
    neighbor 172.24.1.17 remote-as 300
    !
    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

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

    ISP#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname ISP
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 202.0.0.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Serial0
    ip address 192.168.1.6 255.255.255.252
    no ip directed-broadcast
    !
    interface Serial1
    ip address 172.24.1.17 255.255.255.252
    no ip directed-broadcast
    clockrate 64000
    !
    router bgp 300
    network 202.0.0.0
    neighbor 172.24.1.18 remote-as 65000
    neighbor 172.24.1.18 filter-list 1 out
    neighbor 192.168.1.5 remote-as 100
    neighbor 192.168.1.5 remove-private-AS
    !
    ip classless
    no ip http server
    ip as-path access-list 1 deny ^100$
    ip as-path access-list 1 permit .*
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    end

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

    SaiGon#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.0
    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 201.0.0.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Serial0
    ip address 192.168.1.5 255.255.255.252
    no ip directed-broadcast
    clockrate 64000
    !
    router bgp 100
    network 201.0.0.0
    neighbor 192.168.1.6 remote-as 300
    !
    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
Working...
X