아보카도 오일 등급

아보카도 오일은 여러 가지 등급으로 나뉘며, 이는 품질과 가공 방식에 따라 다릅니다. 여기에는 주로 세 가지 등급이 포함됩니다:

  1. 엑스트라 버진 아보카도 오일: 이는 최고 품질의 아보카도 오일이며, 첫 번째 압착 과정에서 추출됩니다. 이 오일은 가장 부드럽고 미묘한 맛을 가지며, 높은 온도에서는 사용하지 않는 것이 좋습니다.
  2. 버진 아보카도 오일: 이는 엑스트라 버진 오일과 매우 유사하며, 첫 번째 압착에서 얻어집니다. 그러나 이 오일은 엑스트라 버진 오일보다 약간 더 강한 맛을 가지고 있을 수 있습니다.
  3. 순수한 아보카도 오일: 이 오일은 더 많은 가공을 거칩니다. 이로 인해 오일이 높은 온도에 잘 견딜 수 있게 되므로, 요리에 더 넓게 사용될 수 있습니다.

비공개 Kubernetes 클러스터 설정

GSP178

영역설정
gcloud config set compute/zone us-central1-a
gcloud compute zones list

비공개 클러스터 만들기
gcloud beta container clusters create private-cluster \
    --private-cluster \
    --master-ipv4-cidr 172.16.0.16/28 \
    --enable-ip-alias \
    --create-subnetwork ""

서브넷 및 보조 IP 주소 범위 확인
gcloud compute networks subnets list --network default

조회결과
gke-private-cluster-subnet-7aee73db

gcloud compute networks subnets describe gke-private-cluster-subnet-7aee73db \
--region us-central1

마스터 승인 네트워크 사용 설정

vm 인스턴스 만들기
gcloud compute instances create source-instance --zone us-central1-a --scopes 'https://www.googleapis.com/auth/cloud-platform'

nat ip 확인
gcloud compute instances describe source-instance --zone us-central1-a | grep natIP

natIP: 34.70.56.122

gcloud container clusters update private-cluster \
    --enable-master-authorized-networks \
    --master-authorized-networks 34.70.56.122/32


source-instance 에 SSH 접속
gcloud compute ssh source-instance --zone us-central1-a

kubectl 구성요소 설치
gcloud components install kubectl

(실패할 경우)
sudo apt-get install kubectl

SSH 쉘에서 Kubernetes 클러스터 액세스 권한 설정하기
gcloud container clusters get-credentials private-cluster --zone us-central1-a

클러스터 노드에 외부 IP 주소가 없는지 확인하기
kubectl get nodes --output yaml | grep -A4 addresses

  응답 메세지 중 type 값이 모두 InternalIP, InternalDNS 만 검색 됨

Kubernetes 클러스터 삭제
gcloud container clusters delete private-cluster --zone us-central1-a

사용자 지정 하위 네트워크를 사용하는 비공개 클러스터 만들기

1.하위 네트워크 및 보조 범위 만들기
gcloud compute networks subnets create my-subnet \
    --network default \
    --range 10.0.4.0/22 \
    --enable-private-ip-google-access \
    --region us-central1 \
    --secondary-range my-svc-range=10.0.32.0/20,my-pod-range=10.4.0.0/14


2. 하위 네트워크를 사용하는 비공개 클러스터 만들기
gcloud beta container clusters create private-cluster2 \
    --private-cluster \
    --enable-ip-alias \
    --master-ipv4-cidr 172.16.0.32/28 \
    --subnetwork my-subnet \
    --services-secondary-range-name my-svc-range \
    --cluster-secondary-range-name my-pod-range


3.외부 IP 주소 확인
gcloud compute instances describe source-instance --zone us-central1-a | grep natIP

4.외부IP 주소 적용
gcloud container clusters update private-cluster2 \
    --enable-master-authorized-networks \
    --master-authorized-networks 34.70.56.122/32

5.source-instance 에 SSH 접속
gcloud compute ssh source-instance --zone us-central1-a

6.SSH 쉘에서 Kubernetes 클러스터 액세스 권한 설정
gcloud container clusters get-credentials private-cluster2 --zone us-central1-a

7.클러스터 노드에 외부 IP 주소가 없는지 확인
kubectl get nodes --output yaml | grep -A4 addresses

VPC Network Peering

Overview

