I have a somewhat complex virtual network setup with multiple virtual machines and the links between them. There are perhaps 40 ip
commands to set it up which (if I read the docs correctly) need to be translated into appropriate interface definitions in in multiple .netdev
files along with other details in /etc/netplan/
files.
While it can be done this way, it will end up being (IMO) a lot less clear than using one script file for them all.
What is the best practice here? I'd like to fit in with standard setup methods, but I'd also like to have all the related (virtual) network config in one place.
Edit in response to comments, I have given a concrete example below:
ip link add veth_host_1 type veth peer name veth_host_2_b1
ip link add veth_host_2 type veth peer name veth_host_1_b1
...
ip link add veth_host_x type veth peer name veth_host_x_b2
ip link add veth_host_y type veth peer name veth_host_y_b2
...
#(several more like the above)
# Some direct links like this too:
ip link add veth_host_1_lnk1 type veth peer name veth_host_x_lnk1
# And the bridges
ip link add br_1 type bridge
ip link add br_2 type bridge
# Add the interfaces to the bridges
ip link set veth_host_1_b master br_1
ip link set veth_host_2_b master br_1
...
ip link set veth_host_x_b master br_2
ip link set veth_host_y_b master br_2
...
# Bring up the bridges
ip link set br_1 up
ip link set br_2 up
...
# The setup the interfaces
ip link set veth_host_1 address aa:bb:cc:dd:ee:f1 up
ip link set veth_host_2 address aa:bb:cc:dd:ee:f2 up
...
# (and so on for each interface)