-
Notifications
You must be signed in to change notification settings - Fork 50
Security Group Rules and Driver API
ByoungSeob Kim edited this page Apr 5, 2022
·
47 revisions
-
VM의 in/out 네트워크 트래픽 제어를 위해서 특정 VPC에 소속되는 Security Group을 정의할 수 있다.
-
Security Group은 하나 이상의 규칙을 포함할 수 있으며, 허용 규칙을 정의한다. (Allow Rule)
-
Security Group 생성 시에는 최소 1개 이상의 Rule을 포함해야 하며, 이후 Rule을 추가 삭제할 수 있다.
-
Security Group 생성 시 default Rule은 다음과 같고, CSP별로 관련 Rule이 보일 수도 있고 안보일 수도 있다.
-
inbound
: 모든 트래픽 차단 -
outbound
: 모든 트래픽 허용
-
-
Rule은 다음과 같은 속성들로 정의할 수 있다.
- Direction: 트래픽 방향
-
inbound
|outbound
-
- Protocol: 대상 프로토콜
-
ALL
: 모든 트래픽 허용 -
TCP
|UDP
|ICMP
-
- Port Range: 대상 포트 범위
-
FromPort: 22
,ToPort: 22
-
FromPort: 1
,ToPort: 65535
-
FromPort: -1
,ToPort: -1
: 포트 설정이 무의미, 또는 모든 포트 대상
-
- Source or Destination: 적용 대상, Address CIDR Block으로 표현
-
0.0.0.0/0
,::/0
,1.2.3.4/32
, ...
-
- Direction: 트래픽 방향
-
CSP Driver 개발 가이드
- Security Group 생성시 대상 CSP의 default Rule 규칙 확인
- Spider default rule과 다를 경우 Spider default rule로 설정 필요
-
ALL
,-1
관련: 대상 CSP에서 Spider와 의미가 다를 경우 변환 처리 필요- ex)
ALL
<--->ANY
- ex)
- Security Group 생성시 대상 CSP의 default Rule 규칙 확인
-
Rule's Data Structure 참고
type SecurityRuleInfo struct { Direction string IPProtocol string FromPort string ToPort string CIDR string }
-
프로토콜별 Rule 세부 규칙 참고
Direction IPProtocol FromPort ToPort CIDR Block (source or destination) 비고 inbound, outbound ALL -1 -1 IPv4 ex) 0.0.0.0/0
IPv6 ex) ::/0* ALL: All traffic inbound, outbound TCP 1~65535
ex) 4431~65535
ex) 443IPv4 ex) 0.0.0.0/8
IPv6 ex) ::/8inbound, outbound UDP 1~65535
ex) 60001~65535
ex) 8000IPv4 ex) 0.0.0.0/32
IPv6 ex) ::/32inbound, outbound ICMP -1 -1 IPv4 ex) 1.2.3.4/32
IPv6 ex) ::/64* ICMP: network layer
- Port 지정 불필요
- ICMP 예시: ping, echo, tracert 등
- 생성한 Security Group에 Rule 추가/삭제 기능 추가
- AddRules(), RemoveRules() API 신규 추가
type SecurityReqInfo struct {
IId IID // {NameId, SystemId}
VpcIID IID // {NameId, SystemId}
Direction string // To be deprecated
SecurityRules *[]SecurityRuleInfo
}
type SecurityRuleInfo struct {
Direction string
IPProtocol string
FromPort string
ToPort string
CIDR string
}
type SecurityInfo struct {
IId IID // {NameId, SystemId}
VpcIID IID // {NameId, SystemId}
Direction string // To be deprecated
SecurityRules *[]SecurityRuleInfo
KeyValueList []KeyValue
}
type SecurityHandler interface {
CreateSecurity(securityReqInfo SecurityReqInfo) (SecurityInfo, error)
ListSecurity() ([]*SecurityInfo, error)
GetSecurity(securityIID IID) (SecurityInfo, error)
DeleteSecurity(securityIID IID) (bool, error)
}
type SecurityReqInfo struct {
IId IID // {NameId, SystemId}
VpcIID IID // {NameId, SystemId}
//Direction string // To be deprecated <=== Deleted
SecurityRules *[]SecurityRuleInfo
}
type SecurityRuleInfo struct {
Direction string
IPProtocol string
FromPort string
ToPort string
CIDR string
}
type SecurityInfo struct {
IId IID // {NameId, SystemId}
VpcIID IID // {NameId, SystemId}
//Direction string // To be deprecated <=== Deleted
SecurityRules *[]SecurityRuleInfo
KeyValueList []KeyValue
}
type SecurityHandler interface {
CreateSecurity(securityReqInfo SecurityReqInfo) (SecurityInfo, error)
ListSecurity() ([]*SecurityInfo, error)
GetSecurity(securityIID IID) (SecurityInfo, error)
DeleteSecurity(securityIID IID) (bool, error)
AddRules(sgIID IID, securityRules *[]SecurityRulesInfo) (SecurityInfo, error) <==== Added
RemoveRules(sgIID IID, securityRules *[]SecurityRulesInfo) (bool, error) <==== Added
}
-
SecurityReqInfo.Direction
과SecurityInfo.Direction
삭제 예정- AdminWeb, Test Scripts, Driver/Test, Tumblebug/Test 등 사용 여부 파악 필요
- 현황 파악 후 현 작업시 삭제 여부 결정 예정
- GCP 이슈: Security Group(GCP:firewall) 정의시 2개 이상의 Rule 포함시 잠재적 오류 발생 가능
- 하나의 Firewall에는 동일 Direction만 포함 가능, 1개의 CIDR 값만 유효
- 관련 Issue: https://github.com/cloud-barista/cb-spider/issues/595
- AWS 이슈: CIDR 값 validation 여부 관련
- NCP Classic 이슈: Security Group 생성은 웹 console로만 가능, API는 List/Get만 가능
-
Security Group으로 생성된 대상 VM을 향한 Test
-
CASE-1: default inbound test
- Test Command
nc -w 2 -zv {$VM_IP} 22
- Expected Results
Connection to {$VM_IP} port [tcp/http] succeeded!
- Test Command
-
WIP
-
이후 생성된 대상 VM에 로그인 후 Test
-
CASE-1: default outbound test
- Test Command
nc -w 2 -zv 142.250.190.99 80
- Expected Results
Connection to 142.250.190.99 80 port [tcp/http] succeeded!
- Test Command
-
CASE-2: remove default outbound test
- 설정: remove default rule (outbound TCP 80 80 0.0.0.0/0)
- Test Command
nc -w 2 -zv 142.250.190.99 80
- Expected Results
nc: connect to 142.250.190.99 port 80 (tcp) timed out: Operation now in progress
-
CASE-3: add outbound 80 port test
- 설정: add rule (outbound TCP 80 80 0.0.0.0/0)
- Test Command
nc -w 2 -zv 142.250.190.99 80
- Expected Results
Connection to 142.250.190.99 80 port [tcp/http] succeeded!
-
Install & Start Guide
-
Features & Usage
-
- AdminWeb Tool Guide
- CLI Tool Guide
- REST API Guide
- NLI Guide
-
Design
-
Developer Guide
-
Cloud Driver Developer Guide
- Cloud Driver Developer Guide-WIP
- VM SSH Key Development Guide-WIP
- VM User Development Guide
- What is the CSP SDK API Version of drivers
- Region Zone Info and Driver API
- (StartVM TerminateVM) API Call Counts and Waiting
- StartVM and TerminateVM Main Flow of drivers
- VM Root Disk Configuration Guide
- Security Group Rules and Driver API
- Network Load Balancer and Driver API
- VM Snapshot, MyImage and Disk Overview
- Kubernetes and Driver API(PMKS, K8S)
- Tag and Cloud Driver API
- AnyCall API Extension Guide
-
Test Reports
- v0.2.8-for-espresso-release
- v0.3.0-espresso-release
- Azure:Terminating VM
- cb-user@VM: ssh login, sudo run
- v0.3.14 test for SG Source
- v0.4.0-cafemocha-release
- Test via REST API Gateway
- Test Reports of v0.4.11 (IID2 initial Version)
- Test Reports of v0.4.12 (Register & Unregister existing Resources)
- Test Reports for v0.6.0 Release
- How to ...
- How to Use Alibaba ECS i1.* Instance Types
- How to provision GPU VMs
- How to Resolve the 'Failed to Connect to Database' Error
- How to test CB Spider with Mock Driver
- How to install CB Spider on WSL2 under 공유기/사설망
- How to install CB Spider on macOS
- How to run CB Spider Container on macOS
- How to install OpenStack on a VM for CB Spider Testing
- How to get Azure available Regions
- How to profile memory usage in Golang
- Deprecated:How to install protoc and plugins
- [For Cloud-Migrator]