Google Cloud Virtual Private Cloud (VPC) Network Peering allows private connectivity across two VPC networks regardless of whether or not they belong to the same project or the same organization.

VPC Network Peering is useful for :

  • Organizations with several network administrative domains.
  • Organizations that want to peer with other organizations.

If you have multiple network administrative domains within your organizations, VPC Network Peering allows you to make services available across VPC networks in private space. VPC Network Peering allows you to make those services available in private space to those organizations. The ability to offer services across organizations is useful if you want to offer services to other enterprises, and it is useful within your own enterprise if you have several distinct organization nodes due to your own structure or as a result of mergers or acquisitions.

VPC Network Peering gives you serveral advantages over using external IP addresses or VPNs to connect networks, including:

  • Network Latency : Private networking offeres lower latency than public IP networking.
  • Network Security : Service owners do not need to have their services exposed to the public internet and deal with its associated risks.
  • Network Cost : Networks that are peered can use internal IPs to communicate and save Google Cloud egress bandwidth costs. Regular network pricing still applies to all traffic.

VPC Network Peering setup

Within the same organization node, a network could be hosting services that need to be accessible from other VPC networks in the same or different projects.

Alternatively, one organization may want to access services a third-party services offering

Create network-A VPC

gcloud compute networks create network-a --subnet-mode custom

gcloud compute networks subnets create network-a-central --network network-a --range 10.0.0.0/16 --region us-central1

gcloud compute instances create vm-a --zone us-central1-a --network network-a --subnet network-a-central

gcloud compute firewall-rules create network-a-fw --network network-a --allow tcp:22,icmp

Create network-B VPC

gcloud compute network create network-b --subnet-mode custom

gcloud compute network subnets create network-b-central --network network-b --range 10.8.0.0/16 --region us-central1

gcloud compute instances create vm-b --zone us-central1-a --network network-b --subnet network-b-central

ggcloud compute firewall-rules create network-b-fw --network network-b --allow tcp:22,icmp

Peer network -a with network-b (peer-ab)

VPC Network > VPC network peering > Create Connection > Continue
  Name : peer-ab
  Your VPC network : network-a
  Peering VPC network : (Radio Button) In another project
  Project ID : 'second project id'
  VPC network name : network-b
Create

Peer network-b with network-a (peer-ba)

VPC Network > VPC network peering > Create Connection > Continue
  Name : peer-ba
  Your VPC network : network-b
  peering VPC network : (Radio Button) In another project
  Project ID : 'first project id'
  VPC Network name : network-a
Create
Final result
gcloud compute routes list --project <First_Project_ID>

Connectivity Test

Copy the internal ip for vm-a

ssh into vm-b instance

ping -c 5 <internal ip of vm-a>

IAM Custom Roles

Understanding IAM Custom Roles

You can create a custom role at the organization level and at the project level. However, you cannot create custom roles at the folder level

permissions are represented in the form

<service>.<resource>.<verb>

compute.instances.list

Custom roles can only be used to grant permissions in policies for the same project or organization that owns the roles or resource under them.

Required permissions and roles

To create a custom role, a caller must have the iam.roles.create permission.

Organization Role Administrator role (roles/iam.organizationRoleAdmin)

IAM Role Administrator role (roles/iam.roleAdmin)

Viewing the available permissions for resource

gcloud iam list-testable-permissions

Getting the role metadata

gcloud iam roles describe [ROLE_NAME]

gcloud iam roles describe roles/viewer
gcloud iam roles describe roles/editor

To create a custom role using a YAML file

vi role-definition.yaml

title: "Role Editor"
description: "Edit access for App Versions"
stage: "ALPHA"
includedPermissions:
- appengine.versions.create
- appengine.versions.delete

gcloud iam roles create editor --project $DEVSHELL_PROJECT_ID \
--file role-definition.yaml

Created role [editor].
description: Edit access for App Versions
etag: BwVs4O4E3e4=
includedPermissions:
- appengine.versions.create
- appengine.versions.delete
name: projects/[PROJECT_ID]/roles/editor
stage: ALPHA
title: Role Editor

Create a custom role using flags

gcloud iam roles create viewer --project $DEVSHELL_PROJECT_ID \
--title "Role Viewer" --description "Custom role description." \
--permissions compute.instances.get,compute.instances.list --stage ALPHA

