AWS Network ACL(NACL)
Complete Guide to AWS Network Security: VPC, NACL, and Security Groups
When building network security in the AWS cloud environment, three fundamental components come into play: Virtual Private Cloud (VPC), Network Access Control Lists (NACLs), and Security Groups. Let’s dive deep into understanding each of these elements.
What is VPC (Virtual Private Cloud)?
A VPC is your logically isolated virtual network within the AWS cloud. It’s similar to a traditional network in your data center but provides the added benefits of using AWS’s scalable infrastructure.
Key Components of VPC
- Subnets
- Subdivisions of your VPC’s IP address range
- Public Subnets: Can communicate directly with the internet
- Private Subnets: No direct internet communication
- Route Tables
- Collection of rules that determine network traffic direction
- Each subnet is associated with one route table
- Internet Gateway
- Enables communication between VPC and the internet
- Required for resources in public subnets to access the internet
- NAT Gateway
- Acts as a mediator for private subnet resources to access the internet
- Prevents direct external access to private subnet resources
What is a NACL?
A Network Access Control List (NACL) is a firewall that operates at the subnet level of your VPC. It consists of a numbered list of rules that control inbound and outbound traffic, allowing or denying network traffic based on these rules.
NACL Rule Configuration
NACL rules consist of the following elements:
- Rule number (1-32766)
- Type (SSH, HTTP, etc.)
- Protocol (TCP, UDP, etc.)
- Port range
- Source/Destination (IP CIDR)
- Allow/Deny
NACL Best Practices
- Space Out Rule Numbers
- Set rule numbers in increments of 100 (100, 200, 300…)
- Makes it easier to insert rules later
- Apply Least Privilege Principle
- Only allow necessary traffic
- Deny all traffic by default and only allow what’s needed
Security Groups
Security Groups act as instance-level firewalls and control traffic differently from NACLs.
Security Group Rule Evaluation
Security group rules are evaluated in the following way:
- Cumulative Evaluation
1 2 3 4
Example Security Group Rules: Rule 1: Allow Port 80 (Source: 10.0.0.0/24) Rule 2: Allow Port 80 (Source: 192.168.1.0/24) Rule 3: Allow Port 443 (Source: 0.0.0.0/0)
- All rules are evaluated as OR conditions
- Traffic is allowed if it matches ANY rule
- Rule order doesn’t matter
- Stateful Firewall
- If inbound traffic is allowed, response traffic is automatically allowed
- Unlike NACLs, no need to set separate outbound rules for responses
NACL vs Security Groups: Key Differences
- Scope of Application
- NACL: Applied at the subnet level
- Security Group: Applied at the instance level
- State Management
- NACL: Stateless (requires separate inbound/outbound rules)
- Security Group: Stateful (automatically allows response traffic)
- Rule Processing
- NACL: Processes rules in numerical order
- Security Group: Evaluates all rules cumulatively
Implementation Examples
NACL Configuration Example
1
2
3
4
5
6
7
8
9
10
11
Inbound Rules:
100 - HTTP(80) - Allow - 0.0.0.0/0
200 - HTTPS(443) - Allow - 0.0.0.0/0
300 - SSH(22) - Allow - COMPANY_IP_RANGE
* - All Traffic - Deny - 0.0.0.0/0
Outbound Rules:
100 - HTTP(80) - Allow - 0.0.0.0/0
200 - HTTPS(443) - Allow - 0.0.0.0/0
300 - Custom TCP(1024-65535) - Allow - 0.0.0.0/0
* - All Traffic - Deny - 0.0.0.0/0
Security Group Configuration Example
1
2
3
4
5
6
7
Inbound Rules:
- HTTP(80) - Allow - 0.0.0.0/0
- HTTPS(443) - Allow - 0.0.0.0/0
- SSH(22) - Allow - COMPANY_IP_RANGE
Outbound Rules:
- All Traffic - Allow - 0.0.0.0/0
Security Best Practices
- Implement Layered Security
- Properly configure public/private subnets in VPC design
- Use both NACLs and Security Groups for multiple security layers
- Apply Least Privilege Principle
- Only allow necessary ports and protocols
- Use specific source/destination IP ranges whenever possible
- Regular Review and Audit
- Remove unnecessary rules
- Reflect changes in security requirements
- Monitor access logs
- Documentation
- Document the purpose and necessity of each rule
- Maintain change history
- Utilize tags for resource management
Common Use Cases
- Public Subnets
- Allow HTTP/HTTPS inbound for web servers
- Restrict SSH access to specific IP ranges
- Allow outbound internet access
- Private Subnets
- Block direct internet access
- Allow specific internal traffic
- Control access to databases
- Database Subnets
- Allow only specific application subnet access
- Block all other inbound traffic
- Restrict outbound to necessary services
Troubleshooting Tips
- Check Rule Order
- Remember NACL rules are processed in numerical order
- First matching rule applies
- Verify Both Directions
- Check both inbound and outbound rules
- Remember the stateless nature of NACLs
- Monitor Denied Traffic
- Use VPC Flow Logs to track denied requests
- Helpful for identifying missing rules
AWS VPC 네트워크 보안 완벽 가이드: VPC, NACL, 보안 그룹 총정리
AWS 클라우드 환경에서 네트워크 보안을 구축할 때 가장 기본이 되는 세 가지 요소는 VPC, Network Access Control Lists(NACL), 그리고 보안 그룹입니다. 오늘은 이 세 가지 요소에 대해 자세히 알아보도록 하겠습니다.
VPC(Virtual Private Cloud)란?
VPC는 AWS 클라우드 내에서 논리적으로 격리된 사용자만의 가상 네트워크입니다. 마치 데이터센터에서 사용하는 전통적인 네트워크와 유사하지만, AWS의 확장 가능한 인프라를 사용할 수 있다는 장점이 있습니다.
VPC의 주요 구성 요소
- 서브넷(Subnet)
- VPC의 IP 주소 범위를 더 작은 단위로 나눈 것
- 퍼블릭 서브넷: 인터넷과 직접 통신 가능
- 프라이빗 서브넷: 인터넷과 직접 통신 불가능
- 라우팅 테이블(Route Table)
- 네트워크 트래픽의 방향을 결정하는 규칙들의 집합
- 각 서브넷은 하나의 라우팅 테이블과 연결
- 인터넷 게이트웨이(Internet Gateway)
- VPC와 인터넷 간의 통신을 가능하게 하는 구성 요소
- 퍼블릭 서브넷의 리소스가 인터넷과 통신하기 위해 필요
- NAT 게이트웨이(NAT Gateway)
- 프라이빗 서브넷의 리소스가 인터넷과 통신할 수 있게 해주는 중개자
- 외부에서 프라이빗 서브넷으로의 직접 접근은 불가능
NACL이란?
Network Access Control List(NACL)는 VPC의 서브넷 레벨에서 작동하는 방화벽입니다. 인바운드 및 아웃바운드 트래픽을 제어하는 규칙들의 번호 지정 목록으로, 네트워크 트래픽을 허용하거나 거부하는 역할을 합니다.
NACL 규칙 구성하기
NACL 규칙은 다음과 같은 요소로 구성됩니다:
- 규칙 번호 (1-32766)
- 유형 (SSH, HTTP 등)
- 프로토콜 (TCP, UDP 등)
- 포트 범위
- 소스/대상 (IP CIDR)
- 허용/거부 여부
NACL 모범 사례
- 규칙 번호 간격 두기
- 규칙 번호를 100 단위로 설정 (100, 200, 300…)
- 나중에 규칙 삽입이 필요할 때 유용
- 최소 권한 원칙 적용
- 필요한 트래픽만 허용
- 기본적으로 모든 트래픽 거부 후 필요한 것만 허용
보안 그룹(Security Group)
보안 그룹은 인스턴스 수준의 방화벽으로 작동하며, NACL과는 다른 방식으로 트래픽을 제어합니다.
보안 그룹의 규칙 평가 방식
보안 그룹의 규칙은 다음과 같은 방식으로 평가됩니다:
- 누적적 평가
1 2 3 4
예시 보안 그룹 규칙: 규칙 1: 포트 80 허용 (소스: 10.0.0.0/24) 규칙 2: 포트 80 허용 (소스: 192.168.1.0/24) 규칙 3: 포트 443 허용 (소스: 0.0.0.0/0)
- 모든 규칙이 OR 조건으로 평가됨
- 어떤 트래픽이 위 규칙 중 하나라도 일치하면 허용
- 규칙 순서는 중요하지 않음
- 상태 기반 방화벽
- 인바운드 트래픽이 허용되면 응답 트래픽은 자동으로 허용
- NACL과 달리 아웃바운드 규칙을 별도로 설정할 필요 없음
NACL vs 보안 그룹의 차이점
- 적용 범위
- NACL: 서브넷 레벨에서 적용
- 보안 그룹: 인스턴스 레벨에서 적용
- 상태 저장 여부
- NACL: Stateless (인바운드/아웃바운드 규칙을 각각 정의해야 함)
- 보안 그룹: Stateful (인바운드 트래픽이 허용되면 응답도 자동 허용)
- 규칙 처리
- NACL: 규칙 번호 순서대로 처리
- 보안 그룹: 모든 규칙을 누적적으로 평가
실제 구현 예시
NACL 구성 예시
1
2
3
4
5
6
7
8
9
10
11
인바운드 규칙:
100 - HTTP(80) - 허용 - 0.0.0.0/0
200 - HTTPS(443) - 허용 - 0.0.0.0/0
300 - SSH(22) - 허용 - 회사_IP_RANGE
* - 전체 트래픽 - 거부 - 0.0.0.0/0
아웃바운드 규칙:
100 - HTTP(80) - 허용 - 0.0.0.0/0
200 - HTTPS(443) - 허용 - 0.0.0.0/0
300 - Custom TCP(1024-65535) - 허용 - 0.0.0.0/0
* - 전체 트래픽 - 거부 - 0.0.0.0/0
보안 그룹 구성 예시
1
2
3
4
5
6
7
인바운드 규칙:
- HTTP(80) - 허용 - 0.0.0.0/0
- HTTPS(443) - 허용 - 0.0.0.0/0
- SSH(22) - 허용 - 회사_IP_RANGE
아웃바운드 규칙:
- 전체 트래픽 - 허용 - 0.0.0.0/0
보안 모범 사례
- 계층화된 보안 적용
- VPC 설계 시 퍼블릭/프라이빗 서브넷 적절히 구성
- NACL과 보안 그룹을 함께 사용하여 다중 보안 계층 구축
- 최소 권한 원칙
- 필요한 포트와 프로토콜만 허용
- 가능한 한 구체적인 소스/대상 IP 범위 사용
- 정기적인 검토와 감사
- 불필요한 규칙 제거
- 보안 요구사항 변경사항 반영
- 접근 로그 모니터링
- 문서화
- 각 규칙의 목적과 필요성 문서화
- 변경 이력 관리
- 태그 활용하여 리소스 관리
일반적인 사용 사례
- 공용 서브넷
- 웹 서버를 위한 HTTP/HTTPS 인바운드 허용
- 특정 IP 범위로 SSH 접근 제한
- 아웃바운드 인터넷 접속 허용
- 프라이빗 서브넷
- 직접적인 인터넷 접속 차단
- 특정 내부 트래픽 허용
- 데이터베이스 접근 제어
- 데이터베이스 서브넷
- 특정 애플리케이션 서브넷의 접근만 허용
- 다른 모든 인바운드 트래픽 차단
- 필요한 서비스로 아웃바운드 제한
문제 해결 팁
- 규칙 순서 확인
- NACL 규칙은 숫자 순서로 처리됨을 기억하세요
- 첫 번째 일치하는 규칙이 적용됨
- 양방향 검증
- 인바운드와 아웃바운드 규칙 모두 확인
- NACL의 상태 비저장(stateless) 특성을 기억하세요
- 거부된 트래픽 모니터링
- VPC 흐름 로그를 사용하여 거부된 요청 추적
- 누락된 규칙 식별에 도움됨