Week7 - Selesfia/ComputerNetwork GitHub Wiki

Create VPC Network (Auto and Custom)

Auto

  1. Go to GCP platform -> VPC Networks -> Create VPC Networks
  2. Give it a name "mygcp1"
  3. Subnet Creation Mode -> Auto
  4. Firewall Rules -> allow-icmp, allow-ssh
  5. Click create

Custom

  1. Go to GCP platform -> VPC Networks -> Create VPC Network
  2. Give it a name "mygcp2"
  3. Subnet Creation Mode -> Custom
  4. Subnet -> Edit subnet -> Give a name "asia-ast1" -> Choose region -> IPv4 range "192.168.1.0/24"
  5. Click create

Creating Firewall Rule1

  1. Go to Network Securities -> Firewall Policies -> Create Firewall Rule
  2. Give a name "mygcp1-allow-ssh" -> Network choose "mygcp1" -> Target change to "All instances in the network" -> Source IPv4 "0.0.0.0/0"
  3. Protocols and ports -> TCP "22"

Creating Firewall Rule2

  1. Go to Network Securities -> Firewall Policies -> Create Firewall Rule
  2. Give a name "mygcp2-allow-ssh" -> Network choose "mygcp2" -> Target change to "All instances in the network" -> Source IPv4 "0.0.0.0/0"
  3. Protocols and ports -> TCP "22" -> Other "icmp"

Create 2 VM

(VM1)

  1. Compute Engine -> New Instance
  2. Give a name "myvm-myvpc1" -> Change to N1 and Ubuntu
  3. Advance Options -> Network Interface -> Network -> Choose "mygcp1"
  4. Click create

(VM2)

  1. Compute Engine -> New Instance
  2. Give a name "myvm-myvpc2" -> Change to N1 and Ubuntu
  3. Advance Options -> Network Interface -> Network -> Choose "mygcp2"
  4. Click create

Create Peering Connection

Peering Connection 1

  1. Go to VPC Network Peering -> Create Peering Connection -> Continue
  2. Give a name "myvpc1-mygcp2" -> Your VPC Network "mygcp1" -> VPC Network name "mygcp2"
  3. Click create

Peering Connection 2

  1. Go to VPC Network Peering -> Create Peering Connection -> Continue
  2. Give a name "myvpc2-mygcp1" -> Your VPC Network "mygcp2" -> VPC Network name "mygcp1"
  3. Click create

Check Connection

  1. Connect SSH for both VM
  2. At VM1 $ ip addr show #to check ip address
  3. At VM2 $ ping 10.140.0.2

PS : Remember to delete the resources that you created if you don't use it anymore.

22/10/2024