Skip to content

Instantly share code, notes, and snippets.

@qskwood
Last active February 16, 2020 03:23
Show Gist options
  • Save qskwood/32e86389e31f70be7285c288b6634237 to your computer and use it in GitHub Desktop.
Save qskwood/32e86389e31f70be7285c288b6634237 to your computer and use it in GitHub Desktop.
These scripts add and remove IPv4 forwarding and NAT from a Linux bridge while still allowing it to be managed by Proxmox.
Place each file in /etc/network/if-up.d/ or /etc/network/if-down.d/ as appropriate, mark as executable, and name whatever you want.
#!/bin/bash -e
# /etc/network/if-down.d/vmbr1
if [[ $IFACE == "vmbr1" ]]; then
echo 0 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -D POSTROUTING -s '10.0.0.0/8' -o vmbr0 -j MASQUERADE
fi
#!/bin/bash -e
# /etc/network/if-up.d/vmbr1
if [[ $IFACE == "vmbr1" ]]; then
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s '10.0.0.0/8' -o vmbr0 -j MASQUERADE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment