Is it possible to have both the Default Configuration using a Bridge and Masquerading (NAT) with iptables with one physical interface?
I currently have Masquerading (NAT) with iptables setup and it's a pain adding NAT rules to /etc/network/interfaces for each service I want to open up to the rest of the network.
I currently have Masquerading (NAT) with iptables setup and it's a pain adding NAT rules to /etc/network/interfaces for each service I want to open up to the rest of the network.
Code:
auto lo
iface lo inet loopback
auto eno1
# real ip
iface eno1 inet static
address 192.168.4.2/24
gateway 192.168.4.1
auto vmbr0
# vm network
iface vmbr0 inet static
address 192.168.5.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 '192.168.5.0/24' -o eno1 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.5.0/24' -o eno1 -j MASQUERADE
post-up iptables -t nat -A PREROUTING -p tcp -i eno1 --dport 2222 -j DNAT --to-destination 192.168.5.3:22
post-down iptables -t nat -D PREROUTING -p tcp -i eno1 --dport 2222 -j DNAT --to-destination 192.168.5.3:22
#work
iface wlp1s0 inet manual
source /etc/network/interfaces.d/*