joepa37
joepa37

Reputation: 23

Create GCloud VM instance with no VPC

I need to create a Google Compute Engine Virtual Machine instance with no VPC.

For the App environment that I am using, I need to use the Public IP Address directly such as DigitalOcean Droplet, so if I run ifconfig command should show the interface with the public IP Address.

Upvotes: 6

Views: 1512

Answers (3)

James Dean
James Dean

Reputation: 4461

There is a way to do it(not the vpc part because it's not possible but to see the external IP directly on vm). steps are below:

  1. Launch a VM in VPC first, while launching, in networking section, set the IP-Forwarding on. --> do it while creating, once the vm is created, you can't do that.

  2. Reserve a External IP in your project and vpc.

  3. In the VPC routing, create a route and for destination network x.x.x.x/32 (reserved Public IP) --> point the next hop as the VM.

  4. In VM, create a Sub interface and assign the public IP directly using ip addr.

Note: This works only if you're able to reach to VPC, example: VPN to access the VM over public IP.

Upvotes: 0

Adi Dembak
Adi Dembak

Reputation: 2556

Each Compute Engine instance belongs to at least one VPC network. The use case you are describing is likely impossible given GCP's software-defined network architecture.

Upvotes: 3

Wojtek_B
Wojtek_B

Reputation: 4443

You can't create a VM in GCP without it belonging to some VPC. Console gui won't allow you that - you just have to have at least one interface.

But - there's a workaround;

  • ssh to your VM and create additional user & password; add this user to sudo group: (adduser username; echo 'sudouser:userspass' | chpasswd; usermod -aG google-sudoers sudouser)
  • logout
  • enable serial-console interactive aceess
  • login using serial console
  • disable all network interfaces

This way you will have a VM with only a serial console access - however I didn't try this myself.

Upvotes: 0

Related Questions