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

Tìm hiểu tính năng câu lệnh “ip classfull” – Bài 1

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

  • Tìm hiểu tính năng câu lệnh “ip classfull” – Bài 1


    1. Tổng quan cơ chế hoạt động của “ip classfull”.

    Nếu cơ chế “ip classfull” làm việc dựa trên Major Network (là mạng lớn chưa được chia nhỏ). Theo phương thức phân loại địa chỉ IP thì chúng ta có 3 dải địa chỉ IP chủ đạo thuộc các lớp mạng Class A, Class B, Class C.

    Dựa vào octet đầu tiên, ta có thể phân biệt các Major Network thuộc các lớp Class A , B , C của địa chỉ IP.
    + IP thuộc Major Network A sẽ dao động từ 1.0.0.0/8 tới 127.0.0.0/8
    + IP thuộc Major Network B sẽ dao động từ 128.0.0.0/16 tới 191.255.0.0/16
    + IP thuộc Major Network C sẽ dao động từ 192.0.0.0/24 tới 223.255.255.0/24

    Khi bật cơ chế “ip classfull”, Router sẽ bỏ qua default route mà chỉ sử dụng thông tin định tuyến các mạng cụ thể tương ứng với Major Network trong bảng định tuyến. Nếu Major Network không tồn tại, trong bảng định tuyến, Router lúc này mới sử dụng tới default route.

    2. Khảo sát cơ chế hoạt động của “ip classfull”.

    Cấu hình IP trên các VPC.

    VPC1.

    ip 172.16.1.2/24 172.16.1.1

    VPC2.

    ip 172.16.2.2/24 172.16.2.1

    VPC3.

    ip 172.16.3.2/24 172.16.3.1

    Cấu hình cơ bản trên R1.

    hostname R1

    interface e0/0

    ip address 192.168.12.1 255.255.255.0

    no shutdown

    exit

    interface e0/1

    ip address 172.16.1.1 255.255.255.0

    no shutdown

    exit

    line console 0

    logging synchronous

    exec-timeout 0 0

    exit

    line vty 0 4

    privilege level 15

    no login

    exit

    no ip domain-lookup



    Cấu hình cơ bản trên R2.

    hostname R2

    interface e0/0

    ip address 192.168.12.2 255.255.255.0

    no shutdown

    exit

    interface e0/1

    ip address 172.16.2.1 255.255.255.0

    no shutdown

    exit

    interface e0/2

    ip address 172.16.3.1 255.255.255.0

    no shutdown

    exit

    line console 0

    logging synchronous

    exec-timeout 0 0

    exit

    line vty 0 4

    privilege level 15

    no login

    exit

    no ip domain-lookup

    Cấu hình định tuyến tại R1 cho phép ping tới 172.16.2.0/24 và 172.16.3.0/24.

    ip route 0.0.0.0 0.0.0.0 192.168.12.2

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

    R1# show ip route

    Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP

    D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area

    N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

    E1 – OSPF external type 1, E2 – OSPF external type 2

    i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

    ia – IS-IS inter area, * – candidate default, U – per-user static route

    o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP

    + – replicated route, % – next hop override



    Gateway of last resort is 192.168.12.2 to network 0.0.0.0



    S* 0.0.0.0/0 [1/0] via 192.168.12.2

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks

    C 172.16.1.0/24 is directly connected, Ethernet0/1

    L 172.16.1.1/32 is directly connected, Ethernet0/1

    192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks

    C 192.168.12.0/24 is directly connected, Ethernet0/0

    L 192.168.12.1/32 is directly connected, Ethernet0/0

    R1#

    Bật cơ chế định tuyến “ip classless” tại R1, quá trình ping tới địa chỉ IP thuộc lớp mạng 172.16.3.0/24 diễn ra thành công vì gói tin được gửi theo default route trong bảng định tuyến của R1.

    R1(config)# ip classless

    S* 0.0.0.0/0 [1/0] via 192.168.12.2

    R1# ping 172.16.2.2

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:

    !!!!!

    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

    R1#

    R1# ping 172.16.3.2

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.3.2, timeout is 2 seconds:

    !!!!!

    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

    R1#

    Tại R1, khi bật chức năng định tuyến “ip classfull” bằng cách thực hiện câu lệnh “no ip classless” tại R1 ta phát hiện R1 không còn ping được tới lớp mạng 172.16.2.0/24 và 172.16.3.0/24 nữa mặc dù trong bảng định tuyến của R1 vẫn còn default route 0.0.0.0/0.

    R1(config)# no ip classless

    Câu lệnh “no ip classless” sẽ không có tác dụng gì cho đến khi ta vô hiệu hóa cơ chế chuyển mạch CEF bằng câu lệnh “no ip cef”.

    R1(config)# no ip cef

    Nếu cơ chế định tuyến “ip classfull” được kích hoạt, R1 sẽ không gửi gói tin tới mạng 172.16.2.0/24 và 172.16.3.0/24 bằng default route vì trong bảng định tuyến của R1 vẫn còn thông tin của route 172.16.0.0/16. Điều này khiến bảng định tuyến của R1 phải chứa các route cụ thể trỏ tới các mạng 172.16.2.0/24 và 172.16.3.0/24 thì quá trình ping từ R1 tới 2 mạng trên mới diễn ra thành công. Hoặc nếu mạng 172.16.0.0/16 không còn trong bảng định tuyến của R1 nữa thì các gói tin từ R1 gửi tới các mạng 172.16.2.0/24 và 172.16.3.0/24 sẽ được gửi đi theo default route và quá trình ping tới 2 mạng trên sẽ diễn ra thành công.

    R1# ping 172.16.2.1

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:

    …..

    Success rate is 0 percent (0/5)

    R1#



    R1# ping 172.16.3.1

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.3.1, timeout is 2 seconds:

    …..

    Success rate is 0 percent (0/5)

    R1#



    R1# show ip route

    Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP

    D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area

    N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

    E1 – OSPF external type 1, E2 – OSPF external type 2

    i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

    ia – IS-IS inter area, * – candidate default, U – per-user static route

    o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP

    + – replicated route, % – next hop override

    Gateway of last resort is 192.168.12.2 to network 0.0.0.0

    S* 0.0.0.0/0 [1/0] via 192.168.12.2

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks

    C 172.16.1.0/24 is directly connected, Ethernet0/1

    L 172.16.1.1/32 is directly connected, Ethernet0/1

    192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks

    C 192.168.12.0/24 is directly connected, Ethernet0/0

    L 192.168.12.1/32 is directly connected, Ethernet0/0

    R1#

    Tiến hành debug để biết gói tin từ R1 gửi tới 172.16.2.0/24 và 172.16.3.0/24 sẽ được gửi đi đâu.

    R1(config)# access-list 100 permit icmp any any

    R1# debug ip packet 100

    IP packet debugging is on for access list 100

    R1#

    R1# ping 172.16.2.1

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:

    *Jul 16 03:39:02.051: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.

    *Jul 16 03:39:04.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.

    *Jul 16 03:39:06.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.

    *Jul 16 03:39:08.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.

    *Jul 16 03:39:10.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.

    Success rate is 0 percent (0/5)

    R1#

    Với cơ chế “ip classfull”, R1 sẽ sử dụng thông tin định tuyến tương ứng với các route cụ thể nằm trong Major Network 172.16.0.0/16 để gửi các gói tin liên quan tới các mạng con của mạng này (chẳng hạn như mạng 172.16.2.0/24 và 172.16.3.0/24) và bỏ qua default route. Nếu bảng định tuyến của R1 không còn xuất hiện mạng 172.16.0.0/16 nữa thì các gói tin gửi tới 172.16.2.0/24 và 172.16.3.0/24 sẽ được gửi đi theo default route. Ta có thể xóa route 172.16.0.0/16 tại bảng định tuyến của R1 bằng cách vào cổng e0/1 trên R1 tiến hành “shutdown”.

    R1# show ip route

    Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP

    D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area

    N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

    E1 – OSPF external type 1, E2 – OSPF external type 2

    i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

    ia – IS-IS inter area, * – candidate default, U – per-user static route

    o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP

    + – replicated route, % – next hop override

    Gateway of last resort is 192.168.12.2 to network 0.0.0.0

    S* 0.0.0.0/0 [1/0] via 192.168.12.2

    172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks

    C 172.16.1.0/24 is directly connected, Ethernet0/1

    L 172.16.1.1/32 is directly connected, Ethernet0/1

    192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks

    C 192.168.12.0/24 is directly connected, Ethernet0/0

    L 192.168.12.1/32 is directly connected, Ethernet0/0

    R1#

    R1(config)# interface e0/1

    R1(config-if)# shutdown

    Sau khi shutdown cổng e0/1 tương ứng với lớp mạng 172.16.1.0/24 thì mạng 172.16.0.0/16 cũng không còn xuất hiện nữa trong bảng định tuyến của R1. Lúc này, khi ping tới các IP thuộc lớp mạng 172.16.2.0/24 và 172.16.3.0/24 sẽ diễn ra thành công vì R1 sẽ sử dụng thông tin default route để gửi dữ liệu.

    R1# show ip route

    Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP

    D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area

    N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

    E1 – OSPF external type 1, E2 – OSPF external type 2

    i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

    ia – IS-IS inter area, * – candidate default, U – per-user static route

    o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP

    + – replicated route, % – next hop override



    Gateway of last resort is 192.168.12.2 to network 0.0.0.0



    S* 0.0.0.0/0 [1/0] via 192.168.12.2

    192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks

    C 192.168.12.0/24 is directly connected, Ethernet0/0

    L 192.168.12.1/32 is directly connected, Ethernet0/0

    R1#



    R1# ping 172.16.2.2

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:

    !!!!!

    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/5 ms

    R1#



    R1# ping 172.16.3.2

    Type escape sequence to abort.

    Sending 5, 100-byte ICMP Echos to 172.16.3.2, timeout is 2 seconds:

    !!!!!

    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

    R1#
    Bùi Quốc Kỳ - VnPro
    Phạm Thanh Đông Khê
    Email: dongkhe@vnpro.org
    Hãy share hoặc like nếu thông tin hữu ích!
    ---------------------------------------------------------------------------------------------------------------------------------------------------
Trung Tâm Tin Học VnPro
149/1D Ung Văn Khiêm, P.25, Q.Bình Thạnh, Tp.HCM
Tel: (08) 35124257 (5 lines)
Fax: (08) 35124314

Home Page: http://www.vnpro.vn
Forum: http://www.vnpro.org
Twitter: https://twitter.com/VnVnpro
LinkedIn: https://www.linkedin.com/in/VnPro
- Chuyên đào tạo quản trị mạng và hạ tầng Internet
- Phát hành sách chuyên môn
- Tư vấn và tuyển dụng nhân sự IT
- Tư vấn thiết kế và hỗ trợ kỹ thuật hệ thống mạng

Videos: http://www.dancisco.com
Blog: http://www.vnpro.org/blog
FB: http://facebook.com/VnPro
Working...
X