• 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 NAT

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

  • BGP with NAT

    Cấu hình BGP với NAT

    1. Mục tiêu
    Trong bài lab này, chúng ta sẽ cấu hình BGP với NAT

    2. Hoàn cảnh

    Mạng của Công ty XYZ ở Sài Gòn, thuộc AS64512, sử dụng giao thức định tuyến OSPF để định tuyến giữa các internal router SaiGon1 và SaiGon2. ISP nối với SaiGon1 dùng eBGP, đồng thời SaiGon1 cũng được cấu hình NAT trước khi đến ISP

    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 OSPF giữa router SaiGon1 và SaiGon2:

    SaiGon1(config)#router ospf 1
    SaiGon1(config-router)#network 172.16.1.1 0.0.0.0 area 0
    SaiGon1(config-router)#network 172.16.64.1 0.0.0.0 area 0

    SaiGon2(config)#router ospf 1
    SaiGon2(config-router)#network 172.16.1.2 0.0.0.0 area 0
    SaiGon2(config-router)#network 172.16.32.1 0.0.0.0 area 0

    Kiểm tra adjacency giữa SaiGon1 và SaiGon2, chẩn đoán lỗi nếu có. Dùng lệnh show ip ospf neighbor và show ip ospf interface

    SaiGon1#show ip ospf neighbor

    Neighbor ID Pri State Dead Time Address Interface
    172.16.32.1 1 FULL/ - 00:00:30 172.16.1.2 Serial0/1

    SaiGon1#show ip ospf interface serial 0/1
    Serial0/1 is up, line protocol is up
    Internet Address 172.16.1.1/24, Area 0
    Process ID 1, Router ID 172.16.64.1, Network Type POINT_TO_POINT, Cost: 64
    Transmit Delay is 1 sec, State POINT_TO_POINT,
    Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:09
    Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 172.16.32.1
    Suppress hello for 0 neighbor(s)

    c. Bước 3
    Cấu hình eBGP giữa ISP và SaiGon1:

    SaiGon1(config)#router bgp 64512
    SaiGon1(config-router)#neighbor 192.168.1.5 remote-as 200

    ISP(config)#router bgp 200
    ISP(config-router)#network 210.210.210.0 mask 255.255.255.0
    ISP(config-router)#neighbor 192.168.1.6 remote-as 64512

    Ở đây, ta lưu ý là SaiGon1 không quảng bá bất cứ network nào bên trong nó cho ISP (không có câu lệnh network).
    Kiểm tra kết nối BGP giữa SaiGon1 và ISP. Dùng lệnh clear ip bgp * để thiết lập lại kết nối, sau đó vài phút, dùng lệnh show ip bgp để kiểm tra:

    SaiGon1#show ip bgp
    BGP table version is 2, local router ID is 172.16.64.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
    *> 210.210.210.0 192.168.1.5 0 0 200 i

    SaiGon1#show ip bgp summary
    BGP table version is 2, main routing table version 2
    1 network entries (1/3 paths) using 208 bytes of memory
    1 BGP path attribute entries using 108 bytes of memory
    0 BGP route-map cache entries using 0 bytes of memory
    0 BGP filter-list cache entries using 0 bytes of memory

    Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    192.168.1.5 4 200 33 27 2 0 0 00:06:36 1

    Kiểm tra bảng định tuyến:
    SaiGon1#show ip route

    Gateway of last resort is not set

    B 210.210.210.0/24 [20/0] via 192.168.1.5, 00:07:12
    172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
    O 172.16.32.1/32 [110/65] via 172.16.1.2, 00:07:44, Serial0/1
    C 172.16.1.0/24 is directly connected, Serial0/1
    C 172.16.64.0/24 is directly connected, Loopback0
    192.168.1.0/30 is subnetted, 1 subnets
    C 192.168.1.4 is directly connected, Serial0/0

    Tại SaiGon1, dùng extend ping đến 210.210.210.1 với địa chỉ source 172.16.64.1. Ping không thành công, do packet đi từ SaiGon1 đến ISP nhưng ISP không có route đến network 172.16.64.0 để quay trả lời.

    SaiGon1#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: 172.16.64.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 0 percent (0/5)

    d. Bước 4
    Cấu hình NAT trên SaiGon1, đổi địa chỉ private 172.16.0.0 thành địa chỉ public có thể ra được Internet (đến ISP).

    SaiGon1(config)#interface s0/0
    SaiGon1(config-if)#ip nat outside
    SaiGon1(config-if)#interface lo0
    SaiGon1(config-if)#ip nat inside
    SaiGon1(config-if)#interface s0/1
    SaiGon1(config-if)#ip nat inside

    Cấu hình NAT pool và NAT translation trên SaiGon1:

    SaiGon1(config)#access-list 1 permit 172.16.0.0 0.0.255.255
    SaiGon1(config)#ip nat pool NAT_POOL 66.122.33.98 66.122.33.126 netmask 255.255.255.224
    SaiGon1(config)#ip nat inside source list 1 pool NAT_POOL overload

    Ở đây, ta sử dụng range IP public là 66.122.33.96/27 để cho các host ra Internet.
    Đưa mạng 66.122.33.96/27 vào BGP:

    SaiGon1(config)#router bgp 64512
    SaiGon1(config-router)#network 66.122.33.96 mask 255.255.255.224

    Ta sử dụng interface loopback 100 với địa chỉ IP 66.122.33.97 để BGP quảng bá network 66.122.33.96/27. Chú ý rằng BGP chỉ quảng bá một network khi network đó là connected hoặc static hoặc từ một dynamic routing protocol được redistribute vào BGP.

    SaiGon1(config)#interface lo100
    SaiGon1(config-if)#ip address 66.122.33.97 255.255.255.224

    Kiểm tra cấu hình BGP:

    SaiGon1#show ip bgp
    BGP table version is 5, local router ID is 172.16.64.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
    *> 66.122.33.96/27 0.0.0.0 0 32768 i
    *> 210.210.210.0 192.168.1.5 0 0 200 i

    Dùng extend ping 210.210.210.1 từ private address 172.16.64.1 của SaiGon1:

    SaiGon1#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: 172.16.64.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 = 32/32/32 ms


    Từ SaiGon2 ping thử đến 210.210.210.1

    SaiGon2#debug ip packet
    SaiGon2#ping 210.210.210.1
    Sending 5, 100-byte ICMP Echos to 210.210.210.1, timeout is 2 seconds:
    .....
    Success rate is 0 percent (0/5)

    01:44:13: IP: s=172.16.32.1 (local), d=210.210.210.1, len 100, unroutable.
    01:44:15: IP: s=172.16.32.1 (local), d=210.210.210.1, len 100, unroutable
    01:44:17: IP: s=172.16.32.1 (local), d=210.210.210.1, len 100, unroutable.
    01:44:19: IP: s=172.16.32.1 (local), d=210.210.210.1, len 100, unroutable.
    01:44:21: IP: s=172.16.32.1 (local), d=210.210.210.1, len 100, unroutable.

    SaiGon2 chưa có route đến network 210.210.210.0 nên lệnh ping ở trên cho kết quả không thành công. Ta sẽ cấu hình default route trên SaiGon1 và cho phép nó quảng bá trên miền OSPF:

    SaiGon1(config)#router ospf 1
    SaiGon1(config-router)#defaul-information originate always metric 2500 metric-type 1
    SaiGon1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.5

    Kiểm tra routing table tại SaiGon2:
    SaiGon2#show ip route

    Gateway of last resort is 172.16.1.1 to network 0.0.0.0

    172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
    C 172.16.32.0/24 is directly connected, Loopback0
    C 172.16.1.0/24 is directly connected, Serial1
    O 172.16.64.1/32 [110/65] via 172.16.1.1, 00:08:01, Serial1
    O*E1 0.0.0.0/0 [110/2564] via 172.16.1.1, 00:07:09, Serial1

    Default đã xuất hiện trên SaiGon2. Tại SaiGon2 ping 210.210.210.1 để kiểm tra kết nối, đồng thời tại SaiGon1 debug ip nat để kiểm tra quá trình NAT:

    SaiGon2#ping 210.210.210.1

    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 = 64/70/84 ms

    SaiGon1#debug ip nat
    IP NAT debugging is on
    SaiGon1#
    00:45:00: NAT: s=172.16.1.2->66.122.33.98, d=210.210.210.1 [25]
    00:45:00: NAT*: s=210.210.210.1, d=66.122.33.98->172.16.1.2 [25]
    00:45:00: NAT: s=172.16.1.2->66.122.33.98, d=210.210.210.1 [26]
    00:45:00: NAT*: s=210.210.210.1, d=66.122.33.98->172.16.1.2 [26]
    00:45:00: NAT: s=172.16.1.2->66.122.33.98, d=210.210.210.1 [27]
    00:45:00: NAT*: s=210.210.210.1, d=66.122.33.98->172.16.1.2 [27]
    00:45:00: NAT: s=172.16.1.2->66.122.33.98, d=210.210.210.1 [28]
    00:45:00: NAT*: s=210.210.210.1, d=66.122.33.98->172.16.1.2 [28]
    00:45:00: NAT: s=172.16.1.2->66.122.33.98, d=210.210.210.1 [29]
    00:45:00: NAT*: s=210.210.210.1, d=66.122.33.98->172.16.1.2 [29]

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

    Current configuration:
    !
    version 11.3
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname SaiGon1
    !
    ip nat pool NAT_POOL 66.122.33.98 66.122.33.126 netmask 255.255.255.224
    ip nat inside source list 1 pool NAT_POOL overload
    !
    interface Loopback0
    ip address 172.16.64.1 255.255.255.0
    ip nat inside
    !
    interface Loopback100
    ip address 66.122.33.97 255.255.255.224
    !
    interface Serial0/0
    ip address 192.168.1.6 255.255.255.252
    ip nat outside
    no ip mroute-cache
    !
    interface Serial0/1
    ip address 172.16.1.1 255.255.255.0
    ip nat inside
    !
    router ospf 1
    network 172.16.1.1 0.0.0.0 area 0
    network 172.16.64.1 0.0.0.0 area 0
    default-information originate always metric 2500 metric-type 1
    !
    router bgp 64512
    network 66.122.33.96 mask 255.255.255.224
    neighbor 192.168.1.5 remote-as 200
    !
    ip classless
    ip route 0.0.0.0 0.0.0.0 192.168.1.5
    ip route 66.122.33.96 255.255.255.224 Null0 230
    !
    access-list 1 permit 172.16.0.0 0.0.255.255
    !
    line con 0
    logging synchronous
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    end

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

    SaiGon2#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname SaiGon2
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Loopback0
    ip address 172.16.32.1 255.255.255.0
    no ip directed-broadcast
    !
    interface Ethernet0
    no ip address
    no ip directed-broadcast
    !
    interface Serial1
    ip address 172.16.1.2 255.255.255.0
    no ip directed-broadcast
    clockrate 64000
    !
    router ospf 1
    network 172.16.1.2 0.0.0.0 area 0
    network 172.16.32.1 0.0.0.0 area 0
    !
    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 : 799 bytes
    !
    version 12.2
    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 210.210.210.1 255.255.255.0
    !
    interface Serial0
    ip address 192.168.1.5 255.255.255.252
    no fair-queue
    clockrate 64000
    !
    router bgp 200
    no synchronization
    bgp log-neighbor-changes
    network 210.210.210.0
    neighbor 192.168.1.6 remote-as 64512
    !
    ip classless
    ip http server
    !
    line con 0
    logging synchronous
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    end

  • #2
    Có thấy cái sơ đò nào đâu?

    Comment

    Working...
    X