Info
- Alle Befehle als root ausführen
Schritt 1
- Installiere iptables auf der Firewall
apt install iptables
Schritt 2
- füge folgendes Skript unter nano /usr/local/sbin/firewall
#!/bin/bash
# Interfaces
WAN_IF="enp0s3"
CLIENT_IF="enp0s8"
SERVER_IF="enp0s9"
# Netzwerke
CLIENT_NET="10.22.1.0/28"
SERVER_NET="192.168.5.0/26"
# Flush all existing rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Default Policies
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Masquerading für Internetzugriff
iptables -t nat -A POSTROUTING -s $CLIENT_NET -o $WAN_IF -j MASQUERADE
iptables -t nat -A POSTROUTING -s $SERVER_NET -o $WAN_IF -j MASQUERADE
Schritt 3
- Mache die Datei ausführbar
chmod +x /usr/local/sbin/firewall
Schritt 4
firewall
Schritt 5
sudo nano /etc/sysctl.conf
Schritt 6
- Suche die Zeile #net.ipv4.ip_forward=1 und entferne das Raute-Symbol
net.ipv4.ip_forward=1
Schritt 7
sysctl -p