Add IPTables fixes

This commit is contained in:
2025-03-22 17:57:48 +00:00
parent 612b899549
commit ab1d8e822b

View File

@ -113,6 +113,23 @@ sysctl --system
echo "Configuring firewall..." echo "Configuring firewall..."
ufw allow 1194/udp ufw allow 1194/udp
ufw allow OpenSSH ufw allow OpenSSH
# Set up NAT for VPN clients
echo "Setting up NAT for VPN clients..."
# Get the primary network interface
PRIMARY_NIC=$(ip route | grep default | awk '{print $5}')
echo "Primary network interface: $PRIMARY_NIC"
# Add NAT rules
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o $PRIMARY_NIC -j MASQUERADE
iptables -A FORWARD -s 10.8.0.0/24 -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
# Make NAT rules persistent
echo "Making NAT rules persistent..."
apt-get install -y iptables-persistent
echo "y" | netfilter-persistent save
echo "y" | ufw enable echo "y" | ufw enable
# Start OpenVPN service # Start OpenVPN service