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

Distribute List and Passive Interface

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

  • Distribute List and Passive Interface

    DISTRIBUTE-LIST AND PASSIVE-INTERFACE

    1. Mục tiêu:
    Sử dụng các kỹ thuật distribute-list, passive interface, default route và route redistribution.
    Đối với các internal và external route trong OSPF, lệnh distribute-list in chỉ lọc các route được cài vào trong routing table của cùng một routing process; lệnh distribute-list out chỉ lọc được các external route (những route được học từ các routing protocol khác).
    Lệnh passive-interface có khả năng chặn các update được gửi ra một interface. Đối với các protcol cần thiết lập adjacency như OSPF, passive-interface sẽ ngăn chặn sự thiết lập mối quan hệ này.

    2. Bối cảnh.



    Công ty International Travel Agency (ITA) sử dụng OSPF để định tuyến động và cần phải thoả các điều kiện:
     Một kết nối 19.2 kbps được dùng kết nối Singapore và Auckland . Do đó, cần phải hạn chế thông tin định tuyến kết nối này.
     Một LAN 192.168.5.0/24 kết nối trực tiếp vào SanJose3 là 1 stub network và gần bão hoà. Để giảm traffic trên LAN 192.168.5.0/24, các thông tin định tuyến cũng bị hạn chế vào.
     ITA có một chi nhánh nghiên cứu ở Singapore.Các kỹ sư R&D ở trên 192.168.232.0/24 và toàn bộ mạng của công ty không được thấy và truy xuất vào mạng này. Tuy nhiên, các nhà quản lý R&D ở trên 192.168.236.0/24 cần truy xuất vào mạng trên.

    3. Thực hiện.

    Bước 1:
    Xây dựng và cấu hình mạng theo sơ đồ nhưng chưa cấu hình OSPF. Dùng các lệnh CDP và ping để kiểm tra các kết nối trực tiếp với nhau.

    Bước 2:
    Trên SanJose3, cấu hình OSPF như sau:

    SanJose3(config)#router ospf 1
    SanJose3(config-router)#network 192.168.224.0 0.0.0.3 area 0
    SanJose3(config-router)#network 192.168.5.0 0.0.0.255 area 0
    SanJose3(config-router)#passive-interface e0

    NOTE:
    Lệnh passive-interface để ngăn không cho thông tin định tuyến chạy trong LAN 192.168.5.0/24


    Bước 3:
    Cấu hình OSPF trên Singapore để Singapore có thể trao đổi update với SanJose3:

    Singapore(config)#router ospf 1
    Singapore(config-router)#network 192.168.224.0 0.0.0.3 area 0
    Singapore(config-router)#passive-interface s0
    Singapore(config-router)#passive-interface e1

    NOTE:
    Lệnh passive-interface để ngăn không cho thông tin định tuyến quảng bá ra ngoài 2 network 192.168.240.0/30 (s0) và network 192.168.236.0/24 (e1)



    Kiểm tra giao thức định tuyến OSPF bằng lệnh:


    Singapore#show ip ospf neighbor

    Neighbor ID Pri State Dead Time Address Interface
    192.168.224.1 1 FULL/ - 00:00:34 192.168.224.1 Serial1


    Bước 4:
    Cấu hình OSPF để Singapore quảng bá các mạng LAN:

    Singapore(config)#router ospf 1
    Singapore(config-router)#network 192.168.232.0 0.0.0.255 area 0

    Kiểm tra routing table trên hai router SanJose3 và Singapore bằng lệnh:

    Singapore#show ip route

    Gateway of last resort is not set

    192.168.224.0/30 is subnetted, 1 subnets
    C 192.168.224.0 is directly connected, Serial1
    192.168.240.0/30 is subnetted, 1 subnets
    C 192.168.240.0 is directly connected, Serial0
    O 192.168.5.0/24 [110/74] via 192.168.224.1, 00:05:52, Serial1
    C 192.168.232.0/24 is directly connected, Ethernet0
    C 192.168.236.0/24 is directly connected, Ethernet1


    SanJose3#show ip route

    Gateway of last resort is not set

    192.168.224.0/30 is subnetted, 1 subnets
    C 192.168.224.0 is directly connected, Serial1
    C 192.168.5.0/24 is directly connected, Ethernet0
    O 192.168.232.0/24 [110/74] via 192.168.224.2, 00:05:19, Serial1

    Bước 5:
    Hiện tại, Singapore còn hai mạng 192.168.240.0/30 và 192.168.236.0/24 chưa được quảng bá và cần thoả hai điều kiện:
    1. Các LAN trừ 192.168.232.0/24 không được thấy 192.168.236.0/24.
    2. Thông tin định tuyến không được lưu thông trên kết nối giữa Singapore và Auckland để tiết kiệm băng thông.

    Đối với điều kiện 1, do hai mạng 192.168.232/24 và 192.168.236.0/24 cùng nối vào Singapore, nên chúng có thể thông nhau một cách dễ dàng. Để ngăn các LAN khác của công ty không thấy 192.168.236.0/24 thì ta không được quảng cáo nó vào OSPF domain hoặc nếu có quảng cáo thì phải ngăn chặn nó được cài đặt vào trong bảng định tuyến. Do đó, ta có thể dùng lệnh distribute-list in hay distribute-list out

    Kết hợp với điều trên, để quảng bá 192.168.240.0/24 có thể filter được mạng 192.168.236.0/24 quảng bá trên mạng, ta có thể dùng hai cách:

    a. Quảng bá 192.168.240.0/24 như internal route bằng lệnh network và dùng passive-interface để ngăn thông tin định tuyến chạy trên link.
    b. Quảng bá 192.168.236.0/24, 192.168.240.0/30 như external route bằng lệnh redistribute connected và dùng distribute-list out ở Singapore để ngăn chặn sự quảng bá của 192.168.236.0/24.

    Ở đây, ta sử dụng cách b. Trước hết, ta quảng bá 192.168.236.0/24 ở Singapore như là một external route:

    Singapore(config)#router ospf 1
    Singapore(config-router)#redistribute connected subnets

    Ta có thể kiểm tra hai network 192.168.240.0/30 và 192.168.236.0/24 được redistribute vào OSPF bằng lệnh:

    SanJose3#show ip ospf database

    OSPF Router with ID (192.168.224.1) (Process ID 1)


    Router Link States (Area 0)

    Link ID ADV Router Age Seq# Checksum Link count
    192.168.224.1 192.168.224.1 858 0x80000003 0xBBDD 3
    192.168.236.1 192.168.236.1 103 0x80000007 0x1A1 3

    Type-5 AS External Link States

    Link ID ADV Router Age Seq# Checksum Tag
    192.168.236.0 192.168.236.1 103 0x80000001 0x7B77 0
    192.168.240.0 192.168.236.1 103 0x80000001 0x3DB4 0

    Kiểm tra bảng định tuyến của SanJose3:

    SanJose3#show ip route

    Gateway of last resort is not set

    192.168.224.0/30 is subnetted, 1 subnets
    C 192.168.224.0 is directly connected, Serial1
    192.168.240.0/30 is subnetted, 1 subnets
    O E2 192.168.240.0 [110/20] via 192.168.224.2, 00:00:14, Serial1
    C 192.168.5.0/24 is directly connected, Ethernet0
    O 192.168.232.0/24 [110/74] via 192.168.224.2, 00:00:14, Serial1
    O E2 192.168.236.0/24 [110/20] via 192.168.224.2, 00:00:14, Serial1


    Sử dung distribute-list để cấm không cho các LAN ở SanJose3 thấy mạng 192.168.236.0/24:

    Singapore(config)#access-list 1 deny 192.168.236.0
    Singapore(config)#access-list 1 permit any

    Singapore(config)#router ospf 1
    Singapore(config-router)#distribute-list 1 out

    Kiểm tra:

    SanJose3#show ip route

    Gateway of last resort is not set

    192.168.224.0/30 is subnetted, 1 subnets
    C 192.168.224.0 is directly connected, Serial1
    192.168.240.0/30 is subnetted, 1 subnets
    O E2 192.168.240.0 [110/20] via 192.168.224.2, 00:06:28, Serial1
    C 192.168.5.0/24 is directly connected, Ethernet0
    O 192.168.232.0/24 [110/74] via 192.168.224.2, 00:06:28, Serial1

    Ta thấy, Sanjose3 không còn thấy network 192.168.236.0 nữa, do Singapore đã lọc route này (distribute-list 1 out) trước khi quảng bá (redistribute).



    Kiểm tra bảng định tuyến tại SanJose3:

    Singapore#show ip protocols
    Routing Protocol is "ospf 1"
    Invalid after 0 seconds, hold down 0, flushed after 0
    Outgoing update filter list for all interfaces is 1
    Incoming update filter list for all interfaces is
    Redistributing: connected, ospf 1
    Routing for Networks:
    192.168.224.0/30
    192.168.232.0
    Passive Interface(s):
    Loopback0
    Serial0
    Routing Information Sources:
    Gateway Distance Last Update
    192.168.224.1 110 00:10:35
    Distance: (default is 110)


    SanJose3#show ip route

    C 192.168.5.0/24 is directly connected, Ethernetwork0
    O 192.168.232.0/24 [110/74] via 192.168.224.2, 00:03:06, Serial0
    192.168.224.0/30 is subnetworkted, 1 subnetworks
    C 192.168.224.0 is directly connected, Serial0
    192.168.240.0/30 is subnetworkted, 1 subnetworks
    O E2 192.168.240.0 [110/20] via 192.168.224.2, 00:03:07, Serial0

    Ta thấy SanJose3 chỉ học được route 192.168.240.0/30 và không có 192.168.236.0/24 do route này đã bị distribute-list không cho phép quảng bá.

    Bước 6:

    Auckland là 1 stub network chỉ có một ngõ ra. Do đó, cấu hình một ngõ ra mặc định cho nó:
    Auckland (config)#ip route 0.0.0.0 0.0.0.0 192.168.240.2 210

    NOTE:
    Số 210 ở cuối lệnh là AD mà ta đặt cho route này. Nếu không có số này, mặc định, router sẽ hiểu là 1 (static route).
    Trong bài này, bạn có thể không cần cấu hình AD cho route này, vì nó chỉ có một đường duy nhất đến Singapore.


    Từ Auckland ping đến 192.168.5.1 thành công do mặc định địa chỉ source của Auckland là 192.168.240.1

    Auckland#debug ip packet
    IP packet debugging is on

    Auckland#ping 192.168.5.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 68/68/68 ms
    Auckland#
    00:40:06: IP: s=192.168.240.1 (local), d=192.168.5.1 (Serial0), len 100, sending
    00:40:06: IP: s=192.168.5.1 (Serial0), d=192.168.240.1 (Serial0), len 100, rcvd
    00:40:07: IP: s=192.168.240.1 (local), d=192.168.5.1 (Serial0), len 100, sending
    00:40:07: IP: s=192.168.5.1 (Serial0), d=192.168.240.1 (Serial0), len 100, rcvd
    00:40:07: IP: s=192.168.240.1 (local), d=192.168.5.1 (Serial0), len 100, sending
    00:40:07: IP: s=192.168.5.1 (Serial0), d=192.168.240.1 (Serial0), len 100, rcvd

    Sau đó, dùng extended ping:

    Auckland #ping
    Protocol [ip]:
    Target IP address: 192.168.5.1
    Repeat count [5]:
    Datagram size [100]:
    Timeout in seconds [2]:
    Extended commands [n]: y
    Source address or interface: 192.168.248.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 192.168.5.1, timeout is 2 seconds:
    .....
    Success rate is 0 percent (0/5)

    Ở SanJose3, ta có:

    SanJose3#debug ip packet
    IP packet debugging is on
    SanJose3#
    00:41:03: IP: s=192.168.5.1 (local), d=192.168.248.1, len 100, unroutable
    00:41:05: IP: s=192.168.248.1 (Serial1), d=192.168.5.1, len 100, rcvd 4
    00:41:05: IP: s=192.168.5.1 (local), d=192.168.248.1, len 100, unroutable
    Kết quả không thành công vì SanJose3 không thấy 192.168.248.0/24.

    Bước 7:

    Do không có thông tin định tuyến chạy trên kết nối giữa Singapore và Auckland, ta không có cách nào để Auckland quảng cáo 192.168.248.0/24 cho Singapore. Vì vậy, ta sử dụng static route để cho Singapore thấy 192.168.248.0/24.

    Singapore(config)#ip route 192.168.248.0 255.255.255.0 192.168.240.1 210

    Để Singapore quảng cáo static route cho SanJose3, ta dùng phương pháp redistribution:

    Singapore(config)#router ospf 1
    Singapore(config-router)#redistribute static metric 100

    Kiểm tra bảng định tuyến trên SanJose3

    SanJose3#show ip route

    Gateway of last resort is not set

    192.168.224.0/30 is subnetted, 1 subnets
    C 192.168.224.0 is directly connected, Serial1
    192.168.240.0/30 is subnetted, 1 subnets
    O E2 192.168.240.0 [110/20] via 192.168.224.2, 00:22:03, Serial1
    C 192.168.5.0/24 is directly connected, Ethernet0
    O 192.168.232.0/24 [110/74] via 192.168.224.2, 00:22:03, Serial1
    O E2 192.168.248.0/24 [110/100] via 192.168.224.2, 00:00:14, Serial1

    Sử dụng extended ping ở Auckland để kiểm tra đường đi từ Auckland đến 192.168.5.0/24 với địa chỉ source là (192.168.248.1) như đã làm ở bước 6.


    Bước 8:

    Ta thấy, lúc này SanJose3 không thể đến được network 192.168.236.0/24, nhưng Auckland thì vẫn có thể đến được do Auckland có một default route đến Singapore.

    Auckland#ping 192.168.236.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.236.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 36/44/60 ms


    SanJose3#ping 192.168.236.1

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

    Với cấu hình như trên ta đã làm cho các router khác không thấy được network 192.168.236.0/24 trong routing table.
    Do yêu cầu về bảo mật, ta chỉ mong muốn network 192.168.232.0/24 đến được network 192.168.236.0/24, nên ta chỉ có thể đặt 1 access-list trên Singapore để thực hiện việc này.

    Singapore(config)#access-list 101 permit ip 192.168.232.0 0.0.0.255 any
    Singapore(config)#access-list 101 deny ip any any

    Singapore(config)#interface e1
    Singapore(config-if)#ip access-group 101 out

    4. Phần làm thêm :

    Ở trên, ta đã có:

    access-list 1 deny 192.168.236.0
    access-list 1 permit any


    Ta thực hiện :

    Singapore(config)#router ospf 1
    Singapore(config-router)#no distribute-list 1 out
    Singapore(config-router)#distribute-list 1 out connected

    NOTE:
    Lệnh distribute-list 1 out sẽ filter tất cả các route của các routing protocol được redistribute vào OSPF theo ACL 1.
    Lệnh distribute-list 1 out connected sẽ chỉ filter các route connected vào OSPF theo ACL 1. Các route của các routing protocol khác, nếu được redistribute vào OSPF sẽ không bị ảnh hưởng bởi ACL 1


    Các lệnh trên sẽ cho ra kết quả giống như phần làm trên. Phần làm thêm chỉ giúp các bạn hiểu hơn về các tham số theo sau lệnh distribute-list. Connected chỉ là một trong các tham số đó, bạn có thể test thêm về tham số static, rip, v.v… Các bạn có thể sửa lại topology để kiểm chứng cho rõ hơn.


    5. Cấu hình :

    Auckland#show run
    Building configuration...

    Current configuration:
    !
    version 12.1
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname Auckland
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Ethernet0
    ip address 192.168.248.1 255.255.255.0
    no keepalive
    !
    interface Serial0
    ip address 192.168.240.1 255.255.255.252
    !
    ip classless
    ip route 0.0.0.0 0.0.0.0 192.168.240.2 210
    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

    Singapore#show run
    Building configuration...

    Current configuration:
    !
    version 12.1
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname Singapore
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Ethernet0
    ip address 192.168.232.1 255.255.255.0
    no keepalive
    !
    interface Ethernet1
    ip address 192.168.236.1 255.255.255.0
    no keepalive
    ip access-group 101 out
    !
    interface Serial0
    ip address 192.168.240.2 255.255.255.252
    clockrate 64000
    !
    interface Serial1
    ip address 192.168.224.2 255.255.255.252
    !
    router ospf 1
    redistribute connected subnets
    redistribute static metric 100
    passive-interface Ethernet1
    passive-interface Serial0
    network 192.168.224.0 0.0.0.3 area 0
    network 192.168.232.0 0.0.0.255 area 0
    distribute-list 1 out
    !
    ip classless
    ip route 192.168.248.0 255.255.255.0 192.168.240.1 210
    !
    access-list 1 deny 192.168.236.0
    access-list 1 permit any
    access-list 101 permit ip 192.168.232.0 0.0.0.255 any
    access-list 101 deny ip any any
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    scheduler interval 2000
    end

    SanJose3#show run
    Building configuration...

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname SanJose3
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Ethernet0
    ip address 192.168.5.1 255.255.255.0
    no ip directed-broadcast
    no keepalive
    !
    interface Serial1
    ip address 192.168.224.1 255.255.255.252
    no ip directed-broadcast
    clockrate 64000
    !
    router ospf 1
    passive-interface Ethernet0
    network 192.168.5.0 0.0.0.255 area 0
    network 192.168.224.0 0.0.0.3 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

  • #2
    RE: Distribute List and Passive Interface

    lệnh passive interface trong OSPF sẽ ngăn không cho các hello-packets được gửi trên interface E0.

    Xem thêm ý nghĩa của passive-interface ở link này

    Đặng Quang Minh, CCIEx2#11897 (Enterprise Infrastructure, Wireless), DEVNET, CCSI#31417

    Email : dangquangminh@vnpro.org
    https://www.facebook.com/groups/vietprofessional/

    Comment

    Working...
    X