2010年11月5日 星期五

Bài Lab Hướng Dẫn Cấu Hình NAT Overload(PAT)

CẤU HÌNH NAT OVERLOAD (PAT)

I.Giới thiệu.
Với thực trạng địa chỉ IP v4 đang dần cạn kiệt va việc phát triển sang IP v6 còn nhiều khó khăn thì một trong những giải pháp tiết kiệm địa chỉ đó la NAT, với Nat chúng ta có thể sử dụng một hoặc rất ít địa chỉ Public khi ra ngoài Internet thay cho dải địa chỉ Private rất lớn trong mạng của mình.
Có các dạng Nat như sau:
+ Nat overload -> Nat nhiều địa chỉ private thanh 1 địa chỉ public khi đi ra ngoài
+ Nat static -> Nat một địa chỉ private thành một địa chỉ Public khi đi ra ngoài
+ NAT Dynamic-> NAT dải địa chỉ private thành 1 dải public khi đi ra ngoài


II. Mô hình.

III. Yêu cầu.
1. Cấu hình Cơ bản
1.1 Cấu hình khởi tạo cho các thiết bị mạng.
- đặt tên
- cấu hình Banner mote
- cấu hình password cho console, telnet, Privileged.
Password console: itn
Password telnet: itn
Password Privileged: itn
1.2. Cấu hình các interface của router.
- cấu hình địa chỉ IP
- cấu hình description
- cấu hình enable các interface
1.3. cấu hình default route trên Router1 và static route trên Router2.
1.4. Kiểm tra
- kiểm tra các interface đã up hay chưa.
- cấu hình đúng hay chưa
- kiểm tra bảng định tuyến.
2. Cấu hình Nat Overload (PAT)
2.1. cấu hình NAT
- tạo Access-list chỉ định dải địa chỉ được NAT
- cấu hình cho phép dải địa chỉ 192.168.2.0/24 nat ra ngoài thành một địa chỉ global
- cấu hình xác định các cổng in và out của router
2.2. Kiểm tra
- kiểm tra cấu hình, dùng câu lệnh Show Running-config để kiểm tra các câu lệnh cấu hình
- dùng lệnh ping mở rộng dùng nguồn từ 192.168.2.1 đến 192.168.1.1, dùng lệnh debug ip nat để kiểm tra địa chỉ chuyển đổi như thế nào
- Để xem bảng chuyển đổi NAT trên Router1 dùng lệnh show ip nat tranlation.
- Một số lệnh kiểm tra khác
Show ip nat statistics : Hiển thị số phiên đang chuyển dịch và đã chuyển dịch khi thực hiện NAT.

Show ip nat translations: Các phiên NAT đang diễn ra; Protocol of the packet translated; inside global address , outside local address, outside global address và inside local address.

Show ip nat translations verbose : giống lệnh trên nhưng chi tiết hơn

clear ip nat translation : Xóa tất cả các phiên NAT

clear ip nat statistics : xóa tất cả các counters của thống kê NAT

debug ip nat : Xem tiến trình của các phiên NAT.

IV. Cấu hình chi tiết
1. cấu hình cơ bản
1.1 Router 1

1.1.1 cấu hình khởi tạo
Cấu hình đặt tên
Router>enable
Router#configure terminal
Router(config)#hostname Router1
Router1(config)#

cấu hình Banner mote
Router1(config)#banner motd " Router_1 "

cấu hình console
Router1(config)#line console 0
Router1(config-line)#password itn
Router1(config-line)#login
Router1(config-line)#exit

cấu hình telnet
Router1(config)#line vty 0 4
Router1(config-line)#password itn
Router1(config-line)#login
Router1(config-line)#exit

cấu hình password privileged
Router1(config)#enable secret itn

Cấu hình các interface của router

Router1(config)#interface serial 1/0
Router1(config-if)#ip address 203.162.1.17 255.255.255.252
Router1(config-if)#description ket noi toi router 2
Router1(config-if)#clock rate 64000
Router1(config-if)#no shutdown
Router1(config-if)#exit


Router1(config)#interface fastEthernet 2/0
Router1(config-if)#ip address 192.168.2.1 255.255.255.0
Router1(config-if)#description ket noi toi lan
Router1(config-if)#no sh
Router1(config-if)#exit

cấu hình default router cho router.
Router1(config)#ip route 0.0.0.0 0.0.0.0 s1/0 trỏ ra cổng s1/0


1.2.Router 2
1.2.1. cấu hình khởi tạo
Cấu hình đặt tên
Router>enable
Router#configure terminal
Router(config)#hostname Router2
Router2(config)#

cấu hình Banner mote
Router2(config)#banner motd " Router_2 "


cấu hình console
Router2(config)#line console 0
Router2(config-line)#password itn
Router2(config-line)#login
Router2(config-line)#exit

cấu hình telnet
Rouer2(config)#line vty 0 4
Router2(config-line)#password itn
Router2(config-line)#login
Router2(config-line)#exit

cấu hình password privileged
Router2(config)#enable secret itn

Cấu hình các interface của router

Router2(config)#interface serial 1/0
Router2(config-if)#ip address 203.162.1.18 255.255.255.252
Router2(config-if)#description ket noi toi router 1
Router2(config-if)#clock rate 64000
Router2(config-if)#no shutdown
Router2(config-if)#exit


Router2(config)#interface lo0
Router2(config-if)#ip address 192.168.1.1 255.255.255.0
Router2(config-if)#description vitual lan
Router2(config-if)#exit

cấu hình static route đối với Router2
Router2(config)#ip route 192.168.2.0 255.255.255.0 203.162.1.17

1.3. kiểm tra
Kiểm tra xem các interface đã được cấu hình đúng chưa sử dụng câu lệnh
Router1#show ip interface brief
kiểm tra xem các cấu hình bên trên đã đúng chưa sử dụng câu lệnh
Router1#show running-config
Kiểm tra bảng định tuyến show ip route và ping thử để xem, mạng đã thông hay chưa.


2. cấu hình Nat địa chỉ trên Router1
2.1 cấu hình NAt
Tạo Access-list chỉ định dải địa chỉ được Nat
Router1(config)#access-list 1 permit 192.168.2.0 255.255.255.0

Cấu hình cho phép Nat ra thành một địa chi Global
Router(config)#ip nat inside source list 1 interface s1/0 overload

Cấu hình xác đinh chiều in và out của Nat
Router(config)#int f2/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config-if)#int s1/0
Router(config-if)#ip nat outside
Router(config-if)#exit



2.2. kiểm tra cấu hình Nat


- Ping

R2#ping
Protocol [ip]:
Target IP address: 192.168.2.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.168.1.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 172.16.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

- Dùng lệnh Show ip nat translations để theo dõi Các phiên NAT đang diễn ra; Protocol of the packet translated; inside global address , outside local address, outside global address và inside local address.

Router1# show ip nat translations
Pro Inside global Inside local Outside local Outside global
--- 171.68.1.1 171.68.1.1 171.68.16.10 172.16.88.1
--- --- --- 171.68.16.10 172.16.88.1

V. Lưu cấu hình vào NVRam
Sau khi hoàn tất các bước cấu hình và kiểm tra đúng ta tiến hành lưu cấu hình hiện tại vào NVRam
Router1# Copy running-config Startup-config
Router1# Copy running-config Startup-config

END

沒有留言:

張貼留言