Created role [viewer].
description: Custom role description.
etag: BwVs4PYHqYI=
includedPermissions:
- compute.instances.get
- compute.instances.list
name: projects/[PROJECT_ID]/roles/viewer
stage: ALPHA
title: Role Viewer

Listing the custom roles

gcloud iam roles list --project $DEVSHELL_PROJECT_ID

Editing an existing custom role

To update a custom role using a YAML file

gcloud iam roles describe editor --project $DEVSHELL_PROJECT_ID]

description: Edit access for App Versions
etag: BwXCsFdYv0o=
includedPermissions:
- appengine.versions.create
- appengine.versions.delete
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/editor
stage: ALPHA
title: Role Editor

vi new-role-definition.yaml

description: Edit access for App Versions
etag: BwVxIBjfN3M=
includedPermissions:
- appengine.versions.create
- appengine.versions.delete
- storage.buckets.get
- storage.buckets.list
name: projects/[PROJECT_ID]/roles/editor
stage: ALPHA
title: Role Editor
gcloud iam roles update editor --project $DEVSHELL_PROJECT_ID --file new-role-definition.yaml

To update a custom role using flags

gcloud iam roles describe viewer --project $DEVSHELL_PROJECT_ID

description: Custom role description.
etag: BwXCsFyYXGs=
includedPermissions:
- compute.instances.get
- compute.instances.list
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/viewer
stage: ALPHA
title: Role Viewer

gcloud iam roles update viewer --project $DEVSHELL_PROJECT_ID --add-permissions storage.buckets.get,storage.buckets.list


description: Custom role description.
etag: BwXCsIGVf6M=
includedPermissions:
- compute.instances.get
- compute.instances.list
- storage.buckets.get
- storage.buckets.list
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/viewer
stage: ALPHA
title: Role Viewer

Disabling a custom role

gcloud iam roles update viewer --project $DEVSHELL_PROJECT_ID --stage DISABLED

description: Custom role description.
etag: BwXCsIeZQcs=
includedPermissions:
- compute.instances.get
- compute.instances.list
- storage.buckets.get
- storage.buckets.list
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/viewer
stage: DISABLED
title: Role Viewer

Deleting a custom role

gcloud iam roles delete viewer --project $DEVSHELL_PROJECT_ID

deleted: true
description: Custom role description.
etag: BwXCsIpRAkM=
includedPermissions:
- compute.instances.get
- compute.instances.list
- storage.buckets.get
- storage.buckets.list
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/viewer
stage: DISABLED
title: Role Viewer

The role can be undeleted within 7 days

After 7 days, the role enters a permanent deletion process that lasts 30 days

After 37 days, the Roel ID is available to be used again

Undeleting a custom role

gcloud iam roles undelete viewer --project $DEVSHELL_PROJECT_ID

description: Custom role description.
etag: BwXCsJhLFsY=
includedPermissions:
- compute.instances.get
- compute.instances.list
- storage.buckets.get
- storage.buckets.list
name: projects/qwiklabs-gcp-03-867ca1078c1e/roles/viewer
stage: DISABLED
title: Role Viewer

Cloud Monitoring: Qwik Start

Create a Compute Engine instance

Add Apache2 HTTP Server to our instace

metadata 부분에 아래와 같은 스크립트 추가

key / value
startup-script / 

#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2 php7.0
sudo service apache2 restart

Create a Monitoring workspace

Install the Monitoring and Logging agents

curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh

sudo apt-get update

sudo apt-get install stackdriver-agent

sudo apt-get install google-fluentd

Create an uptime check

Monitoring > Uptime Check > CREATE UPTIME CHECK

Create an alerting policy

Monitoring > Alerting > CREATE POLICY

Create a dashboard and chart

좀 기네…이건 다시 공부해야할듯

Cloud IAM: Qwik Start

  • Viewer 권한은 Cloud Storage 에 버킷과 파일명은 보이지만 내용을 볼 수 없었음
  • 사용자 2에게 Project Viewer 권한을 제거시
    • 프로젝트 권한 자체가 없어 아무것도 볼 수 없음
  • 사용자 2에게 Cloud Storage Viewer 권한 부여시
    • 프로젝트 페이지는 보여짐
    • Cloud Shell 접근 가능함
      • gsutil ls gs://hungry-000

