I have two machines in the same VPC (under same subnet range) in GCP. I want to ping MAC address from one instance to another (ie. layer 2 connection). Is this supported in GCP?
If not, is GRE tunnel supported between the two VMs in the above configuration or any other tunneling?
My mail goal is to establish a layer 2 connection.
You can not have L2 connectivity this out of the box. However, you can setup a VXLAN or other kind of tunnels between VMs if you really need L2 connectivity for some odd reason. I've written a blog about how to do this: https://samos-it.com/posts/gce-vm-vxlan-l2-connectivity.html (Copy pasting the main pieces below)
Let's start by creating vm-1
Repeat the same command creating vm-2 this time:
Verify that SSH to both VMs is available and up. You might need o be patient.
Create bash variables that will be used for setting up the VXLAN mesh
Create the VXLAN device and mesh on vm-1
Create the VXLAN device and mesh on vm-2
Start a tcpdump on vm-1
In another session ping vm-2 from vm-1 and take a look at tcpdump output. Notice the arp.