IPsec NAT Exemption
NAT (Network Address Translation) is used to translate private IP addresses into public IP addresses. NAT changes the source and destination IP addresses and ports. NAT Address translation reduces the need for IPv4 public addresses and it also hides private network address ranges.
Internet protocol security (IPsec) is a framework that helps us to protect our IP traffic on the network layer. IPsec allows two or more hosts to communicate in a secure manner by authenticating and encrypting each IP packet of a communication session.
The nature
of NAT and IPsec is different, NAT manipulates an IP packet and IPsec preserves
the IP packets. IPsec does not work with NAT. we have to exclude (bypass NAT) the traffic to be encrypted from the NAT operation. Nat must not occur for proper IPsec network communication but NAT should be for inside hosts in order to access the internet.
NAT exemption
is a method that excludes traffic from being translated with NAT. NAT exemption is preferred when bypassing traffic flowing over a VPN tunnel.
R1(config)#ip access-list extended NAT-TRAFFIC
NAT exemption is usually used in the following scenarios:
Legacy policy-based
IPsec VPNs
Remote access VPNs
Site-to-site VPN
tunnels
When we have a lot
of VPN tunnels with customers and we don't want to conflict with IPs on their
network
let's see the configuration for a better understanding:
topology:-
- First, configure the IP addresses as per the topology above
- Configure the default route and static routes
- verify the Default and static routing with ping from pc 192.168.10.2 to 192.168.30.2 and vice versa
- enable crypto isakmp on both sites
- configure extended ACL to tell the router which traffic is to encrypt.
- configure Crypto isakmp policy on both sites
- configure the crypto key on both sites make sure its identical
- configure IPsec transform-set name will be IPsec-tunnel for both sites
- configure IPsec security association timer 1800 on both sites
- configure crypto map name of the map will be map on both sites
- apply the crypto map on interface serial 4/0 on router 1 and serial 4/1 on router 2
First configure the IP addresses as per the topology above
R1(config-if)#ip address 192.168.10.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastEthernet 1/0
R1(config-if)#ip address 192.168.20.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface serial 4/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#do show ip int br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.10.1 YES manual up up
FastEthernet1/0 192.168.20.1 YES manual up up
Serial4/0 192.168.1.1 YES manual up up
.....................................................................................................................
R2(config-if)#ip address 100.100.100.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface serial 4/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config-if)#interface serial 4/1
R2(config-if)#ip address 192.168.3.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
verify the Default and static routing with ping from pc 192.168.10.2 to 192.168.30.2 and vice versa
NAME : PC2[1]
IP/MASK : 192.168.10.2/24
GATEWAY : 192.168.10.1
DNS :
MAC : 00:50:79:66:68:01
LPORT : 10050
RHOST:PORT : 127.0.0.1:10051
MTU: : 1500
PC2> ping 192.168.30.2
84 bytes from 192.168.30.2 icmp_seq=1 ttl=62 time=90.305 ms
84 bytes from 192.168.30.2 icmp_seq=2 ttl=62 time=90.064 ms
84 bytes from 192.168.30.2 icmp_seq=3 ttl=62 time=90.262 ms
84 bytes from 192.168.30.2 icmp_seq=4 ttl=62 time=90.758 ms
84 bytes from 192.168.30.2 icmp_seq=5 ttl=62 time=91.022 ms
NAME : PC6[1]
IP/MASK : 192.168.30.2/24
GATEWAY : 192.168.30.1
DNS :
MAC : 00:50:79:66:68:03
LPORT : 10054
RHOST:PORT : 127.0.0.1:10055
MTU: : 1500
84 bytes from 192.168.10.2 icmp_seq=1 ttl=62 time=91.472 ms
84 bytes from 192.168.10.2 icmp_seq=2 ttl=62 time=91.446 ms
84 bytes from 192.168.10.2 icmp_seq=3 ttl=62 time=91.430 ms
84 bytes from 192.168.10.2 icmp_seq=4 ttl=62 time=91.040 ms
84 bytes from 192.168.10.2 icmp_seq=5 ttl=62 time=90.697 ms
Configure the default route and static routes
enable crypto isakmp on both sites
configure extended ACL to tell the router which traffic is to encrypt.
configure Crypto isakmp policy on both sites
configure the crypto key on both sites make sure its identical
R1(config)#crypto isakmp key 6 internetworks address 192.168.3.1
R3(config)#crypto isakmp key 6 internetworks address 192.168.1.1
Keyring Hostname/Address Preshared Key
default 192.168.1.1 (encrypted)
configure IPsec transform-set name will be ipsec-tunnel for both sites
R1(config)#crypto ipsec transform-set ipsec-tunnel esp-aes 256 esp-sha-hmac
Transform set ipsec-tunnel: { esp-256-aes esp-sha-hmac }
R2(config)#crypto ipsec transform-set ipsec-tunnel esp-aes 256 esp-sha-hmac
configure IPsec security association timer 1800 on both sites
configure crypto map name of the map will be map on both sites
apply the crypto map on interface serial 4/0 on router 1 and serial 4/1 on router 2
now send the ICMP ping packets from PC2 192.168.10.2 to PC6 192.168.20.2 and make sure the data must be encrypt, encapsualte by IPsec.
interface: Serial4/0
Crypto map tag: map, local addr 192.168.1.1
protected vrf: (none)
local ident (addr/mask/prot/port): (192.168.10.0/255.255.255.0/0/0)
remote ident (addr/mask/prot/port): (192.168.30.0/255.255.255.0/0/0)
current_peer 192.168.3.1 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 0, #pkts encrypt: 0, #pkts digest: 0
#pkts decaps: 0, #pkts decrypt: 0, #pkts verify: 0
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 192.168.1.1, remote crypto endpt.: 192.168.3.1
path mtu 1500, ip mtu 1500, ip mtu idb Serial4/0
current outbound spi: 0x0(0)
PFS (Y/N): N, DH group: none
IPv4 Crypto ISAKMP SA
dst src state conn-id status
IPv6 Crypto ISAKMP SA
as of now no packet is encrypt let's send some packets.
from pc2
NAME : PC6[1]
IP/MASK : 192.168.30.2/24
GATEWAY : 192.168.30.1
DNS :
MAC : 00:50:79:66:68:03
LPORT : 10054
RHOST:PORT : 127.0.0.1:10055
MTU: : 1500
192.168.10.2 icmp_seq=1 timeout
192.168.10.2 icmp_seq=2 timeout
84 bytes from 192.168.10.2 icmp_seq=3 ttl=62 time=134.144 ms
84 bytes from 192.168.10.2 icmp_seq=4 ttl=62 time=94.150 ms
84 bytes from 192.168.10.2 icmp_seq=5 ttl=62 time=105.917 ms
84 bytes from 192.168.10.2 icmp_seq=1 ttl=62 time=98.854 ms
84 bytes from 192.168.10.2 icmp_seq=2 ttl=62 time=92.000 ms
84 bytes from 192.168.10.2 icmp_seq=3 ttl=62 time=118.293 ms
84 bytes from 192.168.10.2 icmp_seq=4 ttl=62 time=123.813 ms
84 bytes from 192.168.10.2 icmp_seq=5 ttl=62 time=93.092 ms
IPv4 Crypto ISAKMP SA
dst src state conn-id status
192.168.3.1 192.168.1.1 QM_IDLE 1004 ACTIVE
IPv6 Crypto ISAKMP SA
IPv4 Crypto ISAKMP SA
dst src state conn-id status
192.168.3.1 192.168.1.1 QM_IDLE 1004 ACTIVE
IPv6 Crypto ISAKMP SA
now lets configure NAT on both sites first configure the ACL extended
R1(config-ext-nacl)#permit ip 192.168.10.0 0.0.0.255 any
R1(config-ext-nacl)#permit ip 192.168.20.0 0.0.0.255 any
R1(config-ext-nacl)#exit
R3(config-ext-nacl)#permit ip 192.168.30.0 0.0.0.255 any
R3(config-ext-nacl)#permit ip 192.168.40.0 0.0.0.255 any
R3(config-ext-nacl)#exit
now configure NAT overload on boths routers serial interface.
now send some ICMP packets from PC2 to Server
now send some ICMP packets from PC4 192.168.20.2 to PC8 192.168.40.2
0 comments:
Post a Comment