Creating addtional dummy interfaces on appVM startup?

I have a script in /rw/config/rc.local.d/ which places an interface configuration file in the directory /rw/bind-dirs/etc/network/interfaces.d/ and which, upon a restart of the appVM, generates additional dummy loopback interfaces. Since I would like this script to generate interfaces without a restart I tried experimenting with enabling “Provides network” for the qube and placing the script in /rw/config/network-hooks.d/, but to no effect. I’m using a debian-12-minimal template.

I also tried the following test script:

#!/bin/sh

touch abc.txt
echo "abc"

which I made executable with file permissions rwxr-xr-x 1 user user, but no output. So…

  • First question, Did I miss a step beyond creating the /rw/config/network-hook.d/directory and selecting “Provides network”?
  • Second, is there a way to create dummy interfaces via a drop-in script that places a config file in /rw/bind-dirs/etc/networking/interfaces.d and does not require a restart? I suspect that my /rw/config/rc.local.d/script simply does not execute early enough.

Since I don’t actually need networking, I did not enable additional services, nor do I suspect this is the best approach.

Perhaps some basic troubleshooting? Forgive me if any of this insults your intelligence :slight_smile:

  1. Is the script executable?
  2. Have you tried creating a log to identify any errors?
  3. Would placing the script in /rw/config/qvm-start.d/ work?

Would this work?

1. Create the Script

First, you need to create a script that will create the dummy interfaces. You can place this script in a suitable directory, such as /usr/local/bin/. Here’s an example script:

bash

#!/bin/bash

# Create dummy interfaces
for i in {0..2}; do
    ip link add name dummy$i type dummy
    ip link set dummy$i up
done

Save this script as create_dummy_interfaces.sh and make it executable:

bash

sudo chmod +x /usr/local/bin/create_dummy_interfaces.sh

2. Create a systemd Service

Next, you need to create a systemd service that will execute this script when the network is up. Create a new service file in /etc/systemd/system/:

bash

sudo nano /etc/systemd/system/create-dummy-interfaces.service

Add the following content to the service file:

ini

[Unit]
Description=Create Dummy Network Interfaces
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/create_dummy_interfaces.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
  • Description: A brief description of what the service does.
  • After: Ensures that the service runs after the network is up.
  • Type=oneshot: Indicates that the service will perform a single task and then exit.
  • ExecStart: The command to execute (your script).
  • RemainAfterExit=yes: Keeps the service active after the script has run, which can be useful for tracking the service status.
  • WantedBy: Specifies when the service should be started.

3. Enable the Service

After creating the service file, you need to enable it so that it starts automatically on boot:

bash

sudo systemctl enable create-dummy-interfaces.service

4. Start the Service Manually (Optional)

If you want to test the service immediately without rebooting, you can start it manually:

bash

sudo systemctl start create-dummy-interfaces.service

You can check the status of the service to ensure it ran successfully:

bash

sudo systemctl status create-dummy-interfaces.service

5. Verify the Dummy Interfaces

After starting the service, you can verify that the dummy interfaces have been created:

bash

ip link show

You should see interfaces named dummy0, dummy1, and dummy2 listed.

Additional Considerations

  • Logging: If you want to log the output of your script, you can modify the script to redirect output to a log file. For example:
bash

echo "Created dummy interface dummy$i" >> /var/log/dummy_interfaces.log

I was unintentionally too vague with my questions, which I’ll edit to specify “drop-in” script, as I was trying to take advantage of Qubes config, which provides /rw/config/network-hooks.d/ specifically for interface creation. That said, if a drop-in script approach will not work, especially without toggling “Provides network”, then I’ll consider creating a service. I’m already able to create the interfaces with a drop-in script in /rw/config/rc.local.d/, it’s just not happening early enough.

Yes, they’re executable and manual execution works fine. I’ve checked journalctl, but no signs of an error there. I’ll take a look at /rw/config/qvm-start.d/.

I modified the /rw/config/rc.local.d/ script to copy the config directly to /etc/network/interfaces.d/, but still not early enough and had to rely on the bind-dirs copy.