Sử dụng NAT/IPsec để kết nối 2 mạng trùng dải địa chỉ IP (Overlapping Networks)

1

Tình huống: Công ty quyết định kết nối mạng tại 2 site với nhau, tuy nhiên do không có quy hoạch trước nên cả 2 site đều đang dùng dải IP là 192.168.1.0/24. Phương án thay đổi IP không được chấp nhận vì phải thay đổi lại rất nhiều và gây gián đoạn dịch vụ.

 Giải pháp: Cấu hình NAT trên các Router biên R3 và R4, đổi R3 LAN thành 10.0.0.0/24 và đổi R4 LAN thành 20.0.0.24. Khi 2 site gửi dữ liệu cho nhau thì dst.ip sẽ là địa chỉ sau NAT đại diện cho mỗi LAN. Ví dụ khi PC R1 cần gửi dữ liệu cho PCR5 thì sẽ gửi với dst.ip = 20.0.0.10, ngược lại PC R5 gửi dữ liệu cho PC R1 sẽ lấy dst.ip = 10.0.0.10

Cấu hình:

R3:

ena
conf t

int f0/0
no sh
ip add 192.168.1.1 255.255.255.0
ip nat inside
int f0/1
no sh
ip add 200.200.200.1 255.255.255.0
ip nat outside

!Map toàn bộ dải 192.168.1.0/24 sang dải 10.0.0.0/24
ip nat inside source static network 192.168.1.0 10.0.0.0 /24 no-alias

ip route 20.0.0.0 255.255.255.0 f0/1 200.200.200.2

R4:

ena
conf t

int f0/0
no sh
ip add 192.168.1.1 255.255.255.0
ip nat inside
int f0/1
no sh
ip add 200.200.200.2 255.255.255.0
ip nat outside

!Map toàn bộ dải 192.168.1.0/24 sang dải 20.0.0.0/24
ip nat inside source static network 192.168.1.0 20.0.0.0 /24 no-alias

ip route 10.0.0.0 255.255.255.0 f0/1 200.200.200.1

Kết quả: PC R1 có thể kết nối tới PC R5 bằng ip đại diện.

R1#ping 20.0.0.10

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.0.0.10, timeout is 2 seconds:
!!!!!

R3#debug ip nat
*Mar  1 01:12:18.399: NAT*: s=192.168.1.10->10.0.0.10, d=20.0.0.1 [35]
*Mar  1 01:12:18.443: NAT*: s=20.0.0.1, d=10.0.0.10->192.168.1.10 [35]

R3#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
— 10.0.0.10          192.168.1.10       —                —
— 10.0.0.0           192.168.1.0        —                —

R4#debug ip nat
*Mar 1 01:12:17.119: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.1.1 [35]
*Mar 1 01:12:17.123: NAT: s=192.168.1.1->20.0.0.1, d=10.0.0.10 [35]

R4#show ip nat translations
Pro Inside global      Inside local       Outside local      Outside global
— 20.0.0.1           192.168.1.1        —                —
— 20.0.0.0           192.168.1.0        —                —

Mở rộng: Có thể cấu hình IPsec tunnel cho 2 site bị trùng IP như trên, trong đó chú ý access-list sẽ permit traffic giữa 10.0.0.0/24 và 20.0.0.0/24 vì NAT được xử lý trước khi encryption. Tham khảo cấu hình như  sau:

R3 (R4 tương tự)

crypto isakmp policy 1
encr aes
authentication pre-share
group 2
crypto isakmp key cisco address 200.200.200.2
!
!
crypto ipsec transform-set MYSET esp-aes esp-md5-hmac
!
crypto map MYMAP 10 ipsec-isakmp
set peer 200.200.200.2
set transform-set MYSET
match address 100

int f0/1

crypto map MYMAP
!
ip route 20.0.0.0 255.255.255.0 200.200.200.2
!

access-list 100 permit ip 10.0.0.0 0.0.0.255 20.0.0.0 0.0.0.255

Tham khảo:

http://www.cisco.com/c/en/us/support/docs/security-vpn/ipsec-negotiation-ike-protocols/14143-same-ip.html

http://nyquist.eu/nat-for-overlapping-networks/

https://cciereview.wordpress.com/2012/03/03/nat-overlapping-subnets/

Leave a comment