Skip to content

Instantly share code, notes, and snippets.

@syeef
Created October 7, 2019 12:39
Show Gist options
  • Save syeef/2e4888c24cbe03ec5913ee09f670dfc3 to your computer and use it in GitHub Desktop.
Save syeef/2e4888c24cbe03ec5913ee09f670dfc3 to your computer and use it in GitHub Desktop.
//Creates the External IP address within region us-east4 (you may have to just enter the command and then select option 19)
gcloud compute addresses create unifi-external \
--region us-east4
//Create the Firewall Rules required to have Unifi work
gcloud compute firewall-rules create "unifi-http" \
--allow tcp:80,tcp:8443,tcp:8880,tcp:8843 \
--description="Ports used for HTTP and HTTPS on non-standard ports https://help.ubnt.com/hc/en-us/articles/218506997-UniFi-Ports-Used" \
--target-tags=unifi-server
gcloud compute firewall-rules create "unifi-inform" \
--allow tcp:8080 \
--description="Port for device and controller communication" \
--target-tags=unifi-server
gcloud compute firewall-rules create "unifi-stun" \
--allow udp:3478 \
--description="Port used for STUN" \
--target-tags=unifi-server
gcloud compute firewall-rules create "unifi-throughput" \
--allow tcp:6789 \
--description="Port used for UniFi mobile speed test" \
--target-tags=unifi-server
//Create the VM
gcloud compute instances create unifi-controller \
--machine-type f1-micro \
--image-family debian-9 \
--image-project debian-cloud \
--boot-disk-type pd-standard \
--boot-disk-size 15GB \
--zone us-east4-b \
--description "Unifi Controller" \
--scopes=default,storage-rw \
--tags unifi-server \
--address unifi-external \
--metadata=startup-script-url=gs://petri-unifi/startup.sh,timezone=Europe/London,dns-name=ENTER.YOUR.DOMAIN.HERE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment