Rule Components
Each firewall rule consists of several components that work together to control network traffic:Traffic Direction
Direction Control
- Ingress: Incoming traffic to your VM
- Egress: Outgoing traffic from your VM
- Rules can be specific to direction
- Different rules may apply for each direction
Protocol Specification
Protocol Types
- TCP: Reliable connection-based protocols
- UDP: Connectionless, fast protocols
- ICMP: Network diagnostic and control messages
- Protocol determines available configuration options
Core Rule Elements
- Direction
- Protocol
- IP Version
Traffic Flow ControlIngress (Incoming)
- Controls traffic coming into your VM
- Typical for services your VM provides
- Examples: Web servers, databases, SSH access
- Source IP restrictions apply to incoming connections
- Controls traffic leaving your VM
- Typical for services your VM consumes
- Examples: API calls, database connections, internet access
- Destination IP restrictions apply to outgoing connections
Adding Firewall Rules
To add a rule to an existing firewall:1
Access Rule Management
From the firewall details page or click “Add Rule” button on firewall card
2
Configure Direction
Select traffic direction:
- Ingress: For incoming traffic (most common)
- Egress: For outgoing traffic
3
Select Protocol
Choose the appropriate protocol:
- TCP: For web services, SSH, databases
- UDP: For DNS, streaming, real-time applications
- ICMP: For ping and network diagnostics
4
Set IP Version
Choose IP version:
- IPv4: Standard choice for most applications
- IPv6: For modern applications requiring IPv6
5
Configure IP Range
Enter remote IP range in CIDR format:
- Specific IP: 203.0.113.1/32
- IP Range: 192.168.1.0/24
- All IPs: 0.0.0.0/0 (IPv4) or ::/0 (IPv6)
6
Set Port Range (TCP/UDP only)
For TCP and UDP protocols, specify port ranges:
- Single Port: Set both min and max to same value
- Port Range: Set minimum and maximum ports
- Port Numbers: Must be between 1 and 65535
7
Save Rule
Click “Add Rule” to save the configuration
Port Range Specifications
For TCP and UDP protocols, you must configure port access:Port Configuration Requirements
Port Range Rules:
- Port numbers must be between 1 and 65535
- Minimum port must be less than or equal to maximum port
- Both minimum and maximum ports must be specified together
- For single port access, set both minimum and maximum to the same value
- Port ranges are not applicable for ICMP protocol
Common Port Configurations
- Single Ports
- Port Ranges
- Well-Known Ports
Specific Service Ports
Service | Protocol | Port | Min/Max Setting |
---|---|---|---|
SSH | TCP | 22 | Min: 22, Max: 22 |
HTTP | TCP | 80 | Min: 80, Max: 80 |
HTTPS | TCP | 443 | Min: 443, Max: 443 |
MySQL | TCP | 3306 | Min: 3306, Max: 3306 |
PostgreSQL | TCP | 5432 | Min: 5432, Max: 5432 |
Redis | TCP | 6379 | Min: 6379, Max: 6379 |
IP Range Validation
Remote IP ranges must follow CIDR notation for proper network specification:IPv4 CIDR Examples
IPv6 CIDR Examples
CIDR Validation Rules
IPv4 Validation
IPv4 Validation
IPv4 Address Requirements
- Address parts must be 0-255 (e.g., 192.168.1.100)
- CIDR prefix must be 0-32 (e.g., /24, /16, /8)
- Valid format: xxx.xxx.xxx.xxx/prefix
- Cannot use broadcast or network addresses in single IP specifications
IPv6 Validation
IPv6 Validation
IPv6 Address Requirements
- Must follow standard IPv6 format (e.g., 2001:db8::1)
- CIDR prefix must be 0-128 (e.g., /64, /32, /128)
- Supports compressed notation (:: for consecutive zeros)
- Valid format: xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/prefix
Common Rule Configurations
Web Server Rules
- Basic Web Server
- API Server
HTTP/HTTPS Traffic
Purpose | Direction | Protocol | Port | Remote IP | Use Case |
---|---|---|---|---|---|
Public HTTP | Ingress | TCP | 80 | 0.0.0.0/0 | Public website |
Public HTTPS | Ingress | TCP | 443 | 0.0.0.0/0 | Secure website |
SSH Access | Ingress | TCP | 22 | Your IP/32 | Server management |
Health Check | Ingress | TCP | 80 | Load balancer IP | Monitoring |
Database Server Rules
MySQL Database
MySQL Database
MySQL Server Protection
Rule Purpose | Configuration | Security Notes |
---|---|---|
Application Access | Ingress TCP 3306 from app servers | Restrict to app server IPs only |
Admin Access | Ingress TCP 3306 from admin IPs | Use VPN or bastion host |
Backup Access | Ingress TCP 3306 from backup server | Dedicated backup network preferred |
SSH Management | Ingress TCP 22 from admin IPs | Essential for server management |
PostgreSQL Database
PostgreSQL Database
PostgreSQL Server Protection
Rule Purpose | Configuration | Security Notes |
---|---|---|
Application Access | Ingress TCP 5432 from app servers | Restrict to application subnet |
Replication | Ingress TCP 5432 from replica IPs | Master-slave replication |
Monitoring | Ingress TCP 5432 from monitoring | Database performance monitoring |
SSH Management | Ingress TCP 22 from admin IPs | Server administration |
Application-Specific Rules
- Jupyter Notebook
- Docker Registry
- Monitoring Services
Data Science Environment
Network Diagnostic Rules
ICMP Rules
Network DiagnosticsPing Access:
- Direction: Ingress
- Protocol: ICMP
- IP Range: Your network or 0.0.0.0/0
- Use: Network connectivity testing
- Essential for network troubleshooting
- Helps diagnose connectivity issues
- Useful for performance analysis
Management Access
Administrative AccessSSH Access:
- Direction: Ingress
- Protocol: TCP
- Port: 22
- IP Range: Admin IPs only
- Use: Secure server management
- Consider VPN for enhanced security
- Reduces public IP exposure
- Centralized access control
Security Best Practices
Rule Design Principles
1
Start Restrictive
Begin with the most restrictive rules and gradually open access as needed
2
Document Purpose
Add clear descriptions to rules explaining their purpose and requirements
3
Use Specific IPs
Avoid 0.0.0.0/0 unless public access is truly required
4
Regular Review
Periodically audit rules and remove unnecessary access
Common Security Mistakes
Avoid These Common Errors:
- Overly Broad Access: Using 0.0.0.0/0 for internal services
- Unnecessary Ports: Opening ports that aren’t actively used
- Missing SSH Restrictions: Allowing SSH from any IP address
- Ignoring Egress: Not controlling outbound traffic
- Poor Documentation: Rules without clear purpose or ownership
Rule Testing and Validation
Testing New Rules
Testing New Rules
Validation Process
- Test rules in development environment first
- Use network diagnostic tools to verify connectivity
- Monitor application logs for connection issues
- Validate both allowed and blocked traffic
Troubleshooting Rules
Troubleshooting Rules
Common Debugging Steps
- Check rule order and precedence
- Verify CIDR notation is correct
- Confirm protocol and port specifications
- Test from source IP to verify access
- Review firewall logs for blocked connections
Remember that firewall rules may take up to 10 minutes to be fully applied after creation. Plan rule changes during maintenance windows to minimize service disruption.
Start with restrictive rules and gradually open access as needed. It’s much safer to start with limited access and expand than to start with broad access and try to restrict later.