Build and Secure Networks in Google Cloud: Challenge Lab Answer

개념 구성도
  1. Firewall
    1. 최초에 있었던 정책을 지운다
  2. Compute Engine
    1. bastion vm 에 edit 에서 network tag 로 bastion 기재
    2. jucie-shop vm 에 edit 에서 network tag 로 web-server 기재
  3. Firewall
    1. allow-bastion-iap 정책 신규 추가
      1. network : acme-vpc
      2. source : 35.235.240.0/20
      3. port : TCP 만 선택
    2. allow-bastion-ssh 정책 신규 추가
      1. network : acme-vpc
      2. source : 0.0.0.0/0
      3. port : TCP 22
  4. Security -> IAP
    1. SSH & TCP 리소스 탭 선택
    2. bastion 클릭
    3. add member
      1. 구성원 : 해당 qwiklab 로긴 ID
      2. 역할 : Cloud IA/P > IAP Secure turnaled user
  5. Firewall
    1. allow-ssh-bastion-webserver 정책 생성
      1. source tag : 192.168.10.0/24
      2. target tag : web-server
      3. port : TCP 80

User Authentication: Identity-Aware-Proxy

Python을 사용해 간단한 App Engine 앱을 작성 및 배포

git clone https://github.com/googlecodelabs/user-authentication-with-iap.git

cd user-authentication-with-iap
cd 1-HelloWorld

gcloud app deploy

(실행결과)
Please enter your numeric choice:  2 

Creating App Engine application in project [qwiklabs-gcp-02-c8004de5b58e] and region [asia-northeast1]....done.
Services to deploy:

