Your actual question:
Is it possible with NAT for 192.168.1.1 to ping 192.168.1.2, but for
10.1.1.1 to be actually pinged ?
and your comment:
i want a ping from the 192 network to ping the 10.1.1.1 address with a
source address of the 10.0.0.0 network
are two very different things.
First, we must make sure that you understand what happens when one host sends a packet to another host:
When a source host sends a layer-3 packet, it will build a layer-2 frame, so it needs to relate the layer-3 destination address to a layer-2 destination address in order to build the frame. With IPv4 and an IEEE LAN protocol (ethernet, Wi-Fi, etc.) it will use ARP (Address Resolution Protocol) to get the layer-2 destination address for the layer-3 destination address.
The source host first needs to determine if the destination host is on the same layer-3 network as itself. It does that by masking both the layer-3 source and destination addresses with its configured network mask. If the results are the same, the source host will know that the destination host is on the same network as itself, and it will use ARP to directly find the destination layer-2 address. If the results are different, then the source host knows the destination host is on a different network than it is, and it will use ARP to find the destination layer-2 address of its configured gateway. In either case, the layer-2 frame is built with the layer-2 address (either the destination host, or the gateway to get to the destination host) returned by the ARP process.
ARP works by first looking in the host's ARP table to see if it contains an entry for the destination layer-3 address. If so, it uses the layer-2 destination address related to the entry for the layer-3 destination address. If not, it sends a broadcast ARP request that asks, "Who owns this layer-3 address, and what is your layer-2 address?" It will wait for a reply, eventually timing out if it gets no response, and it will pass an error back up the network stack to the application.
Also remember that ping is a bidirectional application that uses ICMP echo requests to solicit ICMP echo replies, so it is not enough that a ping ICMP echo request reach the destination host, but the ICMP echo reply must also be able to get back to the source host, meaning the destination (now source) host must also be able to send packets to the source (now destination) host, too.
Looking at your question, there are some possibilities how this will play out:
- If there is already a host on the source network with the destination
layer-3 address of
192.168.1.2
. That host will reply to the source
host (192.168.1.1
) with its layer-2 address, and the source host
will end up pinging its neighbor on its own network.
- If there is no host on the source network with the layer-3
destination address, the ARP request will time out, and an error will
be sent back up the network stack to the ping application, resulting
in a destination unreachable error message.
- Another possibility is that you have a router that can be configured
for Proxy ARP (a security problem), and that it can be configured to
send traffic destined for the same network on which it was received
to a different network, and also perform an address translation (NAT)
on the layer-3 packet destination address, translating
192.168.1.2
to 10.1.1.1
. The destination host would then receive a packet with
the source host of 192.168.1.1
and a destination address of
10.1.1.1
, and it will be able to normally reply to the ping.
Looking at your comment, the source host can send packets to the real destination, but have the destination router (the router connected to the destination network) use a common source NAT to change the source layer-3 address to that of the router interface in the destination network.
Doing both scenarios at the same time will require both techniques.
In any case, what you want seems to be a giant kludge for which you should have a valid reason with no other alternative. Routers route packets between networks, and if you have two different networks, then simple routing will send packets between the networks, and you avoid all the problems inherent in NAT.
10.1.1.1 255.255.255.255 192.168.1.254
or whatever the gateway is for your 192.168.1.x network) and then a route on the other side to know how to reach the 192.168.1.x network from the 10.1.1.x network.