0

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)
RabidMutant
  • 123
  • 5
  • Forget netplan (it was yet another bad idea from Canonical to begin with) and write the systemd-networkd configuration yourself. – Michael Hampton Mar 15 '21 at 00:21
  • I don't mind using netplan (or anything else) for the vanilla stuff. But I'd just like a way of saying "run this script afterwards". If I went back to ifupdown I'd have the same problem -- logically related settings all thrown into numerous distinct files (I think). – RabidMutant Mar 15 '21 at 02:42
  • Are you doing something _really_ oddball that can't be expressed in network configuration? – Michael Hampton Mar 15 '21 at 03:04
  • Probably not; virtual bridges and veth devices mainly. I may be confusing myself with ifcfg files -- looking at the ifupdown interface file it *looks* like I should be able to create and define virtual defices there...is that right? Or do I still need some kind of device definition file for each virtual device? – RabidMutant Mar 15 '21 at 03:12
  • You may want to share the specifics about what exactly you are doing. This is going well past the generic advice that can be given to a generic question. – Michael Hampton Mar 15 '21 at 03:15
  • Good point. I have added a representative subset to the original post. – RabidMutant Mar 15 '21 at 03:27
  • Wow, that's a lot of manual setup for something that libvirt could probably handle for you easily. Is there some reason you aren't using it? – Michael Hampton Mar 15 '21 at 03:30
  • Short answer: maybe ignorance, but it's one simple and clear script vs installing and configuring a bunch of stuff. I don't *think* I need more than the script...does libvirt enable this to be put in one place and does it add things I might need? – RabidMutant Mar 15 '21 at 03:41
  • This is for virtual machines, is it not? And you aren't _already_ using libvirt? ??? You are already in a world of pain from many different sources, and libvirt solves all of them. – Michael Hampton Mar 15 '21 at 03:50
  • I don't *feel* like I'm in pain...but I clearly should look at libvirt. Unfortunately, as you can imagine, migrating to it might not be a fast task (though I accept it might be best practice for virtualization). The immediate need is for a way to get a network script automatically run on boot (or use systemd-networkd IF it avoids the plethora of config files). If there are no hook scripts, I guess it just needs to be its own service started after networking. – RabidMutant Mar 15 '21 at 04:05

0 Answers0