descriptor:      [/home/student_02_86e97cfc3a04/user-authentication-with-iap/1-HelloWorld/app.yaml]
source:          [/home/student_02_86e97cfc3a04/user-authentication-with-iap/1-HelloWorld]
target project:  [qwiklabs-gcp-02-c8004de5b58e]
target service:  [default]
target version:  [20210513t082853]
target url:      [https://qwiklabs-gcp-02-c8004de5b58e.an.r.appspot.com]


Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 6 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
ERROR: (gcloud.app.deploy) NOT_FOUND: Unable to retrieve P4SA: [service-942148416139@gcp-gae-service.iam.gserviceaccount.com] from GAIA. Could be GAIA propagation delay or request from deleted apps.
student_02_86e97cfc3a04@cloudshell:~/user-authentication-with-iap/1-HelloWorld (qwiklabs-gcp-02-c8004de5b58e)$

(안되서 다시함)

student_02_86e97cfc3a04@cloudshell:~/user-authentication-with-iap/1-HelloWorld (qwiklabs-gcp-02-c8004de5b58e)$ gcloud app deploy
Services to deploy:

descriptor:      [/home/student_02_86e97cfc3a04/user-authentication-with-iap/1-HelloWorld/app.yaml]
source:          [/home/student_02_86e97cfc3a04/user-authentication-with-iap/1-HelloWorld]
target project:  [qwiklabs-gcp-02-c8004de5b58e]
target service:  [default]
target version:  [20210513t083521]
target url:      [https://qwiklabs-gcp-02-c8004de5b58e.an.r.appspot.com]


Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 0 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://qwiklabs-gcp-02-c8004de5b58e.an.r.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse
student_02_86e97cfc3a04@cloudshell:~/user-authentication-with-iap/1-HelloWorld (qwiklabs-gcp-02-c8004de5b58e)$

배포된 앱 확인

gcloud app browse

(실행결과)
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-02-c8004de5b58e.an.r.appspot.com
student_02_86e97cfc3a04@cloudshell:~/user-authentication-with-iap/1-HelloWorld (qwiklabs-gcp-02-c8004de5b58e)$

(배포 성공 후 다시)
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-02-c8004de5b58e.an.r.appspot.com
student_02_86e97cfc3a04@cloudshell:~/user-authentication-with-iap/1-HelloWorld (qwiklabs-gcp-02-c8004de5b58e)$

안되는 것처럼 보이지만 배포된 화면은 보여짐

앱에 대한 액세스를 제한하기 위해 IAP 활성화 및 비활성화 방법

IAP 에서 앱으로 사용자 신원 정보를 가져오는 방법

스푸핑으로부터 IAP의 정보를 암호화 방식으로 확인 하는 방법

어플리케이션 배포 및 IAP 로 보호

사용자 신원 정보 접근

암호화 확인 사용

Google Cloud Packet Mirroring with OpenSource IDS

  • 한 VPC 안에 2개의 subnet이 존재
    • 웹서버 (수집 대상)
      • Public IP 할당
    • 수집서버 (IDS Suricata)
      • Public IP 미할당
  • Cloud NAT 서비스는 외부 인터넷 접근을 가능케 함
  • 모든 vm 인스턴스는 같은 region, zone 에 존재 (간단하고, 비용측면)
  • iLB_Collectors (Cloud Load Balancer) 를 미러모드로 설정하여 IDS로 패킷을 보냄

Build a networking footprint

1. VPC 생성
gcloud compute networks create dm-stamford \
--subnet-mode=custom

2. 웹서버용 서브넷 생성
gcloud compute networks subnets create dm-stamford-uswest4 \
--range=172.21.0.0/24 \
--network=dm-stamford \
--region=us-west4

3. IDS용 서브넷 생성
gcloud compute networks subnets create dm-stamford-uswest4-ids \
--range=172.21.1.0/24 \
--network=dm-stamford \
--region=us-west4

Create firewall rules

1. 모든 VM이 TCP80, ICMP 프로토콜을 모든 소스로부터 받을 수 있도록 방화벽 정책 생성
gcloud compute firewall-rules create fw-dm-stamford-allow-any-web \
--direction=INGRESS \
--priority=1000 \
--network=dm-stamford \
--action=ALLOW \
--rules=tcp:80,icmp \
--source-ranges=0.0.0.0/0

2. IDS 가 모든 트래픽을 받을 수 있도록 방화벽 정책 생성 (Public IP를 할당하지 않는건 여기서 하지않음)
gcloud compute firewall-rules create fw-dm-stamford-ids-any-any \
--direction=INGRESS \
--priority=1000 \
--network=dm-stamford \
--action=ALLOW \
--rules=all \
--source-ranges=0.0.0.0/0 \
--target-tags=ids

3. 모든 VM이 tcp22, icmp 프로토콜을 GCP IAP Proxy IP 대역 (35.235.240.0/20)에서 접근 할 수 있도록 방화벽 정책 설정
gcloud compute firewall-rules create fw-dm-stamford-iapproxy \
--direction=INGRESS \
--priority=1000 \
--network=dm-stamford \
--action=ALLOW \
--rules=tcp:22,icmp \
--source-ranges=35.235.240.0/20

Create a CloudRouter

1. Cloud NAT 를 사용하려면 Cloud Router 설정이 선행되어야 함. 각자 Region 에서 반드시 가장 먼저 설정되어야함.

gcloud compute routers create router-stamford-nat-west4 \
--region=us-west4 \
--network=dm-stamford

Configure a Cloud NAT

1. Public IP 없이 인터넷 접근을 허용하려면 Cloud NAT 는 반드시 각 리전에 생성되어야 함

gcloud compute routers nats create nat-gw-dm-stamford-west4 \
--router=router-stamford-nat-west4 \
--router-region=us-west4 \
--auto-allocate-nat-external-ips \
--nat-all-subnet-ip-ranges

Create an Instance Template for a WebServer

1. 웹서버용 인스턴스 템플릿 생성

gcloud compute instance-templates create template-dm-stamford-web-us-west4 \
--region=us-west4 \
--network=dm-stamford \
--subnet=dm-stamford-uswest4 \
--machine-type=g1-small \
--image=ubuntu-1604-xenial-v20200807 \
--image-project=ubuntu-os-cloud \
--tags=webserver \
--metadata=startup-script='#! /bin/bash
  apt-get update
  apt-get install apache2 -y
  vm_hostname="$(curl -H "Metadata-Flavor:Google" \
  http://169.254.169.254/computeMetadata/v1/instance/name)"
  echo "Page served from: $vm_hostname" | \
  tee /var/www/html/index.html
  systemctl restart apache2'

Create a Managed Instance Group for the WebServers

1. 웹서버용 인스턴스 그룹 생성

gcloud compute instance-groups managed create mig-dm-stamford-web-uswest4 \
    --template=template-dm-stamford-web-us-west4 \
    --size=2 \
    --zone=us-west4-a

Create an Instance Template for the IDS VM

1. IDS용 인스턴스 탬플릿 생성

gcloud compute instance-templates create template-dm-stamford-ids-us-west4 \
--region=us-west4 \
--network=dm-stamford \
--no-address \
--subnet=dm-stamford-uswest4-ids \
--image=ubuntu-1604-xenial-v20200807 \
--image-project=ubuntu-os-cloud \
--tags=ids,webserver \
--metadata=startup-script='#! /bin/bash
  apt-get update
  apt-get install apache2 -y
  vm_hostname="$(curl -H "Metadata-Flavor:Google" \
  http://169.254.169.254/computeMetadata/v1/instance/name)"
  echo "Page served from: $vm_hostname" | \
  tee /var/www/html/index.html
  systemctl restart apache2'

Create a Managed Instance Group for the IDS VM

1. IDS용 인스턴스 그룹 생성

gcloud compute instance-groups managed create mig-dm-stamford-ids-uswest4 \
    --template=template-dm-stamford-ids-us-west4 \
    --size=1 \
    --zone=us-west4-a

Create Internal LoadBalancer

1. 복제된 패킷을 수집서버에 전달함 (내부 로드벨런서). 여기서는 수집 그룹 컨테이너는 단일 VM 임

2. 먼저 백단 서버 체크하는 헬스체크 생성
gcloud compute health-checks create tcp hc-tcp-80 --port 80

3. ilb가 사용하는 백엔드 서비스 생성
gcloud compute backend-services create be-dm-stamford-suricata-us-west4 \
--load-balancing-scheme=INTERNAL \
--health-checks=hc-tcp-80 \
--network=dm-stamford \
--protocol=TCP \
--region=us-west4

4. IDS 인스턴스 이전 단계에서 만든 백엔드 서비스 그룹에 추가
gcloud compute backend-services add-backend be-dm-stamford-suricata-us-west4 \
--instance-group=mig-dm-stamford-ids-uswest4 \
--instance-group-zone=us-west4-a \
--region=us-west4

5. IDS 인스턴스로 보낼 frontend 전달 규칙 생성
 gcloud compute forwarding-rules create ilb-dm-stamford-suricata-ilb-us-west4 \
 --load-balancing-scheme=INTERNAL \
 --backend-service be-dm-stamford-suricata-us-west4 \
 --is-mirroring-collector \
 --network=dm-stamford \
 --region=us-west4 \
 --subnet=dm-stamford-uswest4-ids \
 --ip-protocol=TCP \
 --ports=all

Install Open Source IDS – Suricata

sudo apt-get update -y

sudo apt-get install libpcre3-dbg libpcre3-dev autoconf automake libtool libpcap-dev libnet1-dev libyaml-dev zlib1g-dev libcap-ng-dev libmagic-dev libjansson-dev libjansson4 -y

sudo apt-get install libnspr4-dev -y

sudo apt-get install libnss3-dev -y

sudo apt-get install liblz4-dev -y

sudo apt install rustc cargo -y

sudo add-apt-repository ppa:oisf/suricata-stable -y

sudo apt-get update -y

sudo apt-get install suricata -y

suricata -V
This is Suricata version 6.0.2 RELEASE

Configure and review Suricata

sudo systemctl stop suricata

sudo cp /etc/suricata/suricata.yaml /etc/suricata/suricata.backup

wget https://storage.googleapis.com/tech-academy-enablement/GCP-Packet-Mirroring-with-OpenSource-IDS/suricata.yaml
wget https://storage.googleapis.com/tech-academy-enablement/GCP-Packet-Mirroring-with-OpenSource-IDS/my.rules
sudo mkdir /etc/suricata/poc-rules
sudo cp my.rules /etc/suricata/poc-rules/my.rules
sudo cp suricata.yaml /etc/suricata/suricata.yaml

Start the Suricata service

sudo systemctl start suricata
sudo systemctl restart suricata

Review Simple Suricata rules for testing

Configure Packet Mirror Policy

gcloud compute packet-mirrorings create mirror-dm-stamford-web \
--collector-ilb=ilb-dm-stamford-suricata-ilb-us-west4 \
--network=dm-stamford \
--mirrored-subnets=dm-stamford-uswest4 \
--region=us-west4

Test Packet Mirroring

패스..

Generate traffic to the “mirrored” subnet

패스..

Test Suricata IDS inspection and alerts

패스..