π Network Policy
Monitor and control network traffic at the application level with Jibril's network policy engine. Block suspicious connections, alert on unauthorized access, and enforce network security rules for domains and IP addresses.
π Default Locationβ
/etc/jibril/netpolicy.yaml
π Quick Startβ
1οΈβ£ Create Policy Fileβ
# Create network policy file
sudo vi /etc/jibril/netpolicy.yaml
2οΈβ£ Enable in Configurationβ
# In config.yaml
features:
- netpolicy
feature_options:
netpolicy:
file: /etc/jibril/netpolicy.yaml
events:
- dropip
π― Configuration Structureβ
The network policy uses a simple allow/deny model with explicit rule lists:
network_policy:
# Default action: allow | deny
policy: allow
# Always allow these (optional)
allow:
- 127.0.0.0/8 # CIDR blocks
- 8.8.8.8 # IP addresses
- google.com # Domain names
# Always deny these (optional)
deny:
- 192.168.100.0/24 # CIDR blocks
- example.com # Domain names
π policy: allowβ
Allow by default, deny specific rules
- Allow all traffic by default
- Explicitly block known threats
- Best for most environments
π policy: denyβ
Deny by default, allow specific rules
- Block all traffic by default
- Explicitly allow trusted destinations
- Zero-trust network model
π Rule Typesβ
Network policy rules support three formats in the same list:
π’ CIDR Blocksβ
allow:
- 127.0.0.0/8 # Localhost
- 192.168.0.0/16 # Private networks
- 10.0.0.0/8 # Private networks
- ::1/128 # IPv6 localhost
π IP Addressesβ
deny:
- 203.0.113.5 # Specific IPv4
- 8.8.8.8 # DNS servers
- 2001:db8::1 # Specific IPv6
π Domain Namesβ
deny:
- malware-site.com
- phishing-domain.net
- suspicious-tracker.org
Note: Domain rules block the resolved IPs, not DNS resolution itself.
π‘οΈ Common Configurationsβ
π Standard Protection (Recommended)β
Allow by default, block known threats:
network_policy:
policy: allow
allow:
# Internal networks (always allow)
- 127.0.0.0/8
- 192.168.0.0/16
- 10.0.0.0/8
- 172.16.0.0/12
# DNS servers
- 8.8.8.8
- 1.1.1.1
deny:
# Block malicious domains
- malware-domain.com
- phishing-site.net
- cryptominer-pool.org
Use case: Production environments with threat intelligence feeds
π° Zero-Trust Modeβ
Deny by default, allow only trusted destinations:
network_policy:
policy: deny
allow:
# Localhost
- 127.0.0.0/8
# Internal infrastructure
- 10.0.1.0/24
- 10.0.2.0/24
# Trusted external services
- trusted-api.company.com
- cdn.example.com
- github.com
Use case: High-security environments, sensitive workloads, compliance requirements
π Understanding Rule Precedenceβ
Rules Override Defaultβ
Explicit rules always take precedence over the default policy:
network_policy:
policy: allow # Default: allow all
deny:
- 8.8.8.8 # Blocked (explicit)
8.8.8.8 is blocked despite default
allow
CIDR Specificityβ
More specific CIDR rules override broader ones:
allow:
- 192.168.0.0/16 # Allow entire range
deny:
- 192.168.1.100 # Block specific IP
192.168.1.100 is blocked (more specific)
π Complete Exampleβ
View production-ready configuration
network_policy:
# Default action: allow most traffic
policy: allow
# Always allow these (whitelist)
allow:
# Loopback
- 127.0.0.0/8
- ::1/128
# Private networks
- 192.168.0.0/16
- 172.16.0.0/12
- 10.0.0.0/8
# Link-local
- 169.254.0.0/16
- fe80::/10
# DNS servers
- 8.8.8.8 # Google DNS
- 8.8.4.4 # Google DNS
- 1.1.1.1 # Cloudflare DNS
- 9.9.9.9 # Quad9 DNS
# Trusted services (if needed)
- github.com
- docker.io
# Always deny these (blacklist)
deny:
# Known malicious domains
- malware-c2-server.com
- phishing-campaign.net
- cryptominer-pool.org
# Known malicious IPs
- 203.0.113.0/24 # Documentation range (example)
# Suspicious services
- torrent-tracker.com
- piracy-site.org
π Best Practicesβ
β Recommendedβ
- π Start with
policy: allowto understand traffic - π Use threat intelligence feeds for deny lists
- π Always allow localhost and internal networks
- π Remember to allow your own IP address(es)
- π Allow necessary DNS servers
- π§ͺ Test policy changes in staging first
- π Document each rule's purpose
- π Monitor dropip events regularly
β οΈ Avoidβ
- β Using
policy: denywithout thorough testing - β Blocking internal networks accidentally
- β Forgetting to allow DNS servers
- β No documentation of deny rules
- β Overly restrictive rules breaking apps
- β Deploying to production without staging tests
- β Ignoring dropip event patterns
π Monitoring Policy Eventsβ
Network policy violations generate dropip events. Enable them in the configuration file to track blocked connections:
# View policy events in real-time
sudo tail -f /var/log/jibril.out | jq 'select(.metadata.kind == "dropip")'
# Count blocked connections
sudo cat /var/log/jibril.out | jq 'select(.metadata.kind == "dropip")' | wc -l
π§ Typical Workflowβ
- Start permissive: Deploy with
policy: allowand minimal deny rules - Observe: Monitor dropip events and network behavior
- Refine: Add known threats to deny list
- Test: Validate in staging environment
- Deploy: Roll out to production
- Iterate: Continuously update based on threat intelligence