• 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 cơ chế định tuyến “ip classfull”

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

  • Tìm hiểu cơ chế định tuyến “ip classfull”


    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:

    Code:
    - VPC1: [B]ip 172.16.1.2/24 172.16.1.1[/B]
    
    - VPC2: [B]ip 172.16.2.2/24 172.16.2.1[/B]
    
    - VPC3: [B]ip 172.16.3.2/24 172.16.3.1[/B]
    Cấu hình cơ bản trên R1.

    Code:
    [B]hostname R1[/B]
    
    [B]interface e0/0[/B]
    
    [B]ip address 192.168.12.1 255.255.255.0[/B]
    
    [B]no shutdown[/B]
    
    [B]exit[/B]
    
    [B]interface e0/1[/B]
    
    [B]ip address 172.16.1.1 255.255.255.0[/B]
    
    [B]no shutdown[/B]
    
    [B]exit[/B]
    
    [B]line console 0[/B]
    
    [B]logging synchronous[/B]
    
    [B]exec-timeout 0 0[/B]
    
    [B]exit[/B]
    
    [B]line vty 0 4[/B]
    
    [B]privilege level 15[/B]
    
    [B]no login[/B]
    
    [B]exit[/B]
    
    [B]no ip domain-lookup[/B]
    Cấu hình cơ bản trên R2:

    Code:
    [B]hostname R2[/B]
    
    [B]interface e0/0[/B]
    
    [B]ip address 192.168.12.2 255.255.255.0[/B]
    
    [B]no shutdown[/B]
    
    [B]exit[/B]
    
    [B]interface e0/1[/B]
    
    [B]ip address 172.16.2.1 255.255.255.0[/B]
    
    [B]no shutdown[/B]
    
    [B]exit[/B]
    
    [B]interface e0/2[/B]
    
    [B]ip address 172.16.3.1 255.255.255.0[/B]
    
    [B]no shutdown[/B]
    
    [B]exit[/B]
    
    [B]line console 0[/B]
    
    [B]logging synchronous[/B]
    
    [B]exec-timeout 0 0[/B]
    
    [B]exit[/B]
    
    [B]line vty 0 4[/B]
    
    [B]privilege level 15[/B]
    
    [B]no login[/B]
    
    [B]exit[/B]
    
    [B]no ip domain-lookup[/B]
    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.

    Code:
    [B]ip route 0.0.0.0 0.0.0.0 192.168.12.2  [/B]


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

    Code:
    [B]R1# show ip route[/B]
    
    [B]Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP[/B] 
    
    [B]             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area [/B]
    
    [B]             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2[/B] 
    
    [B]             E1 - OSPF external type 1, E2 - OSPF external type 2[/B] 
    
    [B]             i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2[/B] 
    
    [B]             ia - IS-IS inter area, * - candidate default, U - per-user static route[/B] 
    
    [B]             o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP[/B] 
    
    [B]             + - replicated route, % - next hop override[/B]
    
     
    
    [B]Gateway of last resort is 192.168.12.2 to network 0.0.0.0[/B]
    
    [B]S*    0.0.0.0/0 [1/0] via 192.168.12.2[/B] 
    
    [B]172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        172.16.1.0/24 is directly connected, Ethernet0/1[/B]
    
    [B]L        172.16.1.1/32 is directly connected, Ethernet0/1[/B] 
    
    [B]192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        192.168.12.0/24 is directly connected, Ethernet0/0[/B]
    
    [B]L        192.168.12.1/32 is directly connected, Ethernet0/0[/B]
    
    [B]R1#[/B]
    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.

    Code:
    [B]R1(config)# ip classless[/B]
    
    [B]S*    0.0.0.0/0 [1/0] via 192.168.12.2[/B]
    
    [B]R1# ping 172.16.2.2[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:[/B]
    
    [B]!!!!![/B]
    
    [B]Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms[/B]
    
    [B]R1#[/B]
    
    [B]R1# ping 172.16.3.2[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.3.2, timeout is 2 seconds:[/B]
    
    [B]!!!!![/B]
    
    [B]Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms[/B]
    
    [B]R1#[/B]
    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.

    Code:
    [B]R1(config)# no ip classless[/B]
    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”.

    Code:
    [B]R1(config)# no ip cef[/B]
    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.

    Code:
    [B]R1# ping 172.16.2.1[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:[/B]
    
    [B].....[/B]
    
    [B]Success rate is 0 percent (0/5)[/B]
    
    [B]R1#[/B]
    
    [B]R1# ping 172.16.3.1[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.3.1, timeout is 2 seconds:[/B]
    
    [B].....[/B]
    
    [B]Success rate is 0 percent (0/5)[/B]
    
    [B]R1#[/B]
    
    [B]R1# show ip route[/B]
    
    [B]Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP[/B] 
    
    [B]             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area [/B]
    
    [B]             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2[/B] 
    
    [B]             E1 - OSPF external type 1, E2 - OSPF external type 2[/B] 
    
    [B]             i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2[/B] 
    
    [B]             ia - IS-IS inter area, * - candidate default, U - per-user static route[/B] 
    
    [B]             o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP[/B] 
    
    [B]             + - replicated route, % - next hop override[/B]
    
     
    
    [B]Gateway of last resort is 192.168.12.2 to network 0.0.0.0[/B]
    
    [B]S*    0.0.0.0/0 [1/0] via 192.168.12.2[/B] 
    
    [B]172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        172.16.1.0/24 is directly connected, Ethernet0/1[/B]
    
    [B]L        172.16.1.1/32 is directly connected, Ethernet0/1[/B] 
    
    [B]192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        192.168.12.0/24 is directly connected, Ethernet0/0[/B]
    
    [B]L        192.168.12.1/32 is directly connected, Ethernet0/0[/B]
    
    [B]R1#[/B]
    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.

    Code:
    [B]R1(config)# access-list 100 permit icmp any any[/B]
    
    [B]R1# debug ip packet 100[/B]
    
    [B]IP packet debugging is on for access list 100[/B]
    
    [B]R1#[/B]
    
    [B]R1# ping 172.16.2.1[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:[/B] 
    
    [B]*Jul 16 03:39:02.051: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.[/B]
    
    [B]*Jul 16 03:39:04.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.[/B]
    
    [B]*Jul 16 03:39:06.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.[/B]
    
    [B]*Jul 16 03:39:08.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.[/B]
    
    [B]*Jul 16 03:39:10.052: IP: s=172.16.1.1 (local), d=172.16.2.1, len 100, unroutable.[/B]
    
    [B]Success rate is 0 percent (0/5)[/B]
    
    [B]R1#[/B]
    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”.

    Code:
    [B]R1# show ip route   [/B]
    
    [B]Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP[/B] 
    
    [B]             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area [/B]
    
    [B]             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2[/B] 
    
    [B]             E1 - OSPF external type 1, E2 - OSPF external type 2[/B] 
    
    [B]             i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2[/B] 
    
    [B]             ia - IS-IS inter area, * - candidate default, U - per-user static route[/B] 
    
    [B]             o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP[/B] 
    
    [B]             + - replicated route, % - next hop override[/B]
    
     
    
    [B]Gateway of last resort is 192.168.12.2 to network 0.0.0.0[/B]
    
    [B]S*    0.0.0.0/0 [1/0] via 192.168.12.2[/B] 
    
    [B]172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        172.16.1.0/24 is directly connected, Ethernet0/1[/B]
    
    [B]L        172.16.1.1/32 is directly connected, Ethernet0/1[/B] 
    
    [B]192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        192.168.12.0/24 is directly connected, Ethernet0/0[/B]
    
    [B]L        192.168.12.1/32 is directly connected, Ethernet0/0[/B]
    
    [B]R1#[/B]
    
    [B]R1(config)# interface e0/1[/B]
    
    [B]R1(config-if)# shutdown[/B]
    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.

    Code:
    [B]R1# show ip route[/B]
    
    [B]Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP[/B] 
    
    [B]             D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area [/B]
    
    [B]             N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2[/B] 
    
    [B]             E1 - OSPF external type 1, E2 - OSPF external type 2[/B] 
    
    [B]             i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2[/B] 
    
    [B]             ia - IS-IS inter area, * - candidate default, U - per-user static route[/B] 
    
    [B]             o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP[/B] 
    
    [B]             + - replicated route, % - next hop override[/B]
    
     
    
    [B]Gateway of last resort is 192.168.12.2 to network 0.0.0.0[/B]
    
    [B]S*    0.0.0.0/0 [1/0] via 192.168.12.2[/B] 
    
    [B]192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks[/B]
    
    [B]C        192.168.12.0/24 is directly connected, Ethernet0/0[/B]
    
    [B]L        192.168.12.1/32 is directly connected, Ethernet0/0[/B]
    
    [B]R1#[/B]
    
    [B]R1# ping 172.16.2.2[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.2.2, timeout is 2 seconds:[/B]
    
    [B]!!!!![/B]
    
    [B]Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/5 ms[/B]
    
    [B]R1#[/B]  
    
    [B]R1# ping 172.16.3.2[/B]
    
    [B]Type escape sequence to abort.[/B]
    
    [B]Sending 5, 100-byte ICMP Echos to 172.16.3.2, timeout is 2 seconds:[/B]
    
    [B]!!!!![/B]
    
    [B]Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms[/B]
    
    [B]R1#[/B]
    Bùi Quốc Kỳ
    Phan Trung Tín
    Email: phantrungtin@vnpro.org
    .
Trung Tâm Tin Học VnPro
149/1D Ung Văn Khiêm, P.25, Q.Bình Thạnh, Tp.HCM
Tel: (028) 35124257 (028) 36222234
Fax: (028) 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
Facebook: http://facebook.com/VnPro
Zalo: https://zalo.me/1005309060549762169
​​​​​​
Working...
X