-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-firewall.sh
More file actions
33 lines (25 loc) · 820 Bytes
/
Copy pathinit-firewall.sh
File metadata and controls
33 lines (25 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Firewall initialization script for Claude Code container
# This script sets up basic iptables rules for network sandboxing
# Exit on error
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
# Only initialize if not already done
if [ -f /var/run/firewall-initialized ]; then
exit 0
fi
# Basic firewall setup (customize as needed)
echo "Initializing firewall rules..."
# Allow loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow established connections
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Mark as initialized
touch /var/run/firewall-initialized
echo "Firewall initialized successfully"