1. Deploy PNETLab on Google cloud by APT

Step 1: 

Go to https://console.cloud.google.com/home/dashboard

You will have 300$ free in 90 days.

Step 2: 

  1. Select your project
  2. Click to Button to open terminal
  3. Make sure the Project ID is set.

 

Step 3: 

Run below command in Terminal.

  • gcloud compute images create nested-ubuntu-xenial --source-image-family=ubuntu-1804-lts --source-image-project=ubuntu-os-cloud --licenses https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx

Step 4:

  • Create a new VM instance base on the images built from Step 3

 

 

Step 5:

  • SSH to Instance run below commands:
    • sudo -i
    • echo "deb [trusted=yes] http://repo.pnetlab.com ./" | tee -a /etc/apt/sources.list
    • apt-get update
    • apt-get install pnetlab
  • Run command:
    • sudo rm /etc/default/grub.d/50-cloudimg-settings.cfg
  • Create Swap memory: (This memory is located on the hard disk. It serves as the support for the RAM in case the RAM is full. It should be set to half of the RAM.)
    • sudo fallocate -l 1G /swapfile (You can change the size of Swap as your wish)
    • sudo chmod 600 /swapfile
    • sudo mkswap /swapfile
    • sudo swapon /swapfile
    • sudo cp /etc/fstab /etc/fstab.bak
    • echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  • After finish access to PNETLab by public ip http or https
  • System > System setting > Click on Fixpermissions Button.
  • Change Root password:
    • sudo -i
    • passwd
    • fill your password

 

2. Deploy PNETLab on Google cloud by .OVA.

Step 1: 

Go to https://console.cloud.google.com/home/dashboard

You will have 300$ free in 90 days.

Step 2: 

Go to  Storage > Create a Bucket > Upload .OVA to bucket you created.

Step 3: 

  1. Select your project
  2. Click to Button to open terminal
  3. Make sure the Project ID is set.

Run below commands to import it will take about 40 minutes

gcloud config set compute/zone [zone]

gcloud compute instances import pnetlab-temp --source-uri=gs://[path to ova on bucket] --os=ubuntu-1804

  • zone: to get list zone refer: https://console.cloud.google.com/compute/zones or run command: gcloud compute zones list
  • If your ova path contain space characters insert \ before them.
  • Example:
    • gcloud config set compute/zone asia-east1-a
    • gcloud compute instances import pnetlab-temp --source-uri=gs://storagevl/PNETLab_2.0.1.ova --os=ubuntu-1804
  • Note: After the command finished, Shutdown pnetlab-temp instance

Step 4: 

Create nested image, need to run qemu devices. Run below command

gcloud compute images create nested-pnetlab-image --source-disk pnetlab-temp --source-disk-zone [zone] --licenses "https://compute.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"

Step 5: 

Create compute instance with nested images: 

gcloud compute instances create pnetlab --zone [zone] --min-cpu-platform "Intel Haswell" --image nested-pnetlab-image

  • Example: gcloud compute instances create pnetlab --zone us-central1-b --min-cpu-platform "Intel Haswell" --image nested-pnetlab-image

Step 6: 

  • Go to Compute you can see 2 instances pnetlab and pnetlab-temp. You can delete pnetlab-temp instance.
  • Edit pnetlab instance make sure enable http and https traffic

Step 7: 

SSH to device

Run 3 command on the open terminal.

  • sudo -i
  • hostname pnetlab
  • echo "pnetlab" > /etc/hostname
  • Change Root password:
    • sudo -i
    • passwd
    • fill your password

Edit the file /etc/network/interfaces like bellow then Reboot pnetlab instance. (External IP will be changed after reboot)

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

 

# The loopback network interface

auto lo

iface lo inet loopback

 

# The primary network interface

iface eth0 inet manual

auto pnet0

iface pnet0 inet dhcp

   bridge_ports eth0

   bridge_stp off

 

# Cloud devices

iface eth1 inet manual

auto pnet1

iface pnet1 inet manual

   bridge_ports eth1

   bridge_stp off

 

iface eth2 inet manual

auto pnet2

iface pnet2 inet manual

   bridge_ports eth2

   bridge_stp off

 

iface eth3 inet manual

auto pnet3

iface pnet3 inet manual

   bridge_ports eth3

   bridge_stp off

 

iface eth4 inet manual

auto pnet4

iface pnet4 inet manual

   bridge_ports eth4

   bridge_stp off

 

iface eth5 inet manual

auto pnet5

iface pnet5 inet manual

   bridge_ports eth5

   bridge_stp off

 

iface eth6 inet manual

auto pnet6

iface pnet6 inet manual

   bridge_ports eth6

   bridge_stp off

 

iface eth7 inet manual

auto pnet7

iface pnet7 inet manual

   bridge_ports eth7

   bridge_stp off

 

iface eth8 inet manual

auto pnet8

iface pnet8 inet manual

   bridge_ports eth8

   bridge_stp off

 

iface eth9 inet manual

auto pnet9

iface pnet9 inet manual

   bridge_ports eth9

   bridge_stp off

Check virtualization enable by command:  grep -cw vmx /proc/cpuinfo It should return 1 or number of CPU core you selected

Now you can access to PNETLab box by External IP. (access by http not https)

Note: 

  • To console to device you have switch to HTML Console.
  • The default account is : root/eve. Please change the pass because your box is public.
  • All devices on the labs should have password when console to them.

 

 

3. Expand RAM, CPU, HDD

To edit Ram, CPU, HDD you need to shut PNETLab down first then click on Edit button.

  • RAM and CPU are attached together. You can drop down and select one of those options. ( Note:The higher the ram and the CPU, the more money you will lose. Choose enough for you)

 

 - To expand the hard disk click on Add new Disk button.

Note: 

  • To save money and trial time. Please choose as small as possible
  • 200G is the minimum that google recommends so as not to lose performance
  • Very easy to add more hard disk, but very difficult to remove a hard disk. It can crash your PNETLab instance.

 

  • Click on Save button and start it again.
  • Check to confirm new HDD by command: df -h