ich stehe vor dem Rätsel wie und wo ich am besten meine Regeln für iptables ablege.
Ich benutze Proxmox (Debian 8.5) und habe nur eine IP-Adresse. Ich verwende daher NAT um den einzelnen LXC Containern Ports zuzuweisen aber auch zu sperren (z.B. ausgehende Ports in einem Fall).
Ich habe alle meine Regeln in dieser Form in /etc/network/interfaces eingetragen:
Code: Alles auswählen
# NAT interface for Teamspeak 3
auto vmbr9
iface vmbr9 inet static
address 10.0.0.1
netmask 255.0.0.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/8' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/8' -o vmbr0 -j MASQUERADE
# NAT interface for gitlab and maybe other service applications
auto vmbr8
iface vmbr8 inet static
address 192.168.0.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE
# -- SSH PORTS (22 + Machine ID) ---
# These two rules enable and disable the actual port forwarding of tcp port 2222 on the WAN IP to tcp port 22 on i$
# post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.21.21.5:22
# post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 2222 -j DNAT --to 10.21.21.5:22
# SSH Teamspeak3 server
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22101 -j DNAT --to 10.3.3.3:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22101 -j DNAT --to 10.3.3.3:22
# SSH Gitlab server
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22102 -j DNAT --to 192.168.0.50:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22102 -j DNAT --to 192.168.0.50:22
Neue Regeln werden nicht angewendet. Auch nicht wenn ich auf Proxmox networking neustarte. Ich muss als die gesamte "Baremetal"-Kiste neustarten und unterbreche damit sämtliche anderen Container.
Erst dann werden die Regeln angewendet. Manchmal. Wenn ich einen Fehler gemacht habe muss ich wieder neustarten, evtl. gilt dann auch keine der Regeln.
Ich weiß, dass ich all das auch über die von Proxmox mitgelieferte Firewall einstellen könnte, ich möchte es aber gerne allgemein lernen und nicht nur auf Proxmox bezogen.
Hat da jemanden einen Tipp für mich?
LG, Frank