Proxmox Netzwerk und NAT Regeln

Inhalt

1. Linux Bridge erstellen

2. Interface bearbeiten und NAT Script erstellen

3. Firewall Regeln erstellen und zuweisen


1. Linux Bridge erstellen

Datacenter -> pve -> System -> Network -> Create -> Linux Bridge

Bestätigen mit OK und Apply Configuration

2. Interface bearbeiten und NAT Script erstellen

Datacenter -> pve -> Shell

>_ Shell
nano /etc/network/interfaces

Code unterhalb der Zeile bridge-fd 0 ergänzen

/etc/network/interfaces

        post-up iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o vmbr0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s 192.168.100.0/24 -o vmbr0 -j MASQUERADE
        post-up /var/scripts/iptables_nat_rule.sh A 192.168.100.100 51820 udp
        post-up /var/scripts/iptables_nat_rule.sh A 192.168.100.102 19132 udp
        post-up /var/scripts/iptables_nat_rule.sh A 192.168.100.103 80 tcp
        post-up /var/scripts/iptables_nat_rule.sh A 192.168.100.103 443 tcp
        post-up /var/scripts/iptables_nat_rule.sh A 192.168.100.119 8007 tcp

Ordner und Script erstellen

>_ Shell
mkdir /var/scripts
nano /var/scripts/iptables_nat_rule.sh
/var/scripts/iptables_nat_rule.sh
#! /bin/sh

# $1 = Action (A / D)
# $2 = Destination (Internal IP)
# $3 = Port
# $4 = Protocol (tcp / udp)

PUBLICIP=178.254.2.61

# Port Forward Rule
iptables -t nat -$1 PREROUTING -i vmbr0 -p $4 --dport $3 -j DNAT --to $2:$3

# NAT Reflection Rules
iptables -t nat -$1 PREROUTING -i vmbr1 -s 192.168.100.0/24 -d $PUBLICIP/32 -p $4 --dport $3 -j DNAT --to-destination>
iptables -t nat -$1 POSTROUTING -o vmbr1 -s 192.168.100.0/24 -d $2/32 -p $4 --dport $3 -j SNAT --to-source $PUBLICIP

3. Firewall Regeln erstellen und zuweisen

Datacenter -> Firewall -> Security Group -> Create -> pve

Datacenter -> Firewall -> Insert: Security Group

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

*