Custom network/firewall bash script for Ubuntu

Create the file under this path - /etc/networkd-dispatcher/routable.d/10-eth0-post-up - with the following contents:

#!/bin/bash

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s '10.0.0.0/16' -o eth0 -j MASQUERADE
Make it executable:
chmod +x /etc/networkd-dispatcher/routable.d/10-eth0-post-up