49 lines
2.7 KiB
Django/Jinja
49 lines
2.7 KiB
Django/Jinja
# This file describes the network interfaces available on your system
|
|
# and how to activate them. For more information, see interfaces(5).
|
|
|
|
source /etc/network/interfaces.d/*
|
|
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
|
|
# The primary network interface
|
|
allow-hotplug {{ ansible_default_ipv4.interface }}
|
|
iface {{ ansible_default_ipv4.interface }} inet dhcp
|
|
|
|
auto lxcbr1
|
|
iface lxcbr1 inet static
|
|
bridge_ports none
|
|
bridge_fd 0
|
|
bridge_maxwait 0
|
|
address {{ ipv4_gateway }}/24
|
|
# Forward connections to lxcbr1 and lxcbr2
|
|
up iptables -t nat -C POSTROUTING -s {{ ipv4_subnet }} -d {{ ipv4_subnet }} -j ACCEPT 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ ipv4_subnet }} -d {{ ipv4_subnet }} -j ACCEPT
|
|
up iptables -t nat -C POSTROUTING -s {{ ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j ACCEPT 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j ACCEPT
|
|
# Masquerade all other connections
|
|
up iptables -t nat -C POSTROUTING -s {{ ipv4_subnet }} -j MASQUERADE 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ ipv4_subnet }} -j MASQUERADE
|
|
down iptables -t nat -D POSTROUTING -s {{ ipv4_subnet }} -d {{ ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|
|
down iptables -t nat -D POSTROUTING -s {{ ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|
|
down iptables -t nat -D POSTROUTING -s {{ ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|
|
|
|
auto lxcbr2
|
|
iface lxcbr2 inet static
|
|
bridge_ports none
|
|
bridge_fd 0
|
|
bridge_maxwait 0
|
|
address {{ outsider_ipv4_gateway }}/24
|
|
# Forward connections to lxcbr1 and lxcbr2
|
|
up iptables -t nat -C POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ ipv4_subnet }} -j ACCEPT 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ ipv4_subnet }} -j ACCEPT
|
|
up iptables -t nat -C POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j ACCEPT 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j ACCEPT
|
|
# Masquerade all other connections
|
|
up iptables -t nat -C POSTROUTING -s {{ outsider_ipv4_subnet }} -j MASQUERADE 2>/dev/null || \
|
|
iptables -t nat -A POSTROUTING -s {{ outsider_ipv4_subnet }} -j MASQUERADE
|
|
down iptables -t nat -D POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|
|
down iptables -t nat -D POSTROUTING -s {{ outsider_ipv4_subnet }} -d {{ outsider_ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|
|
down iptables -t nat -D POSTROUTING -s {{ outsider_ipv4_subnet }} -j MASQUERADE 2>/dev/null || true
|