This repository accompanies my answer to https://unix.stackexchange.com/q/735931/4989.
You'll need Mininet. The easiest way to use this is to download the mininet vm.
To deploy a virtual network with the routing and netfilter configuration applied:
sudo python network.py
To deploy a virtual network with the topology in place but without any routing or netfilter configuration:
sudo mn --custom topology.py --topo custom