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

NAT: Static, Dynamic and Overload

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

  • NAT: Static, Dynamic and Overload

    NAT: Static, Dynamic and Overload
    1. Mục tiêu
    Trong bài lab này, chúng ta sẽ cấu hình static NAT, dynamic NAT và option overload trong NAT

    2. Hoàn cảnh



    Công ty du lịch ABC cần khoảng 100 địa chỉ IP private dịch sang một pool địa chỉ IP public để có thể route ra ISP. ABC đã thực hiện điều này bằng cách sử dụng NAT, dịch các địa chỉ private thành các địa chỉ public được ISP cho phép.

    3. Thực hiện
    a. Bước 1:
    Cấu hình các địa chỉ IP trên các router theo sơ đồ trên, kiểm tra các kết nối trực tiếp bằng lệnh show cdp neighbor.
    Kiểm tra ping giữa các workstation và router NAT, giữa WebServer và router ISP1.

    b. Bước 2:
    Do không sử dụng routing protocol, ta cấu hình default route ra Internet trên router NAT:

    NAT(config)#ip route 0.0.0.0 0.0.0.0 200.200.100.2

    ISP cần được cấu hình để đến được mạng 192.168.1.0/24. Nhưng các host trong mạng này sẽ đổi địa chỉ private 192.168.1.0/24 thành địa chỉ public 200.200.100.128/25, do đó ta cấu hình static route trên ISP:
    ISP(config)#ip route 200.200.100.128 255.255.255.128 200.200.100.1

    c. Bước 3:
    Trong bước này, ta sẽ chỉ định các địa chỉ private và public sẽ được NAT xử lý để translate.
    Trước hết, ta dùng static NAT, chuyển internal user 192.168.1.5 thành 200.200.100.252:

    NAT(config)#ip nat inside source static 192.168.1.5 200.200.100.252

    Cấu hình NAT trên các interface:

    NAT(config)#int e0/0
    NAT(config-if)#ip nat inside
    NAT(config-if)#int s0/1
    NAT(config-if)#ip nat outside

    Lúc này, host 192.168.1.5 có thể ping được WebServer, còn host 192.168.1.2 thì chưa thể. Do packet đi từ router NAT theo default route qua ISP đến WebServer nhưng khi WebServer gửi trả packet lại thì nó không route được do không học được network 192.168.1.0

    WebServer#debug ip packet
    IP packet debugging is on
    WebServer#
    00:29:05: IP: s=200.200.100.252 (Ethernet0/0), d=200.200.50.2 (Ethernet0/0), len 60, rcvd 3
    00:29:05: IP: s=200.200.50.2 (local), d=192.168.1.2, len 60, unroutable
    WebServer#
    00:29:06: IP: s=200.200.50.2 (local), d=192.168.1.2, len 58, unroutable

    Static NAT có ưu điểm là external user luôn có thể truy cập được host 192.168.1.5 qua địa chỉ 200.200.100.252. Nhưng việc cấu hình static NAT đối với một mạng có nhiều host là không thực tế, đòi hỏi nhiểu thời gian cấu hình, và không gian địa chỉ. Trong trường hợp đó, ta cấu hình NAT động.

    Trước hết, ta xác định địa chỉ host sẽ được NAT:

    NAT(config)#access-list 1 permit 192.168.1.0 0.0.0.255

    Kế tiếp, xác định pool địa chỉ public sẽ được sử dụng bởi các địa chỉ private:

    NAT(config)#ip nat pool public 200.200.100.129 200.200.100.250 netmask 255.255.255.128

    Cho phép các địa chỉ private translate thành các địa chỉ public:

    NAT(config)#ip nat inside source list 1 pool public

    Kiểm tra: ping từ internal user (192.168.1.2) đến webserver

    NAT#debug ip nat
    IP NAT debugging is on
    NAT#
    01:02:15: NAT*: s=192.168.1.2->200.200.100.129, d=200.200.50.2 [3969]
    01:02:20: NAT*: s=192.168.1.2->200.200.100.129, d=200.200.50.2 [3970]

    Kiểm tra các translation của NAT:
    NAT#show ip nat translations
    Pro Inside global Inside local Outside local Outside global
    --- 200.200.100.129 192.168.1.2 --- ---
    --- 200.200.100.252 192.168.1.5 --- ---

    4. Thực hiện overload:

    Do việc thuê từ ISP một pool địa chỉ public khá tốn kém, các nhà quản trị công ty ABC quyết định giảm số lượng địa chỉ public thuê từ ISP xuống càng ít càng tốt.

    Trong trường hợp này, ta dùng NAT overload để giảm số lượng địa chỉ public cấn sử dụng:

    NAT(config)#no ip nat inside source static 192.168.1.5 200.200.100.252
    NAT(config)#no ip nat inside source list 1 pool public
    NAT(config)#ip nat inside source list 1 interface Serial0/1 overload

    Ở đây, thay vì dùng 1 pool các địa chỉ như trước, ta sẽ cho các PC trong mạng LAN dùng chung địa chỉ với serial 0/1 (200.200.100.1) để ra bên ngoài Internet.

    Tham số overload cho phép nhiều host dùng chung một địa chỉ IP (router phân biệt các host bằng port number) để ra ngoài ISP.
    Ta kiểm tra bằng cách ping từ các Internal User (192.168.1.5) đến Webserver.

    NAT#show ip nat translations
    Pro Inside global Inside local Outside local Outside global
    icmp 200.200.100.1:512 192.168.1.5:512 200.200.50.2:512 200.200.50.2:512


    NAT#debug ip packet
    IP packet debugging is on
    NAT#
    01:36:00: IP: s=200.200.100.1 (Ethernet0/0), d=200.200.50.2 (Serial0/1), g=200.200.100.2, len 60, forward
    01:36:00: IP: s=200.200.50.2 (Serial0/1), d=192.168.1.5 (Ethernet0/0), g=192.168.1.5, len 60, forward

    5. Cấu hình:
    NAT#show running-config
    Building configuration...

    Current configuration:
    !
    version 12.0
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname NAT
    !
    ip subnet-zero
    no ip domain-lookup
    !
    interface Ethernet0/0
    ip address 192.168.1.1 255.255.255.0
    no ip directed-broadcast
    ip nat inside
    !
    interface Serial0/1
    ip address 200.200.100.1 255.255.255.252
    no ip directed-broadcast
    ip nat outside
    !
    ip nat pool public 200.200.100.129 200.200.100.129 prefix-length 24
    ip nat inside source list 1 interface Serial0/1 overload
    ip classless
    ip route 0.0.0.0 0.0.0.0 200.200.100.2
    !
    access-list 1 permit 192.168.1.0 0.0.0.255
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    no scheduler allocate
    end

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

    ISP1#show running-config
    Building configuration...

    Current configuration : 1041 bytes
    !
    version 12.1
    no service single-slot-reload-enable
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname ISP1
    !
    ip subnet-zero
    !
    no ip domain-lookup
    !
    !
    interface FastEthernet0/0
    ip address 200.200.50.1 255.255.255.0
    duplex auto
    speed auto
    !
    interface Serial0/1
    ip address 200.200.100.2 255.255.255.252
    clockrate 64000
    !
    ip classless
    ip route 200.200.100.128 255.255.255.128 200.200.100.1
    no ip http server
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    no scheduler allocate
    end

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

    WebServer#show running-config
    Building configuration...

    Current configuration : 877 bytes
    !
    version 12.1
    no service single-slot-reload-enable
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname WebServer
    !
    no logging buffered
    logging rate-limit console 10 except errors
    !
    ip subnet-zero
    !
    no ip domain-lookup
    !
    interface Ethernet0/0
    ip address 200.200.50.2 255.255.255.0
    half-duplex
    !
    interface Serial0/1
    no ip address
    shutdown
    !
    ip classless
    ip route 0.0.0.0 0.0.0.0 200.200.50.1
    ip http server
    !
    line con 0
    logging synchronous
    transport input none
    line aux 0
    line vty 0 4
    privilege level 15
    no login
    !
    no scheduler allocate
    end

  • #2
    Hi

    bạn ơi post hình bài nat này lại đi mình không thấy hình đâu cả. cám ơn

    Comment


    • #3
      Up lai hinh di ban oi.

      Comment


      • #4
        up lại sơ đồ đi bạn

        Comment

        Working...
        X