A method and system for enabling secure IPsec tunnels within NAT without
compromising security. A local network is configured with a gateway
machine connected to the Internet and having an IPsec ID for interfacing
with the Internet and a local IP/interface address for interfacing with
the local network. Client machines are connected to the gateway machine
and communicate with the Internet via the gateway and network address
translation (NAT) techniques. Each client machine is configured with a
local IP/interface address. The client machines are also provided with an
alias of the IPsec ID for the gateway machine. When an IPsec request is
received by the gateway machine to establish a tunnel (secure
communication) with one of the clients, the gateway machine forwards the
packet to the particular client using NAT. The client machine receives
the request and since it has an alias of the gateway's IPsec ID, the
client machine will confirm that it has one of the IPsec IDs in the
packet. The client machine sends the reply packet back to the gateway
machine, which then forwards it to the requesting machine over the
Internet. The requesting machine receives the packet and a confirmation
that it has reached its intended recipient and opens the secure IKE
tunnel with the particular client via the gateway machine. In this manner
authentication of the IKE tunnel and establishment of a secure IPsec
session is completed with a client machine that is accessible only via a
gateway implementing NAT.