Routing Problem?

legolas

Renowned Member
Dec 16, 2010
30
1
73
Hallo,

ich habe einen PVE mit diesen Netzwerkeinstellungen:
Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 152.53.85.147/22
        gateway 152.53.85.1

auto vmbr0
iface vmbr0 inet static
        address 10.10.10.1/24
        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.10.10.0/24' -o eth0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
post-up   iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80  -j DNAT --to-destination 10.10.10.100:80
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80  -j DNAT --to-destination 10.10.10.100:80
post-up   iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
post-up   iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
post-up   iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1

jetzt hat der PVE Host eine zusätzliche Netzwerkkarte bekommen und jetzt sieht die Konfiguration so aus:
Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 152.53.85.147/22
        gateway 152.53.85.1

# zusätzliche Netzwerkkarte
auto eth1
iface eth1 inet static
        address 192.168.100.2/24

auto vmbr0
iface vmbr0 inet static
        address 10.10.10.1/24
        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.10.10.0/24' -o eth0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
post-up   iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80  -j DNAT --to-destination 10.10.10.100:80
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80  -j DNAT --to-destination 10.10.10.100:80
post-up   iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
post-up   iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
post-up   iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1

Ich kann vom PVE selbst aus einen Host im Netz 192.168.100.x anpingen

Ich habe mir eine VM erstellt und der die IP 192.168.100.3 gegeben. Ich kann die IP 192.168.100.2 anpingen. Was ich möchte ist das der ganze Traffic aus dem Netz 192.168.100.x über das Gateway 192.168.100.1 läuft aber das kann ich nicht angeben weil mir der PVE sagt das es schon ein default GW gibt. Geht das was ich da bauen will überhaupt? Bzw. was mache ich falsch.

Danke für jeden Tipp

SW
 
Du kannst nur ein default Gateway bei Dir haben. Schau dir mal das sogenannte Policy Based Routing an.
 
Last edited:
wenn die eth1 der einzige link ins 192.168.100er netz ist, dann musst du da auch eine vmbr drauf machen um VMs in das selbe netz zu geben. und wenn die VMs dann auch im 192.168.100er netz sind, dann erreichen sie die 192.168.100.1 direkt, ohne über den pve-host gehen zu müssen, also def-gw in der VM setzen ;-)